<?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 do I create a Splunk query that generates an overview of field combinations? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-Splunk-query-that-generates-an-overview-of/m-p/408864#M118007</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm having difficulty creating a Splunk query that generates an overview of field combinations using regular expressions. What I'm trying to do is combine the fields 'code' and 'outCome' to a key and count the combination over a certain period of time. It is possible for the element 'code' not to be present? If that is the case, I would like to print it "NA". What I would expect the table to look like is:&lt;/P&gt;

&lt;P&gt;Code:outCome:Occurences&lt;BR /&gt;
NA:01:2&lt;BR /&gt;
UNKOWN:02:1&lt;BR /&gt;
KNOWN:01:1&lt;/P&gt;

&lt;P&gt;Below is the Splunk query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="&amp;lt;reply&amp;gt;&amp;lt;result&amp;gt;&amp;lt;sessiondId&amp;gt;1&amp;lt;/sessiondId&amp;gt;&amp;lt;resultChecks&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;code&amp;gt;UNKOWN&amp;lt;/code&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;02&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;code&amp;gt;KNOWN&amp;lt;/code&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;information&amp;gt;&amp;lt;record&amp;gt;&amp;lt;recordCode&amp;gt;1&amp;lt;/recordCode&amp;gt;&amp;lt;recordText&amp;gt;recordText&amp;lt;/recordText&amp;gt;&amp;lt;/record&amp;gt;&amp;lt;/information&amp;gt;&amp;lt;/resultChecks&amp;gt;&amp;lt;/result&amp;gt;&amp;lt;/reply&amp;gt;"
| rex max_match=0 field=_raw "(code&amp;gt;(?&amp;lt;code&amp;gt;\w+)&amp;lt;\/code&amp;gt;.*?)?outCome&amp;gt;(?&amp;lt;outCome&amp;gt;.*?)&amp;lt;\/outCome&amp;gt;"
| table code, outCome
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any suggestions on how to do this?&lt;/P&gt;

&lt;P&gt;Kind regards,&lt;/P&gt;

&lt;P&gt;Josip&lt;/P&gt;</description>
    <pubDate>Wed, 21 Nov 2018 19:08:19 GMT</pubDate>
    <dc:creator>josipj</dc:creator>
    <dc:date>2018-11-21T19:08:19Z</dc:date>
    <item>
      <title>How do I create a Splunk query that generates an overview of field combinations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-Splunk-query-that-generates-an-overview-of/m-p/408864#M118007</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm having difficulty creating a Splunk query that generates an overview of field combinations using regular expressions. What I'm trying to do is combine the fields 'code' and 'outCome' to a key and count the combination over a certain period of time. It is possible for the element 'code' not to be present? If that is the case, I would like to print it "NA". What I would expect the table to look like is:&lt;/P&gt;

&lt;P&gt;Code:outCome:Occurences&lt;BR /&gt;
NA:01:2&lt;BR /&gt;
UNKOWN:02:1&lt;BR /&gt;
KNOWN:01:1&lt;/P&gt;

&lt;P&gt;Below is the Splunk query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="&amp;lt;reply&amp;gt;&amp;lt;result&amp;gt;&amp;lt;sessiondId&amp;gt;1&amp;lt;/sessiondId&amp;gt;&amp;lt;resultChecks&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;code&amp;gt;UNKOWN&amp;lt;/code&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;02&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;code&amp;gt;KNOWN&amp;lt;/code&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;information&amp;gt;&amp;lt;record&amp;gt;&amp;lt;recordCode&amp;gt;1&amp;lt;/recordCode&amp;gt;&amp;lt;recordText&amp;gt;recordText&amp;lt;/recordText&amp;gt;&amp;lt;/record&amp;gt;&amp;lt;/information&amp;gt;&amp;lt;/resultChecks&amp;gt;&amp;lt;/result&amp;gt;&amp;lt;/reply&amp;gt;"
| rex max_match=0 field=_raw "(code&amp;gt;(?&amp;lt;code&amp;gt;\w+)&amp;lt;\/code&amp;gt;.*?)?outCome&amp;gt;(?&amp;lt;outCome&amp;gt;.*?)&amp;lt;\/outCome&amp;gt;"
| table code, outCome
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any suggestions on how to do this?&lt;/P&gt;

&lt;P&gt;Kind regards,&lt;/P&gt;

&lt;P&gt;Josip&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 19:08:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-Splunk-query-that-generates-an-overview-of/m-p/408864#M118007</guid>
      <dc:creator>josipj</dc:creator>
      <dc:date>2018-11-21T19:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a Splunk query that generates an overview of field combinations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-Splunk-query-that-generates-an-overview-of/m-p/408865#M118008</link>
      <description>&lt;P&gt;Here it is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="&amp;lt;reply&amp;gt;&amp;lt;result&amp;gt;&amp;lt;sessiondId&amp;gt;1&amp;lt;/sessiondId&amp;gt;&amp;lt;resultChecks&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;code&amp;gt;UNKOWN&amp;lt;/code&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;02&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;resultCheck&amp;gt;&amp;lt;personId/&amp;gt;&amp;lt;code&amp;gt;KNOWN&amp;lt;/code&amp;gt;&amp;lt;address&amp;gt;&amp;lt;street&amp;gt;streetName&amp;lt;/street&amp;gt;&amp;lt;/address&amp;gt;&amp;lt;outCome&amp;gt;01&amp;lt;/outCome&amp;gt;&amp;lt;/resultCheck&amp;gt;&amp;lt;information&amp;gt;&amp;lt;record&amp;gt;&amp;lt;recordCode&amp;gt;1&amp;lt;/recordCode&amp;gt;&amp;lt;recordText&amp;gt;recordText&amp;lt;/recordText&amp;gt;&amp;lt;/record&amp;gt;&amp;lt;/information&amp;gt;&amp;lt;/resultChecks&amp;gt;&amp;lt;/result&amp;gt;&amp;lt;/reply&amp;gt;" 
| spath output=resultCheck path=reply.result.resultChecks.resultCheck
| mvexpand resultCheck
| rex field=resultCheck "(\&amp;lt;code\&amp;gt;(?&amp;lt;code&amp;gt;\w+)\&amp;lt;\/code\&amp;gt;)?\&amp;lt;address.+outCome\&amp;gt;(?&amp;lt;outCome&amp;gt;\d+)\&amp;lt;\/outCome\&amp;gt;"
| eval code=if(isnull(code),"NA",code)
| stats count by code,outCome
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 20:44:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-Splunk-query-that-generates-an-overview-of/m-p/408865#M118008</guid>
      <dc:creator>akocak</dc:creator>
      <dc:date>2018-11-21T20:44:06Z</dc:date>
    </item>
  </channel>
</rss>

