<?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 How to regex over nested jsons with foreach and rex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-over-nested-jsons-with-foreach-and-rex/m-p/495971#M138247</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;Currently I have a log record in the form of nested jsons, not arrays of jsons:&lt;/P&gt;

&lt;P&gt;{"root_key": {"subkey_0": {nested json string}, ... , "subkey_N": {nested json string}}}&lt;/P&gt;

&lt;P&gt;I want to extract some fields with &lt;STRONG&gt;rex&lt;/STRONG&gt; from each &lt;STRONG&gt;subkey&lt;/STRONG&gt; json string.&lt;BR /&gt;
Is it possible somehow to accomplish this by &lt;STRONG&gt;foreach&lt;/STRONG&gt; and &lt;STRONG&gt;rex&lt;/STRONG&gt;?&lt;/P&gt;

&lt;P&gt;Something like this pseudocode:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foreach subkey:
    (field_value_0, ... field_value_M) &amp;lt;--- rex(subkey json string)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The goal is to build the following list:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[
    [field_value_0, ... field_value_M],
    ...
    [field_value_0, ... field_value_M]
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And to display it with &lt;STRONG&gt;table&lt;/STRONG&gt; command.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 03:55:11 GMT</pubDate>
    <dc:creator>neuromantik</dc:creator>
    <dc:date>2020-09-30T03:55:11Z</dc:date>
    <item>
      <title>How to regex over nested jsons with foreach and rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-over-nested-jsons-with-foreach-and-rex/m-p/495971#M138247</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;Currently I have a log record in the form of nested jsons, not arrays of jsons:&lt;/P&gt;

&lt;P&gt;{"root_key": {"subkey_0": {nested json string}, ... , "subkey_N": {nested json string}}}&lt;/P&gt;

&lt;P&gt;I want to extract some fields with &lt;STRONG&gt;rex&lt;/STRONG&gt; from each &lt;STRONG&gt;subkey&lt;/STRONG&gt; json string.&lt;BR /&gt;
Is it possible somehow to accomplish this by &lt;STRONG&gt;foreach&lt;/STRONG&gt; and &lt;STRONG&gt;rex&lt;/STRONG&gt;?&lt;/P&gt;

&lt;P&gt;Something like this pseudocode:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foreach subkey:
    (field_value_0, ... field_value_M) &amp;lt;--- rex(subkey json string)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The goal is to build the following list:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[
    [field_value_0, ... field_value_M],
    ...
    [field_value_0, ... field_value_M]
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And to display it with &lt;STRONG&gt;table&lt;/STRONG&gt; command.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:55:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-over-nested-jsons-with-foreach-and-rex/m-p/495971#M138247</guid>
      <dc:creator>neuromantik</dc:creator>
      <dc:date>2020-09-30T03:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to regex over nested jsons with foreach and rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-regex-over-nested-jsons-with-foreach-and-rex/m-p/495972#M138248</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"root_key\": {\"subkey_0\": {a},\"subkey_1\": {b} , \"subkey_N\": {c}}}" 
| rex ":(?&amp;lt;json&amp;gt;.+)}$"
| rex field=json max_match=1000 ": \{(?&amp;lt;field_value&amp;gt;.+?)\}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;limits: 1000 objects. if you want more, change &lt;CODE&gt;max_match&lt;/CODE&gt; args.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jan 2020 23:21:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-regex-over-nested-jsons-with-foreach-and-rex/m-p/495972#M138248</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-25T23:21:17Z</dc:date>
    </item>
  </channel>
</rss>

