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
Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

  Ready to master Kubernetes and cloud monitoring like the pros?Join Splunk’s Growth Engineering team for an ...

Wrapping Up Cybersecurity Awareness Month

October might be wrapping up, but for Splunk Education, cybersecurity awareness never goes out of season. ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

&#x1f5e3; You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...