How to calculate duration in aggregation?

Hi all,

first posts here in elasticsearch forum and new to this exciting technology.

working on a proof of concept and already loaded/indexed some data into elastic.

Data is structured like the sample bellow:

SIG201600064827 Registo do Pedido - Submetida em 2016-05-22 15:19:11.357 JANDRADE42
SIG201600064827 Registo do Pedido - Finalizada em 2016-05-22 15:19:25.220 SISTEMA
SIG201600064827 Validação do Pedido - Atribuída em 2016-05-22 15:20:00.300 JJESUS01

The challenge here is to calculate the duration of the event.

Each line of the above sample is one step, so , as we can see , the task in the sample above has been completed in 3 steps.
How can i build an aggregation and calculate the duration of the task ?

duration = time of step "Validação do Pedido - Atribuída em" - time of step "Registo do Pedido - Submetida em"

best regards

Rui Madaleno

1 Like

Are you needing to do this for many task IDs? e.g. you want to find the average/min/max duration in an index with millions of tasks?

Hi Mark, thank you for your response.

in fact the logical structure of my data is

<task id> <step name> <time of step> <user executing the step>

i need to answer questions like

"how long does it takes the task to be completed ?"

So, i really need to perform this calculation in thousands of taskid's

Toughest question to answer on an event store is something like "what is the average duration of web sessions on my website?". This looks like that sort of question.

Why it is hard and how to solve it is covered in the "entity centric indexing" talk here: https://www.youtube.com/watch?v=yBf7oeJKH2Y

It includes example scripts you can download.