Splunk Search

How do I get a value from a field as described in the following example?

vaibhavvijay9
New Member
some normal text.......and in between 

    <ns0:ExceptionLog_Action>

        <ns0:Exception>

         <ns0:Code>111</ns0:Code>

         <ns0:Reason>ErrorCode: Life-003&#xD;Reason: Mapping error in Web Service &#xD;Stacktrace...(other sub-fields)</ns0:Reason>


        </ns0:Exception>

    </ns0:ExceptionLog_Action>

I want the value of Reason: inside <ns0:Reason> before &#xD; that is : Mapping error in Web Service

Please help me to do so.

Thanks In Advance

Vaibhav Vijay

Tags (1)
0 Karma
1 Solution

whrg
Motivator

Hello Vaibhav,

I can see that "Mapping error in Web Service" is prefixed by "Reason:"

With that in mind, check out this regex:

Reason: (?<Reason>[^&]+) &#xD

This is how you can verify:

| makeresults count=1
| eval _raw="some normal text.......and in between <ns0:ExceptionLog_Action> <ns0:Exception> <ns0:Code>111</ns0:Code> <ns0:Reason>ErrorCode: Life-003&#xD;Reason: Mapping error in Web Service &#xD;Stacktrace...(other sub-fields)</ns0:Reason> </ns0:Exception> </ns0:ExceptionLog_Action>"
| rex field=_raw "Reason: (?<Reason>[^&]+) &#xD"

View solution in original post

0 Karma

whrg
Motivator

Hello Vaibhav,

I can see that "Mapping error in Web Service" is prefixed by "Reason:"

With that in mind, check out this regex:

Reason: (?<Reason>[^&]+) &#xD

This is how you can verify:

| makeresults count=1
| eval _raw="some normal text.......and in between <ns0:ExceptionLog_Action> <ns0:Exception> <ns0:Code>111</ns0:Code> <ns0:Reason>ErrorCode: Life-003&#xD;Reason: Mapping error in Web Service &#xD;Stacktrace...(other sub-fields)</ns0:Reason> </ns0:Exception> </ns0:ExceptionLog_Action>"
| rex field=_raw "Reason: (?<Reason>[^&]+) &#xD"
0 Karma

vaibhavvijay9
New Member

Thanks a lot Whrg!!

I am really grateful for your help, it has been incredibly helpful to me.

Regards,
Vaibhav Vijay

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...