I have the following query where to get data, and I create an aggregation of each hour:
query = {
"query": {
"bool": {
"must": [
{ "term": {"deviceId":device} },
{ "match": {"eventType":"Connected"} }
],
"must_not":[{
"query_string": {
"query": "Pong",
"fields": ["data.message"]
}
},
]
},
},
"size": 0,
"sort": [{ "timestamp": { "order": "desc" }}],
"aggs" : {
"time_buckets" : {
"date_histogram" : {
"field" : "timestamp",
"interval" : "hour",
},
}
}
}
I would like to get the average field value from each hour interval (each bucket created by aggregation). In this article, they talk about something similar to what I want to do:
http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_looking_at_time.html
("What is the average latency of our site every hour for the last week?" ). However, they do not explain exactly what to do in this case.
Does anyone know how to do this?
source
share