susmeeta
(Susmeeta Patra)
September 28, 2021, 1:52pm
1
Hi ,
We have a scenario where each case is processed multiple times. I am trying to fetch the unique count of cases along with the latest status of each case. To get this i have used Top Hit aggregation to get the latest status, and using Unique Count to fetch the unique number of records.
Scenario:
Case1 BE 10:00 AM
Case2 TE 10:02 AM
Case2 Success 10:20 AM
Case 3 Success 10:35 AM
Case1 TE 11:00 AM
Expected Result :
TE 1
Success 2
Actual Result :
TE 3
Please suggest how to get the expected result.
Thanks,
Susmeeta.
Hi @susmeeta ,
welcome to the Kibana community.
May I ask some more details of the configuration you've used for your visualization/result?
(Also, which version of the stack/Kibana are you using?)
susmeeta
(Susmeeta Patra)
September 29, 2021, 12:54pm
3
Hi @Marco_Liberati , thank you for your response.
I am using Kibana version: 7.9.1.
Attached is the request configuration for this Data Table .Processing: request_dataTable.txt...
{
"aggs": {
"2": {
"terms": {
"field": "processIdentifier.keyword",
"order": {
"1": "desc"
},
"size": 5000
},
"aggs": {
"1": {
"cardinality": {
"field": "uniqueIdentifier.keyword"
}
},
"5": {
"cardinality": {
"script": {
"source": "if (doc['BotId.keyword'].size()!=0){ if (doc['processStage.keyword'].value=='Worker') \r\n{return (doc['BotId.keyword'].value)+(doc['processStage.keyword'].value);}}\r\n",
"lang": "painless"
}
}
},
"6": {
"top_hits": {
"docvalue_fields": [
{
"field": "message.keyword"
}
],
"_source": "message.keyword",
"size": 1,
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
}
}
}
},
"size": 0,
"stored_fields": [
"*"
],
"script_fields": {
"UC02_Status": {
"script": {
"source": "if (doc['archetype.keyword'].size()!=0){ if (doc['message.keyword'].size()!=0) {if(doc['message.keyword'].value=='Success'){ return \"Successful\";}\r\n\telse if (doc['message.keyword'].value=='Technical Exception') {return \"Marked as complex\";}\r\n\telse if (doc['message.keyword'].value=='Business Exception') {return \"Marked as complex\";}}}",
"lang": "painless"
}
},
"Processing Time": {
"script": {
"source": "if (doc['BotId.keyword'].size()!=0){ if (doc['processStage.keyword'].value=='Worker') \r\n{return (doc['BotId.keyword'].value)+(doc['processStage.keyword'].value);}}\r\n",
"lang": "painless"
}
},
"Proc_time": {
"script": {
"source": "if (doc['message.keyword'].size()!=0) { if (doc['archetype.keyword'].size()!=0) { if (doc['archetype.keyword'].value=='Vod-W-03-1')\n{return Double.parseDouble(doc['message.keyword'].value)/60;}}}",
"lang": "painless"
}
}
},
"docvalue_fields": [
{
"field": "@timestamp",
"format": "date_time"
},
{
"field": "endTime",
"format": "date_time"
},
{
"field": "startTime",
"format": "date_time"
},
{
"field": "timeStamp",
"format": "date_time"
}
],
"_source": {
"excludes": []
},
"query": {
"bool": {
"must": [],
"filter": [
{
"match_all": {}
},
{
"match_phrase": {
"projectName.keyword": "DE_HC"
}
},
{
"match_phrase": {
"archetype.keyword": "Vod-W-00"
}
},
{
"range": {
"@timestamp": {
"gte": "2021-07-01T12:50:09.486Z",
"lte": "2021-09-29T12:50:09.486Z",
"format": "strict_date_optional_time"
}
}
}
],
"should": [],
"must_not": [
{
"match_phrase": {
"message.keyword": "Pending Retry"
}
}
]
}
}
}
system
(system)
Closed
October 27, 2021, 12:54pm
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.