From 7450966ef05e1a9e4a9bb7147538ba0f916d84f7 Mon Sep 17 00:00:00 2001 From: Yarden Bar Date: Sun, 31 May 2015 10:30:51 +0300 Subject: [PATCH 1/3] Short-circut GenIndex when using concrete ES index name --- cmd/bosun/expr/logstash.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/bosun/expr/logstash.go b/cmd/bosun/expr/logstash.go index f25ca6933e..8d16b47bb0 100644 --- a/cmd/bosun/expr/logstash.go +++ b/cmd/bosun/expr/logstash.go @@ -122,6 +122,12 @@ func (e *LogstashElasticHosts) GenIndices(r *LogstashRequest) (string, error) { if err != nil { return "", err } + // Short-circut when using concrete ES index name + if len(r.IndexRoot) > 0 { + if r.IndexRoot[len(r.IndexRoot)-1] == '/' { + return r.IndexRoot[:len(r.IndexRoot)-1], nil + } + } indices, err := lsClient.IndexNames() if err != nil { return "", err @@ -147,7 +153,7 @@ func (e *LogstashElasticHosts) GenIndices(r *LogstashRequest) (string, error) { } } if len(selectedIndices) == 0 { - return "", fmt.Errorf("no elastic indices available during this time range") + return "", fmt.Errorf("no elastic indices available during this time range, start/end: [%s|%s]", start, end) } return strings.Join(selectedIndices, ","), nil } From fdad55377fe7b6a83ab9d8ccab885553dca4ff84 Mon Sep 17 00:00:00 2001 From: Yarden Bar Date: Sun, 31 May 2015 10:51:26 +0300 Subject: [PATCH 2/3] Revert GenIndex error message formatting --- cmd/bosun/expr/logstash.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/bosun/expr/logstash.go b/cmd/bosun/expr/logstash.go index 8d16b47bb0..4f50e097c4 100644 --- a/cmd/bosun/expr/logstash.go +++ b/cmd/bosun/expr/logstash.go @@ -153,7 +153,7 @@ func (e *LogstashElasticHosts) GenIndices(r *LogstashRequest) (string, error) { } } if len(selectedIndices) == 0 { - return "", fmt.Errorf("no elastic indices available during this time range, start/end: [%s|%s]", start, end) + return "", fmt.Errorf("no elastic indices available during this time range") } return strings.Join(selectedIndices, ","), nil } From 910120b3f8259c5513aaed66d4b5f69b31499595 Mon Sep 17 00:00:00 2001 From: Yarden Bar Date: Sun, 31 May 2015 13:29:09 +0300 Subject: [PATCH 3/3] Better concrete suffix checking --- cmd/bosun/expr/logstash.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/bosun/expr/logstash.go b/cmd/bosun/expr/logstash.go index 4f50e097c4..38021f3b5a 100644 --- a/cmd/bosun/expr/logstash.go +++ b/cmd/bosun/expr/logstash.go @@ -123,10 +123,8 @@ func (e *LogstashElasticHosts) GenIndices(r *LogstashRequest) (string, error) { return "", err } // Short-circut when using concrete ES index name - if len(r.IndexRoot) > 0 { - if r.IndexRoot[len(r.IndexRoot)-1] == '/' { - return r.IndexRoot[:len(r.IndexRoot)-1], nil - } + if strings.HasSuffix(r.IndexRoot, "/") { + return r.IndexRoot[:len(r.IndexRoot)-1], nil } indices, err := lsClient.IndexNames() if err != nil { @@ -153,7 +151,7 @@ func (e *LogstashElasticHosts) GenIndices(r *LogstashRequest) (string, error) { } } if len(selectedIndices) == 0 { - return "", fmt.Errorf("no elastic indices available during this time range") + return "", fmt.Errorf("no elastic indices available during this time range, index[%s]", r.IndexRoot) } return strings.Join(selectedIndices, ","), nil }