<?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: Field extraction using rex command - dynamic regex with lookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489223#M136670</link>
    <description>&lt;P&gt;I finally came to a workable solution using map&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup my_fields_xml.csv 
| stats list(FieldName) as FieldName delim="|" 
| nomv FieldName 
|  eval KeyRegex = "\"(?&amp;lt;FieldName&amp;gt;(" + FieldName + "))\":(?!\s*{\[)\"*(?&amp;lt;Value&amp;gt;(?!\[+{|{+|null)[^(,|}|\")]*)" 
| fields KeyRegex 
| map search="search index=index1
  | rex field=_raw max_match=0 $KeyRegex$....."
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 Mar 2020 22:51:21 GMT</pubDate>
    <dc:creator>arpitpropay</dc:creator>
    <dc:date>2020-03-09T22:51:21Z</dc:date>
    <item>
      <title>Field extraction using rex command - dynamic regex with lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489218#M136665</link>
      <description>&lt;P&gt;I am trying to extract key value pairs from JSON events using rex command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | rex field=_raw max_match=0 "\"(?&amp;lt;Key&amp;gt;\b\w+[^\":]*)\":(?!\s*{\[)\"*(?&amp;lt;Value&amp;gt;(?!\[{|{|\[)[^(,|}|\")]*)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have a single column CSV lookup with all the key names I am interested in&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup my_fields_json.csv | fields FieldName 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to use the lookup to make my rex command regular expression dynamic so I only extract the fields I am interested in?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 16:03:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489218#M136665</guid>
      <dc:creator>arpitpropay</dc:creator>
      <dc:date>2020-03-09T16:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction using rex command - dynamic regex with lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489219#M136666</link>
      <description>&lt;P&gt;Why do you need to rex a JSON?  Splunk should be parsing those for you.  Maybe this will help:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/556279/why-would-indexed-extractionsjson-in-propsconf-be.html"&gt;https://answers.splunk.com/answers/556279/why-would-indexed-extractionsjson-in-propsconf-be.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 16:37:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489219#M136666</guid>
      <dc:creator>xavierashe</dc:creator>
      <dc:date>2020-03-09T16:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction using rex command - dynamic regex with lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489220#M136667</link>
      <description>&lt;P&gt;If field are not extracted from json events then you can use spath command to extract field value pairs. Then you can filter fields.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index | spath | fields foo, bar
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you filter fields from csv lookup only then,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index | spath | fields [| inputlookup my_fields_json.csv | fields FieldName | mvcombine delim="," FieldName | nomv FieldName | return $FieldName]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 17:23:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489220#M136667</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-09T17:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction using rex command - dynamic regex with lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489221#M136668</link>
      <description>&lt;P&gt;The reason I am trying to parse JSON using regex is that I have nested JSON objects with dynamic structure. I would like to be able to find all key value pairs in the events regardless of their depth in the raw JSON. Splunk is parsing those objects but as I said they have dynamic structure and do not have a consistent object hierarchy &lt;/P&gt;

&lt;P&gt;For example &lt;BR /&gt;
Parent{}.Customer.RelationshipId&lt;BR /&gt;
Parent{}.RelationshipId&lt;BR /&gt;
Parent{}.Order.Customer.RelationshipId and so on. &lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 17:41:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489221#M136668</guid>
      <dc:creator>arpitpropay</dc:creator>
      <dc:date>2020-03-09T17:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction using rex command - dynamic regex with lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489222#M136669</link>
      <description>&lt;P&gt;I am working with events having nested JSON. Splunk extracts top level JSON but there's an array  with nested objects. It does not have consistent structure inside it and inside it Splunk does not extract the fields very well (it does but they appear like Parameters{}.Customer.CustomerId. Not all events have some structure of customerId. So I am trying to extract it using regex)&lt;/P&gt;

&lt;P&gt;{&lt;BR /&gt;
    "TimeStamp": "2020-03-09 12:01:39.451",&lt;BR /&gt;
    "Type": "Info",&lt;BR /&gt;
    "Message": "Some message",&lt;BR /&gt;
    "Host": "SERVER01", ,&lt;BR /&gt;
    "Parameters": [{&lt;BR /&gt;
            "Customer": {&lt;BR /&gt;
                "CusmerId": "888000000587",&lt;BR /&gt;
                "Name": "&lt;A href="mailto:sales@abc.com"&gt;sales@abc.com&lt;/A&gt;",&lt;BR /&gt;
            }&lt;BR /&gt;
        }, false]&lt;BR /&gt;
  } &lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 22:09:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489222#M136669</guid>
      <dc:creator>arpitpropay</dc:creator>
      <dc:date>2020-03-09T22:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction using rex command - dynamic regex with lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489223#M136670</link>
      <description>&lt;P&gt;I finally came to a workable solution using map&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup my_fields_xml.csv 
| stats list(FieldName) as FieldName delim="|" 
| nomv FieldName 
|  eval KeyRegex = "\"(?&amp;lt;FieldName&amp;gt;(" + FieldName + "))\":(?!\s*{\[)\"*(?&amp;lt;Value&amp;gt;(?!\[+{|{+|null)[^(,|}|\")]*)" 
| fields KeyRegex 
| map search="search index=index1
  | rex field=_raw max_match=0 $KeyRegex$....."
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 22:51:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-using-rex-command-dynamic-regex-with-lookup/m-p/489223#M136670</guid>
      <dc:creator>arpitpropay</dc:creator>
      <dc:date>2020-03-09T22:51:21Z</dc:date>
    </item>
  </channel>
</rss>

