Table visualisation on last occurrence of specific field

Hi Everybody,

I'm collecting data from an application that runs "jobs" on different users. The same jobs can be executed multiple times for the same user and I'm struggling to find a way to create a table visualisation that reports some stats taking care only of the last job execution for user.

here an example of the source data:
jobId,user,jobname,jobresult,jobstatus,timestamp
1,userA,BulkJob,IOException,ERROR,20200517120000
2,userA,FinalJob,Success,OK,20200517123000
1,userA,BulkJob,Success,OK,20200517123500
3,userB,BulkJob,IOException,ERROR,20200517124000
3,userB,BulkJob,TimeoutException,ERROR,20200517124500

What I'm trying to generate is a table that reports the success Failures of each jobname based only on the last execution of jobid. This means that only the bold raw should be reported.
Expected result:
Jobname | SUCCESS | ERROR
BulkJob. | 1. | 1
FinalJob. |. 1. |. 0

To count the SUCCESS and ERROR I used two "SUM" metrics with a JSON.input like this:
{
"script": {
"inline": "doc['''jobStatus.keyword'''].value == '''OK''' ? 1 : 0",
"lang": "painless"
}
}
and
{
"script": {
"inline": "doc['''jobStatus.keyword'''].value == '''ERROR''' ? 1 : 0",
"lang": "painless"
}
}

and then a buckets "terms" aggregation on the filed jobName.
But it's obviously counting all the occurrence not jus the last one...
Any ideas?
Thanks in advance.

Max

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.