We have received several requests to add "rate" functionality or aggregation: how many docs/s were there per bucket in a date_histogram? We have decided to implement this as a special metric aggregation with a scope limited to only date_histogram aggregation at the moment, in other words, the rate aggregation will have to be a descendant of a date_histgram and in the case of nested histograms the closest ancestor will be used to determine the rate.
POST /sales/_search
{
"aggs": {
"sales": {
"date_histogram": {
"field": "date",
"calendar_interval": "day"
},
"aggs": {
"the_rate": {
"rate": {
"unit": "second"
}
}
}
}
}
}
{
...
"aggregations": {
"sales": {
"buckets": [
{
"key_as_string": "2020-07-29",
"doc_count": 300000,
"the_rate": {
"rate": 3.47222222222,
"rate_as_string": "3.47222222222/s"
}
},
...
]
}
}
}
By default the number of documents in the bucket will be used to calculate the rate, but it will be also possible to specify a numeric field to use sum of all values of the field to calculate the rate:
"aggs": {
"the_rate": {
"rate": {
"field": "num_of_requests"
"unit": "second"
}
}
}
We could also add support for "accumulative" : true flag to address #60619 in a future iteration.
We have received several requests to add "rate" functionality or aggregation: how many docs/s were there per bucket in a date_histogram? We have decided to implement this as a special metric aggregation with a scope limited to only
date_histogramaggregation at the moment, in other words, therateaggregation will have to be a descendant of adate_histgramand in the case of nested histograms the closest ancestor will be used to determine the rate.By default the number of documents in the bucket will be used to calculate the rate, but it will be also possible to specify a numeric field to use sum of all values of the field to calculate the rate:
We could also add support for
"accumulative" : trueflag to address #60619 in a future iteration.