I'm trying to use transactions to generate a timeline of events where the events are grouped by an eventId
I'm recieving up to 2 events as a START and a STOP event, and have to calculate the duration between them based on actualTime.
{
"action" : "START",
"source" : "AS_PLANNED",
"timestamp" : "2017-07-12T10:07:14.682+02:00",
"eventId" : "1366963140327",
"title" : "sadfasdfasdf",
"flowPublicationId" : "1366963137812",
"timeAllocationType" : "Segment of program",
"actualTime" : "2017-07-12T10:07:14.760+02:00",
"startTimeAnnounced" : "2017-07-12T10:05:00.000+02:00",
"startTimePlanned" : "2017-07-12T10:07:14.760+02:00",
"stopTimePlanned" : "2017-07-12T10:12:50.360+02:00",
"broadcastDate" : [ 2017, 7, 12 ],
"live" : false,
"quickReprise" : false,
"streamingLive" : false,
"streamingOD" : false,
"numberOfBlocks" : "1",
"blockPartNumber" : "1",
"blockId" : "1366963138813"
}
{
"action" : "STOP",
"source" : "AS_PLANNED",
"timestamp" : "2017-07-12T10:12:50.310+02:00",
"eventId" : "1366963140327",
"title" : "yyyyyy",
"flowPublicationId" : "1366963137812",
"timeAllocationType" : "Segment of program",
"actualTime" : "2017-07-12T10:12:50.360+02:00",
"startTimeAnnounced" : "2017-07-12T10:05:00.000+02:00",
"startTimePlanned" : "2017-07-12T10:07:14.760+02:00",
"stopTimePlanned" : "2017-07-12T10:12:50.360+02:00",
"broadcastDate" : [ 2017, 7, 12 ],
"live" : false,
"quickReprise" : false,
"streamingLive" : false,
"streamingOD" : false,
"numberOfBlocks" : "1",
"blockPartNumber" : "1",
"blockId" : "1366963138813"
}
The query I'm using ->
index="morpheus"
| transaction eventId
| eval start=if(action=="START",actualTime,startTimePlanned)
| eval stop=if(action=="STOP",actualTime,stopTimePlanned)
| eval duration=(strptime(stop,"%Y-%m-%dT%H:%M:%S,%3N") - strptime(start,"%Y-%m-%dT%H:%M:%S,%3N"))
| table actualTime, action, title, start, stop, duration
But it seems that I'm not getting the duration correctly calculated.
... View more