Elasticsearch: Use minimum interval for alerts (#30049)

The current backend code doesn't honor the minimum interval set in the UI for alerts using 
the Elasticsearch data source. This means that the data the alerts are triggering against 
will never match the data in the visualization if auto is used in the date histogram as interval. 
This fixes the problem to make sure that date histogram auto interval is set according to 
min interval set in UI for the query or fallback to data source min interval setting.

Fixes #22082

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
pull/30280/head
Chris Cowan 5 years ago committed by GitHub
parent dac7add457
commit 3d7748d9f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      pkg/tsdb/elasticsearch/time_series_query.go
  2. 2
      pkg/tsdb/elasticsearch/time_series_query_test.go

@ -313,7 +313,7 @@ func (p *timeSeriesQueryParser) parse(tsdbQuery *tsdb.TsdbQuery) ([]*Query, erro
return nil, err
}
alias := model.Get("alias").MustString("")
interval := strconv.FormatInt(q.IntervalMs, 10) + "ms"
interval := model.Get("interval").MustString("")
queries = append(queries, &Query{
TimeField: timeField,

@ -865,6 +865,7 @@ func TestTimeSeriesQueryParser(t *testing.T) {
"timeField": "@timestamp",
"query": "@metric:cpu",
"alias": "{{@hostname}} {{metric}}",
"interval": "10m",
"metrics": [
{
"field": "@value",
@ -921,6 +922,7 @@ func TestTimeSeriesQueryParser(t *testing.T) {
So(q.TimeField, ShouldEqual, "@timestamp")
So(q.RawQuery, ShouldEqual, "@metric:cpu")
So(q.Alias, ShouldEqual, "{{@hostname}} {{metric}}")
So(q.Interval, ShouldEqual, "10m")
So(q.Metrics, ShouldHaveLength, 2)
So(q.Metrics[0].Field, ShouldEqual, "@value")

Loading…
Cancel
Save