mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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>
This commit is contained in:
parent
dac7add457
commit
3d7748d9f8
@ -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…
Reference in New Issue
Block a user