<?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: Why is my JSON regex expression not working properly? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448758#M127124</link>
    <description>&lt;P&gt;I have had success using a configuration like this for handling json: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sourcetype]
DATETIME_CONFIG =
INDEXED_EXTRACTIONS = json
KV_MODE = json
NO_BINARY_CHECK = true
category = Structured
disabled = false
TRUNCATE = 999999
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once this data is indexed you can use the &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.3/SearchReference/Mvexpand"&gt;mvexpand&lt;/A&gt; command to view all values for the testid field.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Sep 2018 12:35:08 GMT</pubDate>
    <dc:creator>tkopchak</dc:creator>
    <dc:date>2018-09-17T12:35:08Z</dc:date>
    <item>
      <title>Why is my JSON regex expression not working properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448753#M127119</link>
      <description>&lt;P&gt;I have a JSON file, which is being indexed by Splunk, the format is like -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
   testdata : [
      {
          "testid" : 1234,
          "abc" : "def",
          "def" : "abc",
          "httpServer" : [
               {
                     "responseTime" : 300,
                     "responseCode" : 200,
                     "datetime": 0982894965
               },
               {
                    "responseTime": 312,
                    "responseCode": 200,
                    "datetime": 09230948509
                }
           ],
          "transactions" : [
                 {
                   ....
                 },
                 {
                   ....
                 }
            ]
       },
       {
           "testid": 1234,
           ....
       }
   ]
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can someone please suggest a regex which can give me relevant data for every "testid". Whatever regex I tried doesn't seem to work. I was using this stanza in my props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[randomsourcetype]
[accountgroups]
TRUNCATE = 0
KV_MODE = json
NO_BINARY_CHECK = true
SHOULD_LINEMERGE = true
LINE_BREAKER = ([\r\n]*)(?=\{)
DATETIME_CONFIG = CURRENT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 04 Sep 2018 15:52:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448753#M127119</guid>
      <dc:creator>Dawson014</dc:creator>
      <dc:date>2018-09-04T15:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my JSON regex expression not working properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448754#M127120</link>
      <description>&lt;P&gt;have you try the with the default json sourcetype? Testing in local here, i can access the data:&lt;BR /&gt;
testdata.testid&lt;/P&gt;</description>
      <pubDate>Sun, 16 Sep 2018 21:37:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448754#M127120</guid>
      <dc:creator>felipesewaybric</dc:creator>
      <dc:date>2018-09-16T21:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my JSON regex expression not working properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448755#M127121</link>
      <description>&lt;P&gt;I have also had success with the json sourcetype.&lt;BR /&gt;
For more complex json hierarchies, &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;spath&lt;/A&gt; works very well.&lt;/P&gt;

&lt;P&gt;in addition to the Splunk doc link above, here is an answers refrence that may help&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/63368/how-to-handle-simple-json-array-with-spath.html"&gt;https://answers.splunk.com/answers/63368/how-to-handle-simple-json-array-with-spath.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Sep 2018 22:30:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448755#M127121</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2018-09-16T22:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my JSON regex expression not working properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448756#M127122</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults|eval _raw="{
    testdata : [
       {
           \"testid\" : 1234,
           \"abc\" : \"def\",
           \"def\" : \"abc\",
           \"httpServer\" : [
                {
                      \"responseTime\" : 300,
                      \"responseCode\" : 200,
                      \"datetime\": 0982894965
                },
                {
                     \"responseTime\": 312,
                     \"responseCode\": 200,
                     \"datetime\": 09230948509
                 }
            ],
           \"transactions\" : [
                  {
                    ....
                  },
                  {
                    ....
                  }
             ]
        },
        {
            \"testid\": 1234,
            ....
        }
    ]
 }"
 | rex max_match=0 "\s+{[\r\n]+\s+\"testid\"\s*:\s*(?&amp;lt;testid&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Sep 2018 01:40:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448756#M127122</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-09-17T01:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my JSON regex expression not working properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448757#M127123</link>
      <description>&lt;P&gt;My favorite tool for problems like this is Regex101.com&lt;BR /&gt;
At least take a look &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 02:17:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448757#M127123</guid>
      <dc:creator>Noah_Woodcock</dc:creator>
      <dc:date>2018-09-17T02:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my JSON regex expression not working properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448758#M127124</link>
      <description>&lt;P&gt;I have had success using a configuration like this for handling json: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sourcetype]
DATETIME_CONFIG =
INDEXED_EXTRACTIONS = json
KV_MODE = json
NO_BINARY_CHECK = true
category = Structured
disabled = false
TRUNCATE = 999999
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once this data is indexed you can use the &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.3/SearchReference/Mvexpand"&gt;mvexpand&lt;/A&gt; command to view all values for the testid field.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 12:35:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448758#M127124</guid>
      <dc:creator>tkopchak</dc:creator>
      <dc:date>2018-09-17T12:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my JSON regex expression not working properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448759#M127125</link>
      <description>&lt;P&gt;turns out if you remove the LINE_BREAKER = it works. Thanks for your suggestion.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 14:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448759#M127125</guid>
      <dc:creator>Dawson014</dc:creator>
      <dc:date>2018-09-26T14:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my JSON regex expression not working properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448760#M127126</link>
      <description>&lt;P&gt;For anyone having the same issue - Just done user LINE_BREAKER or leave it blank or remove it. That's how I got it to work. Thanks for the suggestions.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 14:59:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-JSON-regex-expression-not-working-properly/m-p/448760#M127126</guid>
      <dc:creator>Dawson014</dc:creator>
      <dc:date>2018-09-26T14:59:45Z</dc:date>
    </item>
  </channel>
</rss>

