Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templates: Reduce number of shards to 1 #13

Merged
merged 4 commits into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,21 @@ changelog: git_chglog_check

CONCOURSE_PIPELINE := go-elasticsearch-alerts


check_fly:
if [ -z "$(FLY)" ]; then \
sudo mkdir -p /usr/local/bin; \
sudo wget -q -O /usr/local/bin/fly "https://ci.morningconsultintelligence.com/api/v1/cli?arch=amd64&platform=linux"; \
sudo chmod +x /usr/local/bin/fly; \
/usr/local/bin/fly --version; \
fi
ifeq ($(FLY),)
sudo mkdir -p /usr/local/bin
sudo wget -q -O /usr/local/bin/fly "https://ci.morningconsultintelligence.com/api/v1/cli?arch=amd64&platform=linux";
sudo chmod +x /usr/local/bin/fly
/usr/local/bin/fly --version
endif
.PHONY: check_fly


set_pipeline: check_fly
$(FLY) --target mci-ci-oss validate-pipeline \
--config ci/pipeline.yml
--config ci/pipeline.yml \
--strict

$(FLY) --target mci-ci-oss set-pipeline \
--config ci/pipeline.yml \
Expand Down
2 changes: 1 addition & 1 deletion ci/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ readonly GORELEASER_VERSION=v0.104.0

echo "==> Installing APK dependencies"

apk add -qU --no-progress \
apk add -qU --no-cache --no-progress \
make \
bash \
git \
Expand Down
16 changes: 6 additions & 10 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
# ====================================
resource_types:
- name: slack-alert
type: docker-image
type: registry-image
source:
repository: arbourd/concourse-slack-alert-resource
channel: '#build'

- name: pull-request
type: docker-image
type: registry-image
source:
repository: teliaoss/github-pr-resource

Expand All @@ -39,7 +38,7 @@ resources:
tag_filter: 'v*'

- name: golang
type: docker-image
type: registry-image
source:
repository: golang
tag: 1.11.4-alpine3.8
Expand Down Expand Up @@ -76,22 +75,19 @@ jobs:
params:
path: test-pull-request
status: success
context: $BUILD_JOB_NAME
comment: test-pull-request/ci/pr_test_success
context: test-pr
on_failure:
put: test-pull-request
params:
path: test-pull-request
status: failure
context: $BUILD_JOB_NAME
comment: test-pull-request/ci/pr_test_failure
context: test-pr
on_abort:
put: test-pull-request
params:
path: test-pull-request
status: error
context: $BUILD_JOB_NAME
comment: test-pull-request/ci/pr_test_failure
context: test-pr

- name: build-release
serial: true
Expand Down
2 changes: 0 additions & 2 deletions ci/pr_test_failure

This file was deleted.

2 changes: 0 additions & 2 deletions ci/pr_test_success

This file was deleted.

7 changes: 5 additions & 2 deletions ci/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@

set -e

PROJECT="github.com/morningconsult/go-elasticsearch-alerts"
readonly PROJECT="github.com/morningconsult/go-elasticsearch-alerts"

# NOTE: This script is intended to be run in a
# golang:1.11.3-alpine3.8 Docker container

# Install dependencies
apk add -qU --no-cache make git bzr
apk add -qU --no-cache --no-progress \
make \
git \
bzr

# Run tests
CGO_ENABLED=0 make test
4 changes: 2 additions & 2 deletions command/query/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
)

const (
templateVersion string = "0.0.1"
templateVersion string = "0.0.2"
defaultStateIndexAlias string = "go-es-alerts"
defaultTimestampFormat string = time.RFC3339
defaultBodyField string = "hits.hits._source"
Expand Down Expand Up @@ -272,7 +272,7 @@ func (q *QueryHandler) Run(ctx context.Context, outputCh chan *alert.Alert, wg *
// will be named 'go-es-alerts-status-{date}'; therefore, this template
// enables searching all state indices via this alias
func (q *QueryHandler) PutTemplate(ctx context.Context) error {
payload := fmt.Sprintf(`{"index_patterns":["%s-status-%s-*"],"order":0,"aliases":{%q:{}},"settings":{"index":{"number_of_shards":5,"number_of_replicas":1,"auto_expand_replicas":"0-2","translog":{"flush_threshold_size":"752mb"},"sort":{"field":["next_query","rule_name","hostname"],"order":["desc","desc","desc"]}}},"mappings":{"_doc":{"dynamic_templates":[{"strings_as_keywords":{"match_mapping_type":"string","mapping":{"type":"keyword"}}}],"properties":{"@timestamp":{"type":"date"},"rule_name":{"type":"keyword"},"next_query":{"type":"date"},"hostname":{"type":"keyword"},"hits_count":{"type":"long","null_value":0},"hits":{"enabled":false}}}}}`, defaultStateIndexAlias, templateVersion, q.TemplateName())
payload := fmt.Sprintf(`{"index_patterns":["%s-status-%s-*"],"order":0,"aliases":{%q:{}},"settings":{"index":{"number_of_shards":1,"number_of_replicas":1,"auto_expand_replicas":"0-3","codec":"best_compression","translog":{"flush_threshold_size":"752mb"},"sort":{"field":["next_query","rule_name","hostname"],"order":["desc","desc","desc"]}}},"mappings":{"_doc":{"dynamic_templates":[{"strings_as_keywords":{"match_mapping_type":"string","mapping":{"type":"keyword"}}}],"properties":{"@timestamp":{"type":"date"},"rule_name":{"type":"keyword"},"next_query":{"type":"date"},"hostname":{"type":"keyword"},"hits_count":{"type":"long","null_value":0},"hits":{"enabled":false}}}}}`, defaultStateIndexAlias, templateVersion, q.TemplateName())

resp, err := q.makeRequest(ctx, "PUT", fmt.Sprintf("%s/_template/%s", q.esURL, q.TemplateName()), []byte(payload))
if err != nil {
Expand Down