mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #13609 from Yukinoshita-Yukino/master
elasticsearch: fix no limit size in terms aggregation for alerting queries
This commit is contained in:
commit
1b32ff5795
@ -171,6 +171,10 @@ func addTermsAgg(aggBuilder es.AggBuilder, bucketAgg *BucketAgg, metrics []*Metr
|
|||||||
} else {
|
} else {
|
||||||
a.Size = 500
|
a.Size = 500
|
||||||
}
|
}
|
||||||
|
if a.Size == 0 {
|
||||||
|
a.Size = 500
|
||||||
|
}
|
||||||
|
|
||||||
if minDocCount, err := bucketAgg.Settings.Get("min_doc_count").Int(); err == nil {
|
if minDocCount, err := bucketAgg.Settings.Get("min_doc_count").Int(); err == nil {
|
||||||
a.MinDocCount = &minDocCount
|
a.MinDocCount = &minDocCount
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func TestExecuteTimeSeriesQuery(t *testing.T) {
|
|||||||
_, err := executeTsdbQuery(c, `{
|
_, err := executeTsdbQuery(c, `{
|
||||||
"timeField": "@timestamp",
|
"timeField": "@timestamp",
|
||||||
"bucketAggs": [
|
"bucketAggs": [
|
||||||
{ "type": "terms", "field": "@host", "id": "2" },
|
{ "type": "terms", "field": "@host", "id": "2", "settings": { "size": "0", "order": "asc" } },
|
||||||
{ "type": "date_histogram", "field": "@timestamp", "id": "3" }
|
{ "type": "date_histogram", "field": "@timestamp", "id": "3" }
|
||||||
],
|
],
|
||||||
"metrics": [{"type": "count", "id": "1" }]
|
"metrics": [{"type": "count", "id": "1" }]
|
||||||
@ -69,7 +69,9 @@ func TestExecuteTimeSeriesQuery(t *testing.T) {
|
|||||||
sr := c.multisearchRequests[0].Requests[0]
|
sr := c.multisearchRequests[0].Requests[0]
|
||||||
firstLevel := sr.Aggs[0]
|
firstLevel := sr.Aggs[0]
|
||||||
So(firstLevel.Key, ShouldEqual, "2")
|
So(firstLevel.Key, ShouldEqual, "2")
|
||||||
So(firstLevel.Aggregation.Aggregation.(*es.TermsAggregation).Field, ShouldEqual, "@host")
|
termsAgg := firstLevel.Aggregation.Aggregation.(*es.TermsAggregation)
|
||||||
|
So(termsAgg.Field, ShouldEqual, "@host")
|
||||||
|
So(termsAgg.Size, ShouldEqual, 500)
|
||||||
secondLevel := firstLevel.Aggregation.Aggs[0]
|
secondLevel := firstLevel.Aggregation.Aggs[0]
|
||||||
So(secondLevel.Key, ShouldEqual, "3")
|
So(secondLevel.Key, ShouldEqual, "3")
|
||||||
So(secondLevel.Aggregation.Aggregation.(*es.DateHistogramAgg).Field, ShouldEqual, "@timestamp")
|
So(secondLevel.Aggregation.Aggregation.(*es.DateHistogramAgg).Field, ShouldEqual, "@timestamp")
|
||||||
|
Loading…
Reference in New Issue
Block a user