Splunk Search

Search xml data

Harshi1993
New Member

I have logs in the format of json where message is the key and message contains the value mentioned below

 

message: 

<ErrorMessage>E-delivery failed<ErrorMessage>

When i am searching like below in the splunk, able to search the events

index="*" source="*" "E-delivery failed"

If i want to display the count of E-delivery failed string, the results are not fetching as the value under message tag is xml.

Query used is:

index="*" source="*"
| eval type=case(like(message, "%E-delivery failed%"),"e delivery failed")|stats count as Results by type

With the above query not able to get any results. Please help me with the query.

 

Result should be:

type                                  count

e delivery failed             10

 

Labels (1)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Has the message field already been extracted, e.g. does this produce the expected results

index="*" source="*" | stats count by message

If not, either extract the field with spath for example, or use _raw in the like function

index="*" source="*"
| eval type=case(like(_raw, "%E-delivery failed%"),"e delivery failed")|stats count as Results by type
0 Karma

Harshi1993
New Member

Can't we use message field directly in the case statement. Do we need to use the _raw field in the case statement?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Yes, you can if it has been extracted. I gave an example for the situation where it hadn't been extracted.

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...