Splunk Search

Can someone help me extract a string from a raw XML log?

KowsiSakthi
Engager

How do I use an eval field in a search command?

Hi
I have a Raw log with XML content in it.
ex:

2018-06-19 15:35:57,320 INFO  PAYLOAD - esb_event_time=2018-06-19 15:35:55.964|esb_environment=Dev2|esb_domain=esb-domain|esb_txn=****************|esb_service=student-sda-api|esb_token=null|esb_consumer=null|esb_digest=null|esb_nonce=null|esb_guid=null|esb_correlation_id=null|esb_conversation_id=null|esb_user_ref=null|esb_effective_user=null|esb_sender_machine=null|esb_uri_params=ParameterMap{[]}|esb_query_params=ParameterMap{[]}|esb_http_request_ui=/api/student-api/v1/retrievePPSDetails|esb_content_length=296|esb_host=localhost:8000|esb_user_agent=Apache-HttpClient/4.1.1 (java 1.5)|Accept=null|content-type=application/xml|esb_query_string=|esb_http_version=HTTP/1.1|esb__timestamp=null|esb_connection=Keep-Alive|esb_http_method=POST|esb_http.scheme=http|esb_http_request_path=/retrievestudentDetails|esb_http_listener_path=/api/*|esb_rte_tag=null|esb_operation=retrievestudentDetails|esb_event=esbMsgIn|esb_error_cd=|esb_msg_size=296|esb_time=0|esb_backend_time=0|esb_routing=null|

      <name></name>
      <age>26</age>
      <PIN>100100100</PIN>
      </Identification>

Here, I am extracting the XML content and trying to search for a particular string in XML

ex: "100100100"

This search string will be entered dynamically in a text box. Can someone guide me how to search the above string in XML and return the matching XML

I tried to use the below command...

|index=_raw| eval searchString="$textInput$"|eval xml=mvindex(split(_raw,"|"),1)|search  searchString|table xml

...but it returns with no results found. But, if I directly search the string, say for ex: search "100100100", it is returning the corresponding XML. Kindly help me to resolve this issue.

Thanks
Sakthi
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

index=_raw 
|eval xml=mvindex(split(_raw,"|"),1)\
|search xml="*$textInput$*"
|table xml

OR

index=_raw 
|eval xml=mvindex(split(_raw,"|"),1)\
| where match(xml,"$textInput$")
|table xml

View solution in original post

somesoni2
Revered Legend

Give this a try

index=_raw 
|eval xml=mvindex(split(_raw,"|"),1)\
|search xml="*$textInput$*"
|table xml

OR

index=_raw 
|eval xml=mvindex(split(_raw,"|"),1)\
| where match(xml,"$textInput$")
|table xml

KowsiSakthi
Engager

Hi somesoni2,
It worked!!!. Thanks a lot

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...