I have below JSON event where there are errors present in a field which is a list. I want to extract the values in the list and group them with another field which is part of an object of the same event. After grouping I want to count them like below output. I am using below query but not getting the expected output. Any help on this will be highly appreciated.
Sample JSON Event1
{
"errorList": ["There is an ErrorA", "There is some other ErrorB", "Ohh another ErrorC"],
"Details": {
"type": "ABC"
}
}
Sample JSON Event2
{
"errorList": ["There is some other ErrorB", "Ohh another ErrorC"],
"Details": {
"type": "XYZ"
}
}
Expected Output
Type Error Count
ABC There is some other ErrorB 3
ABC There is an ErrorA 4
XYZ Ohh another ErrorC 2
Query I am trying
BASE_SEARCH
| rex field=MESSAGE "(?<JSON>\{.*\})"
| spath input=JSON
| rename Details{}.type as "Type"
| rename errorList{} as "Error"
| stats count as Count by "Type" "Error"
| table Type, Error , Count
... View more