Hi,
IN A FEW WORDS:
I would like to display on a Kibana dashboard some duration calculated from my logs with the help of Elasticsearch aggregation.
PRECISELY:
I have some logs like this (simplified):
timestamp = 10, id = 1, logtype = Start
timestamp = 12, id = 1, logtype = Stop
timestamp = 11, id = 1, logtype = Start
timestamp = 13, id = 1, logtype = Stop
timestamp = 10, id = 2, logtype = Start
timestamp = 11, id = 2, logtype = Stop
I would like to group them by id then logtype and finally sum the timestamp.
This part is done, I managed to aggregate all of that with the Kibana dev tools console, the result looks like this (simplified):
"buckets" : [
"id": 1,
"start": {
"doc_count":2,
"sum_timestamp":21
},
"stop": {
"doc_count":2,
"sum_timestamp":25
},
"id": 2,
"start": {
"doc_count":1,
"sum_timestamp":10
},
"stop": {
"doc_count":1,
"sum_timestamp":11
}
]
Now the real deal, I have two more things to do:
- Substract the "sum_timestamp"s of the logtypes "stop" and "start" in order to get a duration
- Display the whole aggregation into Kibana (not a time series, something like a statistical distribution for each duration)
And this is where I need your help.
I have no idea how to substract some previous aggregations, and more importantly, how to display the result into a Kibana dashboard.
Maybe I see the problem from a wrong point of view and it's absolutely not possible? Anyway, I am open to all suggestions