Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit ca0ff63

Browse files
committed
fix validation and defaults for elasticsearch-idx retry-interval
fixes crashes like: ``` Aug 23 09:41:39 dieter-mt1 metrictank[20586]: panic: non-positive interval for NewTicker Aug 23 09:41:39 dieter-mt1 metrictank[20586]: goroutine 70 [running]: Aug 23 09:41:39 dieter-mt1 metrictank[20586]: panic(0xa32980, 0xc82000e9f0) Aug 23 09:41:39 dieter-mt1 metrictank[20586]: /usr/local/go/src/runtime/panic.go:481 +0x3e6 Aug 23 09:41:39 dieter-mt1 metrictank[20586]: time.NewTicker(0x0, 0x14) Aug 23 09:41:39 dieter-mt1 metrictank[20586]: /usr/local/go/src/time/tick.go:23 +0xe4 Aug 23 09:41:39 dieter-mt1 metrictank[20586]: github.com/raintank/metrictank/idx/elasticsearch.(*RetryBuffer).run(0xc820050230, 0x0) Aug 23 09:41:39 dieter-mt1 metrictank[20586]: /home/ubuntu/.go_workspace/src/github.com/raintank/metrictank/idx/elasticsearch/elasticsearch.go:114 +0x5d Aug 23 09:41:39 dieter-mt1 metrictank[20586]: created by github.com/raintank/metrictank/idx/elasticsearch.NewRetryBuffer Aug 23 09:41:39 dieter-mt1 metrictank[20586]: /home/ubuntu/.go_workspace/src/github.com/raintank/metrictank/idx/elasticsearch/elasticsearch.go:67 +0x176 ```
1 parent 28b9c83 commit ca0ff63

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

docs/metadata.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ enabled = false
2121
index = metric
2222
# Elasticsearch host addresses (multiple hosts can be specified as comma-separated list)
2323
hosts = localhost:9200
24-
# how often the retry buffer should be flushed to ES
25-
retry-interval = 1h
24+
# how often the retry buffer should be flushed to ES. Valid units are 's', 'm', 'h'.
25+
retry-interval = 10m
2626
# max number of concurrent connections to ES
2727
max-conns = 20
2828
# max number of docs to keep in the BulkIndexer buffer

idx/elasticsearch/elasticsearch.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package elasticsearch
33
import (
44
"bytes"
55
"encoding/json"
6+
"errors"
67
"flag"
78
"fmt"
89
"strings"
@@ -153,6 +154,10 @@ func New() *EsIdx {
153154

154155
func (e *EsIdx) Init(stats met.Backend) error {
155156

157+
if esRetryInterval < time.Second {
158+
return errors.New("Invalid retry-interval. Valid units are 's', 'm', 'h'. Must be at least 1 second")
159+
}
160+
156161
log.Info("initializing EsIdx. Hosts=%s", esHosts)
157162
if err := e.MemoryIdx.Init(stats); err != nil {
158163
return err

metrictank-sample.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ hosts = localhost:9200
197197
# http basic auth
198198
user =
199199
pass =
200-
# how often the retry buffer should be flushed to ES
201-
retry-interval = 10min
200+
# how often the retry buffer should be flushed to ES. Valid units are "s", "m", "h"
201+
retry-interval = 10m
202202
# max number of concurrent connections to ES
203203
max-conns = 20
204204
# max numver of docs to keep in the BulkIndexer buffer

scripts/config/metrictank.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ hosts = localhost:9200
194194
# http basic auth
195195
user =
196196
pass =
197-
# how often the retry buffer should be flushed to ES
198-
retry-interval = 10min
197+
# how often the retry buffer should be flushed to ES. Valid units are "s", "m", "h".
198+
retry-interval = 10m
199199
# max number of concurrent connections to ES
200200
max-conns = 20
201201
# max numver of docs to keep in the BulkIndexer buffer

0 commit comments

Comments
 (0)