<?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: How to create table with two variables? Regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-table-with-two-variables-Regex/m-p/359846#M106378</link>
    <description>&lt;P&gt;Hi JoshuaJohn,&lt;BR /&gt;
does this search run?&lt;BR /&gt;
probably after stats there is an aggregation function (as count or dc...) and dedup has a field.&lt;BR /&gt;
Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nitros_prod_stores_servers sourcetype=_json OR sourcetype=xs_json host=isp* 
| rex "\"locId\":\"(?&amp;lt;locId&amp;gt;[^\"]*)\",\"ip\":\"[^\"]*\",\"hostName\":\"[^\"]*\",\"macaddress\":\"(?&amp;lt;macaddress&amp;gt;[^\"]*)\""
| stats count by locId macaddress
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Test regex in &lt;A href="https://regex101.com/r/EJd50g/1"&gt;https://regex101.com/r/EJd50g/1&lt;/A&gt;&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Fri, 17 Mar 2017 15:43:51 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-03-17T15:43:51Z</dc:date>
    <item>
      <title>How to create table with two variables? Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-table-with-two-variables-Regex/m-p/359845#M106377</link>
      <description>&lt;P&gt;Hi, I am very rusty with my splunk. I have this query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nitros_prod_stores_servers sourcetype=_json OR sourcetype=xs_json host=isp** | rex field=_raw "locId(?.*)+w" | rex field=_raw "macaddress(?.*)+w"| stats locId by macaddress | dedup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to use regex to grab this location number 0775 then use regex to grab this mac address 00-16-7F-EE-DD-17. Then have a list populate showing which mac addresses are in which locations and remove the duplicates. &lt;/P&gt;

&lt;P&gt;Location numbers and mac addresses will all be different there are many events that need to be sorted in this way. (Here are a few examples):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"bdy":{"msg":"NitrosApplication_OnLaunched event triggered.","metricName":"AppStart","metricValue":"NitrosApplication_OnLaunched","measuredTime":"00:00:00.7181610"},"hdr":{"level":"Information","timestamp":"2017-03-17T15:00:55.9692895Z","lineNum":0,"userId":"a211ba03eb3aa1","loc":"Store","locId":"0775","ip":"10.434.24.4","hostName":"W-W10ME-7534513","macaddress":"00-16-7F-EE-DD-17","eventid":0,"appVersion":"10.0.2","appName":"L"},"ver":"0.1"}

{"bdy":{"msg":"Background Task 'DevicePowerCheckBackgroundTask' is Running..."},"hdr":{"level":"Information","timestamp":"2017-03-17T15:00:55.842Z","fxsrc":"Run","lineNum":53,"loc":"Store","locId":"0320","ip":"10.439.3.11","hostName":"K-W10ME-054232","macaddress":"00-13-7F-13-33-29","eventid":0,"appVersion":"3.0.2","appName":"L"},"ver":"0.1"}

{"bdy":{"msg":"SplashPage loaded on back click.","metricName":"PageLoad","metricValue":"SplashPage","measuredTime":"00:00:00.0006669"},"hdr":{"level":"Information","timestamp":"2017-03-17T15:00:55.3022117Z","lineNum":0,"loc":"Store","locId":"0466","ip":"10.111.11.7","hostName":"K-W10ME-3727099","macaddress":"00-15-7E-GE-D2-11","eventid":0,"appVersion":"16.2.0","appName":"L"},"ver":"0.1"}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2017 15:26:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-table-with-two-variables-Regex/m-p/359845#M106377</guid>
      <dc:creator>JoshuaJohn</dc:creator>
      <dc:date>2017-03-17T15:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create table with two variables? Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-table-with-two-variables-Regex/m-p/359846#M106378</link>
      <description>&lt;P&gt;Hi JoshuaJohn,&lt;BR /&gt;
does this search run?&lt;BR /&gt;
probably after stats there is an aggregation function (as count or dc...) and dedup has a field.&lt;BR /&gt;
Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nitros_prod_stores_servers sourcetype=_json OR sourcetype=xs_json host=isp* 
| rex "\"locId\":\"(?&amp;lt;locId&amp;gt;[^\"]*)\",\"ip\":\"[^\"]*\",\"hostName\":\"[^\"]*\",\"macaddress\":\"(?&amp;lt;macaddress&amp;gt;[^\"]*)\""
| stats count by locId macaddress
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Test regex in &lt;A href="https://regex101.com/r/EJd50g/1"&gt;https://regex101.com/r/EJd50g/1&lt;/A&gt;&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 15:43:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-table-with-two-variables-Regex/m-p/359846#M106378</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-03-17T15:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to create table with two variables? Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-table-with-two-variables-Regex/m-p/359847#M106379</link>
      <description>&lt;P&gt;Since your sourcetype is json can you try spath? Following is one of your test data with run anywhere example. Moreover, I would expect Splunk to perform automatic field extraction for json sourcetype using &lt;STRONG&gt;KV_MODE=json&lt;/STRONG&gt; in &lt;STRONG&gt;props.conf&lt;/STRONG&gt;. Have you looked at interesting fields in verbose mode? (Splunk documentation on KV_MODE: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf&lt;/A&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval jsonData="{\"bdy\":{\"msg\":\"NitrosApplication_OnLaunched event triggered.\",\"metricName\":\"AppStart\",\"metricValue\":\"NitrosApplication_OnLaunched\",\"measuredTime\":\"00:00:00.7181610\"},\"hdr\":{\"level\":\"Information\",\"timestamp\":\"2017-03-17T15:00:55.9692895Z\",\"lineNum\":0,\"userId\":\"a211ba03eb3aa1\",\"loc\":\"Store\",\"locId\":\"0775\",\"ip\":\"10.434.24.4\",\"hostName\":\"W-W10ME-7534513\",\"macaddress\":\"00-16-7F-EE-DD-17\",\"eventid\":0,\"appVersion\":\"10.0.2\",\"appName\":\"L\"},\"ver\":\"0.1\"}"
| spath input=jsonData path=hdr.macaddress output=macaddress
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2017 16:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-table-with-two-variables-Regex/m-p/359847#M106379</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-17T16:53:44Z</dc:date>
    </item>
  </channel>
</rss>

