<?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 count the numbers of occurrence for two value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482425#M135159</link>
    <description>&lt;P&gt;I have the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="placingOrder" Code=504 host="localhost*" | stats count by Path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Path                            count
/api/fetchReport/v2/report1    2
/api/fetchReport/v2/report2    8
/api/fetchReport/v2/report3    3
/api/fetchReport/v2/report4   10
/api/Order/v2/OrdrePlaced        9
/api/Order/v3/OrdreNotPlaced    1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the output should be: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Path                   Module           count                   
fetchReport            report1          2
                       report2             8
                       report3             3
                       report4             10
Order               OrdrePlaced          9
                       OrdreNotPlaced       1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Sep 2019 10:18:39 GMT</pubDate>
    <dc:creator>JyotiP</dc:creator>
    <dc:date>2019-09-16T10:18:39Z</dc:date>
    <item>
      <title>How to count the numbers of occurrence for two value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482425#M135159</link>
      <description>&lt;P&gt;I have the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="placingOrder" Code=504 host="localhost*" | stats count by Path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Path                            count
/api/fetchReport/v2/report1    2
/api/fetchReport/v2/report2    8
/api/fetchReport/v2/report3    3
/api/fetchReport/v2/report4   10
/api/Order/v2/OrdrePlaced        9
/api/Order/v3/OrdreNotPlaced    1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the output should be: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Path                   Module           count                   
fetchReport            report1          2
                       report2             8
                       report3             3
                       report4             10
Order               OrdrePlaced          9
                       OrdreNotPlaced       1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Sep 2019 10:18:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482425#M135159</guid>
      <dc:creator>JyotiP</dc:creator>
      <dc:date>2019-09-16T10:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the numbers of occurrence for two value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482426#M135160</link>
      <description>&lt;P&gt;@JyotiP &lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="placingOrder" Code=504 host="localhost*" | stats count by Path | rex field=Path "\/api\/(?&amp;lt;Path&amp;gt;.*)\/(v2|v3)\/(?&amp;lt;Module&amp;gt;.*)" | streamstats window=2 first(Path) as f_path count as c |
eval Path=case(c=1,Path,Path!=f_path,Path,1=1,"") | table Path Module count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;My Sample Search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw=" Path                            count
 /api/fetchReport/v2/report1       2
 /api/fetchReport/v2/report2       8
 /api/fetchReport/v2/report3       3
 /api/fetchReport/v2/report4      10
 /api/Order/v2/OrdrePlaced         9
 /api/Order/v3/OrdreNotPlaced      1
" | multikv | rex field=Path "\/api\/(?&amp;lt;Path&amp;gt;.*)\/(v2|v3)\/(?&amp;lt;Module&amp;gt;.*)" | streamstats window=2 first(Path) as f_path count as c |
eval Path=case(c=1,Path,Path!=f_path,Path,1=1,"") | table Path Module count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Sep 2019 10:34:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482426#M135160</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-09-16T10:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the numbers of occurrence for two value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482427#M135161</link>
      <description>&lt;P&gt;@kamlesh_vaghela yeah this work. What does this &lt;CODE&gt;streamstats&lt;/CODE&gt; do?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 10:42:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482427#M135161</guid>
      <dc:creator>JyotiP</dc:creator>
      <dc:date>2019-09-16T10:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the numbers of occurrence for two value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482428#M135162</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Inspite of stats count by Path, use "|table Path" . &lt;/P&gt;

&lt;P&gt;Try below query&lt;/P&gt;

&lt;P&gt;sourcetype="placingOrder" Code=504 host="localhost*" |table Path | rex field=Path "/api/(?\w+)/(?\w+)/(?\w+)" | stats count by field1 field3*&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:11:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482428#M135162</guid>
      <dc:creator>wanip_fossil</dc:creator>
      <dc:date>2020-09-30T02:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the numbers of occurrence for two value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482429#M135163</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Adds cumulative summary statistics to all search results in a streaming manner. The streamstats command calculates statistics for each event at the time the event is seen.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Streamstats"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Streamstats&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 11:16:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482429#M135163</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-09-16T11:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the numbers of occurrence for two value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482430#M135164</link>
      <description>&lt;P&gt;@wanip_fossil I guess something wrong with the regex. I am getting an error in the regex.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 15:14:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482430#M135164</guid>
      <dc:creator>JyotiP</dc:creator>
      <dc:date>2019-09-16T15:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the numbers of occurrence for two value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482431#M135165</link>
      <description>&lt;P&gt;sourcetype="placingOrder" Code=504 host="localhost*" |table Path | rex field=Path "\/api\/(?\w+)\/(?\w+)\/(?\w+)" | stats count by field1 field3*&lt;/P&gt;

&lt;P&gt;Please try now&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:11:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482431#M135165</guid>
      <dc:creator>wanip_fossil</dc:creator>
      <dc:date>2020-09-30T02:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the numbers of occurrence for two value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482432#M135166</link>
      <description>&lt;P&gt;Getting the below error,&lt;BR /&gt;
    Error in 'rex' command: Encountered the following error while compiling the regex '\/api\/(?\w+)\/(?\w+)\/(?\w+)': Regex: unrecognized character after (? or (?-&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 15:42:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-the-numbers-of-occurrence-for-two-value/m-p/482432#M135166</guid>
      <dc:creator>JyotiP</dc:creator>
      <dc:date>2019-09-16T15:42:41Z</dc:date>
    </item>
  </channel>
</rss>

