<?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: Need help in regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341788#M170183</link>
    <description>&lt;P&gt;This is not displaying what i want. if you look into the age the key is empty for the first column and because of that the value of is showing incorrect&lt;BR /&gt;
For example &lt;BR /&gt;
{\"age\":\"\",\"count\":19953}&lt;BR /&gt;
{\"age\":\"18 - 24\",\"count\":30289}&lt;/P&gt;

&lt;P&gt;but when i am running the command &lt;BR /&gt;
18-24 is displaying 19953 &lt;/P&gt;

&lt;P&gt;Secondly i want to run the job like below because every time the job will run&lt;/P&gt;

&lt;P&gt;index=orion-platform sourcetype=palomar-metrics source="experianCounters.json"   | spath&lt;BR /&gt;
 | rename counterList{}.counterValue{}.age as age, counterList{}.counterValue{}.count as count, counterList{}.counterName as counterName, counterList{}.counterValue{}.distinctSubCount as distinctSubCount, counterList{}.counterValue{}.gender as gender, counterList{}.counterValue{}.income as income, counterList{}.counterValue{}.subscriberCount as subscriberCount&lt;BR /&gt;
 | eval index=mvrange(0,mvcount(count))| mvexpand index| eval age=mvindex(age,index), count=mvindex(count,index), gender=mvindex(gender,index), income=mvindex(income,index), subscriberCount=mvindex(subscriberCount,index)&lt;BR /&gt;
 | table age count gender income subscriberCount&lt;/P&gt;</description>
    <pubDate>Sat, 21 Apr 2018 05:03:24 GMT</pubDate>
    <dc:creator>pswalia06</dc:creator>
    <dc:date>2018-04-21T05:03:24Z</dc:date>
    <item>
      <title>Need help in regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341784#M170179</link>
      <description>&lt;P&gt;{"runDate":"2018-04-18T00:31:46 EDT","dataDate":"20180319","jobName":"experianCounters","counterList":[{"counterName":"experian.input.recordCount","counterValue":[{"subscriberCount":1000100,"distinctSubCount":1000100}]},{"counterName":"experian.output.recordCount","counterValue":[{"subscriberCount":1000100,"distinctSubCount":1000100}]},{"counterName":"experian.output.subscriberCountByAge","counterValue":[{"age":"","count":19953},{"age":"18 - 24","count":30289},{"age":"25 - 34","count":149793},{"age":"35 - 44","count":349856},{"age":"45 - 54","count":250509},{"age":"55 - 64","count":149719},{"age":"65 - 74","count":30008},{"age":"75+","count":19973}]},{"counterName":"experian.output.subscriberCountByGender","counterValue":[{"gender":"","count":79725},{"gender":"B","count":49954},{"gender":"F","count":419773},{"gender":"M","count":450648}]},{"counterName":"experian.output.subscriberCountByIncome","counterValue":[{"income":"","count":19813},{"income":"$1,000 - $14,999","count":39982},{"income":"$100,000 - $124,999","count":100406},{"income":"$125,000 - $149,999","count":29909},{"income":"$15,000 - $24,999","count":60021},{"income":"$150,000 - $174,999","count":20067},{"income":"$175,000 - $199,999","count":79649},{"income":"$200,000 - $249,999","count":20042},{"income":"$25,000 - $34,999","count":80456},{"income":"$35,000 - $49,999","count":99999},{"income":"$50,000 - $74,999","count":249983},{"income":"$75,000 - $99,999","count":199773}]}],"projectName":"RND","releaseVersion":"1.4.0.RNN"}&lt;/P&gt;

&lt;P&gt;I want to find the value of age with there corresponding value ? Can you one help me ?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 05:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341784#M170179</guid>
      <dc:creator>pswalia06</dc:creator>
      <dc:date>2018-04-19T05:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341785#M170180</link>
      <description>&lt;P&gt;This seems like a valid JSON contruct, so you can use spath command to extract your fields&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| spath 
| table counterList{}.counterValue{}.age counterList{}.counterValue{}.count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since there are multiple values, you'll get multivalued field for both age and count. You can expand it to single row like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| spath 
| table counterList{}.counterValue{}.age counterList{}.counterValue{}.count | rename counterList{}.counterValue{}.* as *
| eval temp=mvzip(age,count,"##")
| mvexpand temp | rex field=temp "(?&amp;lt;age&amp;gt;[^#]+)##(?&amp;lt;count&amp;gt;.+)" | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2018 16:40:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341785#M170180</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-04-19T16:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341786#M170181</link>
      <description>&lt;P&gt;At search time, try &lt;CODE&gt;... | rex max_match=0 "\"age\":\"(?&amp;lt;age&amp;gt;[^\"]+)" | ...&lt;/CODE&gt;.  You may have to experiment with the number of escape characters.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 16:44:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341786#M170181</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-04-19T16:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341787#M170182</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;If you try this, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | makeresults
 | eval _raw="{\"runDate\":\"2018-04-18T00:31:46 EDT\",\"dataDate\":\"20180319\",\"jobName\":\"experianCounters\",\"counterList\":[{\"counterName\":\"experian.input.recordCount\",\"counterValue\":[{\"subscriberCount\":1000100,\"distinctSubCount\":1000100}]},{\"counterName\":\"experian.output.recordCount\",\"counterValue\":[{\"subscriberCount\":1000100,\"distinctSubCount\":1000100}]},{\"counterName\":\"experian.output.subscriberCountByAge\",\"counterValue\":[{\"age\":\"\",\"count\":19953},{\"age\":\"18 - 24\",\"count\":30289},{\"age\":\"25 - 34\",\"count\":149793},{\"age\":\"35 - 44\",\"count\":349856},{\"age\":\"45 - 54\",\"count\":250509},{\"age\":\"55 - 64\",\"count\":149719},{\"age\":\"65 - 74\",\"count\":30008},{\"age\":\"75+\",\"count\":19973}]},{\"counterName\":\"experian.output.subscriberCountByGender\",\"counterValue\":[{\"gender\":\"\",\"count\":79725},{\"gender\":\"B\",\"count\":49954},{\"gender\":\"F\",\"count\":419773},{\"gender\":\"M\",\"count\":450648}]},{\"counterName\":\"experian.output.subscriberCountByIncome\",\"counterValue\":[{\"income\":\"\",\"count\":19813},{\"income\":\"$1,000 - $14,999\",\"count\":39982},{\"income\":\"$100,000 - $124,999\",\"count\":100406},{\"income\":\"$125,000 - $149,999\",\"count\":29909},{\"income\":\"$15,000 - $24,999\",\"count\":60021},{\"income\":\"$150,000 - $174,999\",\"count\":20067},{\"income\":\"$175,000 - $199,999\",\"count\":79649},{\"income\":\"$200,000 - $249,999\",\"count\":20042},{\"income\":\"$25,000 - $34,999\",\"count\":80456},{\"income\":\"$35,000 - $49,999\",\"count\":99999},{\"income\":\"$50,000 - $74,999\",\"count\":249983},{\"income\":\"$75,000 - $99,999\",\"count\":199773}]}],\"projectName\":\"RND\",\"releaseVersion\":\"1.4.0.RNN\"}"
| rex mode=sed "s/(\"[^,]*\":)(\"\")/\1\"null\"/g"
 | spath
 | rename counterList{}.counterValue{}.age as age, counterList{}.counterValue{}.count as count, counterList{}.counterName as counterName, counterList{}.counterValue{}.distinctSubCount as distinctSubCount, counterList{}.counterValue{}.gender as gender, counterList{}.counterValue{}.income as income, counterList{}.counterValue{}.subscriberCount as subscriberCount
 | eval index=mvrange(0,mvcount(count))| mvexpand index| eval age=mvindex(age,index), count=mvindex(count,index), gender=mvindex(gender,index), income=mvindex(income,index), subscriberCount=mvindex(subscriberCount,index)
 | table age count gender income subscriberCount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Apr 2018 09:33:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341787#M170182</guid>
      <dc:creator>TISKAR</dc:creator>
      <dc:date>2018-04-20T09:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341788#M170183</link>
      <description>&lt;P&gt;This is not displaying what i want. if you look into the age the key is empty for the first column and because of that the value of is showing incorrect&lt;BR /&gt;
For example &lt;BR /&gt;
{\"age\":\"\",\"count\":19953}&lt;BR /&gt;
{\"age\":\"18 - 24\",\"count\":30289}&lt;/P&gt;

&lt;P&gt;but when i am running the command &lt;BR /&gt;
18-24 is displaying 19953 &lt;/P&gt;

&lt;P&gt;Secondly i want to run the job like below because every time the job will run&lt;/P&gt;

&lt;P&gt;index=orion-platform sourcetype=palomar-metrics source="experianCounters.json"   | spath&lt;BR /&gt;
 | rename counterList{}.counterValue{}.age as age, counterList{}.counterValue{}.count as count, counterList{}.counterName as counterName, counterList{}.counterValue{}.distinctSubCount as distinctSubCount, counterList{}.counterValue{}.gender as gender, counterList{}.counterValue{}.income as income, counterList{}.counterValue{}.subscriberCount as subscriberCount&lt;BR /&gt;
 | eval index=mvrange(0,mvcount(count))| mvexpand index| eval age=mvindex(age,index), count=mvindex(count,index), gender=mvindex(gender,index), income=mvindex(income,index), subscriberCount=mvindex(subscriberCount,index)&lt;BR /&gt;
 | table age count gender income subscriberCount&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 05:03:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341788#M170183</guid>
      <dc:creator>pswalia06</dc:creator>
      <dc:date>2018-04-21T05:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341789#M170184</link>
      <description>&lt;P&gt;Good Observation, I modfied my proposition, can you test please&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 12:17:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341789#M170184</guid>
      <dc:creator>TISKAR</dc:creator>
      <dc:date>2018-04-21T12:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341790#M170185</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"runDate\":\"2018-04-18T00:31:46 EDT\",\"dataDate\":\"20180319\",\"jobName\":\"experianCounters\",\"counterList\":[{\"counterName\":\"experian.input.recordCount\",\"counterValue\":[{\"subscriberCount\":1000100,\"distinctSubCount\":1000100}]},{\"counterName\":\"experian.output.recordCount\",\"counterValue\":[{\"subscriberCount\":1000100,\"distinctSubCount\":1000100}]},{\"counterName\":\"experian.output.subscriberCountByAge\",\"counterValue\":[{\"age\":\"\",\"count\":19953},{\"age\":\"18 - 24\",\"count\":30289},{\"age\":\"25 - 34\",\"count\":149793},{\"age\":\"35 - 44\",\"count\":349856},{\"age\":\"45 - 54\",\"count\":250509},{\"age\":\"55 - 64\",\"count\":149719},{\"age\":\"65 - 74\",\"count\":30008},{\"age\":\"75+\",\"count\":19973}]},{\"counterName\":\"experian.output.subscriberCountByGender\",\"counterValue\":[{\"gender\":\"\",\"count\":79725},{\"gender\":\"B\",\"count\":49954},{\"gender\":\"F\",\"count\":419773},{\"gender\":\"M\",\"count\":450648}]},{\"counterName\":\"experian.output.subscriberCountByIncome\",\"counterValue\":[{\"income\":\"\",\"count\":19813},{\"income\":\"$1,000 - $14,999\",\"count\":39982},{\"income\":\"$100,000 - $124,999\",\"count\":100406},{\"income\":\"$125,000 - $149,999\",\"count\":29909},{\"income\":\"$15,000 - $24,999\",\"count\":60021},{\"income\":\"$150,000 - $174,999\",\"count\":20067},{\"income\":\"$175,000 - $199,999\",\"count\":79649},{\"income\":\"$200,000 - $249,999\",\"count\":20042},{\"income\":\"$25,000 - $34,999\",\"count\":80456},{\"income\":\"$35,000 - $49,999\",\"count\":99999},{\"income\":\"$50,000 - $74,999\",\"count\":249983},{\"income\":\"$75,000 - $99,999\",\"count\":199773}]}],\"projectName\":\"RND\",\"releaseVersion\":\"1.4.0.RNN\"}"
| rex max_match=0 "{\"age\":\"(?&amp;lt;age&amp;gt;[^\"]+)\",\"count\":(?&amp;lt;count&amp;gt;\d+)"
| foreach age count [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_0=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, 0)
                   | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_1=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, 1)
                   | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_2=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, 2)
                   | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_3=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, 3)
                   | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_4=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, 4)
                   | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_5=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, 5)
                   | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_6=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, 6) ]
| foreach age_* [eval {&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;}=count_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;]
| fields - age* count*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Apr 2018 17:25:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-regex/m-p/341790#M170185</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-04-22T17:25:15Z</dc:date>
    </item>
  </channel>
</rss>

