Sorry for the delay. Consider the following:
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:01:00",
"value_a": 10
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:02:00",
"value_a": 10
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:03:00",
"value_a": 10
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:04:00",
"value_a": 10
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:05:00",
"value_a": 10
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:06:00",
"value_a": 10
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:07:00",
"value_a": 10
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:08:00",
"value_a": 11
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:09:00",
"value_a": 12
}
POST /my-index-000001/_doc/?pretty
{
"@timestamp": "2023-09-14T11:10:00",
"value_a": 13
}
You could look at the first five minutes with something like this:
GET /my-index-000001/_search
{
"size":0,
"aggs": {
"average": {
"avg": {
"field": "value_a"
}
},
"max_value": {
"max": {
"field": "value_a"
}
}
},
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "2023-09-14T11:01:00",
"lte": "2023-09-14T11:05:00"
}
}
}
]
}
}
}
Which has the output of:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 5,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"average": {
"value": 10
},
"max_value": {
"value": 10
}
}
}
As you can see the average and max value are the same value so there has been no increase.
Switching up the five minute window to the last five minutes with:
GET /my-index-000001/_search
{
"size":0,
"aggs": {
"average": {
"avg": {
"field": "value_a"
}
},
"max_value": {
"max": {
"field": "value_a"
}
}
},
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "2023-09-14T11:06:00",
"lte": "2023-09-14T11:10:00"
}
}
}
]
}
}
}
Gives us:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 5,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"average": {
"value": 11.2
},
"max_value": {
"value": 13
}
}
}
The max value is greater than the average so you know that the value is increasing.
Hope this helps.