Elasticsearch: Add Support for Serial Differencing Pipeline Aggregation (#28618)
* Elasticsearch: Add support for serial diff pipeline aggregation * Removing settings transsforms * Removing unused deps * removing unused dep * Fixing type in test * Adding backend support for serial_diff
This commit is contained in:
@@ -48,6 +48,7 @@ var metricAggType = map[string]string{
|
||||
"moving_fn": "Moving Function",
|
||||
"cumulative_sum": "Cumulative Sum",
|
||||
"derivative": "Derivative",
|
||||
"serial_diff": "Serial Difference",
|
||||
"bucket_script": "Bucket Script",
|
||||
"raw_document": "Raw Document",
|
||||
}
|
||||
@@ -68,6 +69,7 @@ var pipelineAggType = map[string]string{
|
||||
"moving_fn": "moving_fn",
|
||||
"cumulative_sum": "cumulative_sum",
|
||||
"derivative": "derivative",
|
||||
"serial_diff": "serial_diff",
|
||||
"bucket_script": "bucket_script",
|
||||
}
|
||||
|
||||
|
||||
@@ -650,6 +650,64 @@ func TestExecuteTimeSeriesQuery(t *testing.T) {
|
||||
So(plAgg.BucketPath, ShouldEqual, "_count")
|
||||
})
|
||||
|
||||
Convey("With serial_diff", func() {
|
||||
c := newFakeClient(5)
|
||||
_, err := executeTsdbQuery(c, `{
|
||||
"timeField": "@timestamp",
|
||||
"bucketAggs": [
|
||||
{ "type": "date_histogram", "field": "@timestamp", "id": "4" }
|
||||
],
|
||||
"metrics": [
|
||||
{ "id": "3", "type": "sum", "field": "@value" },
|
||||
{
|
||||
"id": "2",
|
||||
"type": "serial_diff",
|
||||
"pipelineAgg": "3"
|
||||
}
|
||||
]
|
||||
}`, from, to, 15*time.Second)
|
||||
So(err, ShouldBeNil)
|
||||
sr := c.multisearchRequests[0].Requests[0]
|
||||
|
||||
firstLevel := sr.Aggs[0]
|
||||
So(firstLevel.Key, ShouldEqual, "4")
|
||||
So(firstLevel.Aggregation.Type, ShouldEqual, "date_histogram")
|
||||
|
||||
serialDiffAgg := firstLevel.Aggregation.Aggs[1]
|
||||
So(serialDiffAgg.Key, ShouldEqual, "2")
|
||||
plAgg := serialDiffAgg.Aggregation.Aggregation.(*es.PipelineAggregation)
|
||||
So(plAgg.BucketPath, ShouldEqual, "3")
|
||||
})
|
||||
|
||||
Convey("With serial_diff doc count", func() {
|
||||
c := newFakeClient(5)
|
||||
_, err := executeTsdbQuery(c, `{
|
||||
"timeField": "@timestamp",
|
||||
"bucketAggs": [
|
||||
{ "type": "date_histogram", "field": "@timestamp", "id": "4" }
|
||||
],
|
||||
"metrics": [
|
||||
{ "id": "3", "type": "count", "field": "select field" },
|
||||
{
|
||||
"id": "2",
|
||||
"type": "serial_diff",
|
||||
"pipelineAgg": "3"
|
||||
}
|
||||
]
|
||||
}`, from, to, 15*time.Second)
|
||||
So(err, ShouldBeNil)
|
||||
sr := c.multisearchRequests[0].Requests[0]
|
||||
|
||||
firstLevel := sr.Aggs[0]
|
||||
So(firstLevel.Key, ShouldEqual, "4")
|
||||
So(firstLevel.Aggregation.Type, ShouldEqual, "date_histogram")
|
||||
|
||||
serialDiffAgg := firstLevel.Aggregation.Aggs[0]
|
||||
So(serialDiffAgg.Key, ShouldEqual, "2")
|
||||
plAgg := serialDiffAgg.Aggregation.Aggregation.(*es.PipelineAggregation)
|
||||
So(plAgg.BucketPath, ShouldEqual, "_count")
|
||||
})
|
||||
|
||||
Convey("With bucket_script", func() {
|
||||
c := newFakeClient(5)
|
||||
_, err := executeTsdbQuery(c, `{
|
||||
|
||||
Reference in New Issue
Block a user