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

Commit

Permalink
fix validation and defaults for elasticsearch-idx retry-interval
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
Dieterbe committed Aug 23, 2016
1 parent 28b9c83 commit ca0ff63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ enabled = false
index = metric
# Elasticsearch host addresses (multiple hosts can be specified as comma-separated list)
hosts = localhost:9200
# how often the retry buffer should be flushed to ES
retry-interval = 1h
# how often the retry buffer should be flushed to ES. Valid units are 's', 'm', 'h'.
retry-interval = 10m
# max number of concurrent connections to ES
max-conns = 20
# max number of docs to keep in the BulkIndexer buffer
Expand Down
5 changes: 5 additions & 0 deletions idx/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package elasticsearch
import (
"bytes"
"encoding/json"
"errors"
"flag"
"fmt"
"strings"
Expand Down Expand Up @@ -153,6 +154,10 @@ func New() *EsIdx {

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

if esRetryInterval < time.Second {
return errors.New("Invalid retry-interval. Valid units are 's', 'm', 'h'. Must be at least 1 second")
}

log.Info("initializing EsIdx. Hosts=%s", esHosts)
if err := e.MemoryIdx.Init(stats); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions metrictank-sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ hosts = localhost:9200
# http basic auth
user =
pass =
# how often the retry buffer should be flushed to ES
retry-interval = 10min
# how often the retry buffer should be flushed to ES. Valid units are "s", "m", "h"
retry-interval = 10m
# max number of concurrent connections to ES
max-conns = 20
# max numver of docs to keep in the BulkIndexer buffer
Expand Down
4 changes: 2 additions & 2 deletions scripts/config/metrictank.ini
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ hosts = localhost:9200
# http basic auth
user =
pass =
# how often the retry buffer should be flushed to ES
retry-interval = 10min
# how often the retry buffer should be flushed to ES. Valid units are "s", "m", "h".
retry-interval = 10m
# max number of concurrent connections to ES
max-conns = 20
# max numver of docs to keep in the BulkIndexer buffer
Expand Down

0 comments on commit ca0ff63

Please sign in to comment.