<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: RegEx in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706780#M239136</link>
    <description>&lt;P&gt;Thanks this worked like a charm!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2024 20:30:29 GMT</pubDate>
    <dc:creator>CPrimoR</dc:creator>
    <dc:date>2024-12-13T20:30:29Z</dc:date>
    <item>
      <title>RegEx</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706568#M239093</link>
      <description>&lt;P&gt;I am trying to regex out eligible with the answer field true, when i do it in the regex builder this works&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;eligible\\":(?&amp;lt;eligibility_status&amp;gt;[^,]+)&lt;/LI-CODE&gt;
&lt;P&gt;but when i do it in Splunk with adding the additional backslash to escape the quotation the query runs but the field is not there.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Name":null,"Id":null,"WaypointId":null}},"Body":{"APIServiceCall":{"ResponseStatusCode":"200","ResponsePayload":"{\"eligibilityIndicator\":[{\"service\":\"Mobile\",\"eligible\":true,\"successReasonCodes\":[],\"failureReasonCodes\":[]}]}"}}}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 11 Dec 2024 19:58:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706568#M239093</guid>
      <dc:creator>CPrimoR</dc:creator>
      <dc:date>2024-12-11T19:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706571#M239094</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;have you check that your raw event is what you are thinking? As it seems to be a JSON, it probably contains some other characters what you aren’t expecting!&lt;/P&gt;&lt;P&gt;Open event and select from event action “show source”. From there you see what event contains and then you can modify your rex to match it.&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 19:04:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706571#M239094</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-12-11T19:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706584#M239097</link>
      <description>&lt;P&gt;What exactly do you mean by "when I do it in Splunk"?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 20:55:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706584#M239097</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-12-11T20:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706586#M239098</link>
      <description>&lt;P&gt;When rex'ing backslashes, you need to quadruple them&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "eligible\\\\\":(?&amp;lt;eligibility_status&amp;gt;[^,]+)"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 11 Dec 2024 21:01:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706586#M239098</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-12-11T21:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706615#M239114</link>
      <description>&lt;P&gt;Another important point: Your raw data is in JSON. &amp;nbsp;Do not treat structured data as plain strings. &amp;nbsp;In other words, instead of using regex, use proper JSON tools Splunk has.&lt;/P&gt;&lt;P&gt;When showing structured data, it is important to post a compliant structure. Let me reconstruct a compliant JSON out of the illustrated fragment before giving your a shortcut.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"isthiscorrect": {"somekey": {"Name":null,"Id":null,"WaypointId":null}},"Body":{"APIServiceCall":{"ResponseStatusCode":"200","ResponsePayload":"{\"eligibilityIndicator\":[{\"service\":\"Mobile\",\"eligible\":true,\"successReasonCodes\":[],\"failureReasonCodes\":[]}]}"}}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;If your raw events resemble the above in structure, Splunk would have given you a field named&amp;nbsp;Body.APIServiceCall.ResponsePayload. &amp;nbsp;Your illustrated fragment contains this value for that field:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"eligibilityIndicator":[{"service":"Mobile","eligible":true,"successReasonCodes":[],"failureReasonCodes":[]}]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;All you need to do is to use an appropriate tool extract from this. &amp;nbsp;But before you do, note that eligibilityIndicator is an array. &amp;nbsp;You most likely want to split the array into their own events.&lt;/P&gt;&lt;P data-unlink="true"&gt;Putting this chain together:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath input=Body.APIServiceCall.ResponsePayload path=eligibilityIndicator{}
| mvexpand eligibilityIndicator{}
| spath input=eligibilityIndicator{}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;The field you are trying to extract is now called &lt;U&gt;eligible&lt;/U&gt;.&lt;/P&gt;&lt;P data-unlink="true"&gt;Here is an emulation with your fragment as reconstructed above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "{\"isthiscorrect\": {\"somekey\": {\"Name\":null,\"Id\":null,\"WaypointId\":null}},\"Body\":{\"APIServiceCall\":{\"ResponseStatusCode\":\"200\",\"ResponsePayload\":\"{\\\"eligibilityIndicator\\\":[{\\\"service\\\":\\\"Mobile\\\",\\\"eligible\\\":true,\\\"successReasonCodes\\\":[],\\\"failureReasonCodes\\\":[]}]}\"}}}"
| spath
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are the three fields extracted from&amp;nbsp;eligibilityIndicator{}&lt;/P&gt;&lt;TABLE width="146px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;eligible&lt;/TD&gt;&lt;TD&gt;service&lt;/TD&gt;&lt;TD&gt;successReasonCodes{}&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="45.0625px"&gt;true&lt;/TD&gt;&lt;TD width="59.953125px"&gt;Mobile&lt;/TD&gt;&lt;TD width="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 12 Dec 2024 06:17:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706615#M239114</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-12-12T06:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706621#M239117</link>
      <description>&lt;P&gt;While I wholeheartedly agree about the "don't fiddle with structured data using regexes" point, it's worth noting that spath is not feasible for search-time extractions on which you'd want to base your searches because spath has to parse whole event (or a whole given field) as json event and has no notion about fields before that so you don't have any condition like "spath(whatever)=some_value". In other words, while for "first-order" jsons you can do the normal initial search filtering based on field=value conditions, it won't work with more deeply embedded json structures (regardless of whether they are included as strings within an "outer" json or if they are simply a part of a syslog-headered event).&lt;/P&gt;&lt;P&gt;Splunk still has to process all events from the preceeding pipeline, push them through spath and only then you can filter the data further.&lt;/P&gt;&lt;P&gt;One possible way around it is to limit your processed data by limiting your data in the initial search by searching for the literal value term. It will not help much with fields of low cardinality and terms common across many fields (like in this case - true/false is not a very well-limiting search term) but in other cases when you're searching for a fairly unique term it can mean loads of speedup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2024 08:09:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706621#M239117</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-12-12T08:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706780#M239136</link>
      <description>&lt;P&gt;Thanks this worked like a charm!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 20:30:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx/m-p/706780#M239136</guid>
      <dc:creator>CPrimoR</dc:creator>
      <dc:date>2024-12-13T20:30:29Z</dc:date>
    </item>
  </channel>
</rss>

