<?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: Grouping using regex, then do stats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276436#M83403</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;
I would do something like that:&lt;BR /&gt;
 - creation of a temporary variable type!path which takes different value according to the value of Path&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval type_path = case(match(Path, "\/x\/y\/"), path_type1, match(Path,"\/x\/y\/\d+"), path_type2, match(Path,"\/z\/t\/"), path_type3)| stats avg(duration) by type_path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;regards&lt;/P&gt;</description>
    <pubDate>Mon, 19 Oct 2015 20:00:29 GMT</pubDate>
    <dc:creator>clorne</dc:creator>
    <dc:date>2015-10-19T20:00:29Z</dc:date>
    <item>
      <title>Grouping using regex, then do stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276435#M83402</link>
      <description>&lt;P&gt;Assume each event includes 2 fields: &lt;CODE&gt;path&lt;/CODE&gt; and &lt;CODE&gt;duration&lt;/CODE&gt; among other fields. &lt;BR /&gt;
&lt;CODE&gt;Path&lt;/CODE&gt; can have values: (i) type1  = &lt;CODE&gt;/x/y/&lt;/CODE&gt;, (ii) type2 = &lt;CODE&gt;x/y/\d+&lt;/CODE&gt; , eg. &lt;CODE&gt;/x/y/1234&lt;/CODE&gt;, (iii) type3= &lt;CODE&gt;z/t/&lt;/CODE&gt;, (iv) anything else.&lt;BR /&gt;
How can I calculate the avg(duration) per type of &lt;CODE&gt;path&lt;/CODE&gt;, only consider &lt;CODE&gt;type1&lt;/CODE&gt;, &lt;CODE&gt;type2&lt;/CODE&gt;, and &lt;CODE&gt;type3&lt;/CODE&gt;, the rest is not interested?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath path | .... some how group the paths into different groups using regex ... | stats avg(duration) by path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I could do &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | regex path="/x/y(/\d+)?|/z/t/" | stats avg(duration) by path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but the problem is that &lt;CODE&gt;/x/y/1234&lt;/CODE&gt; will be treated differently from &lt;CODE&gt;/x/y/2345&lt;/CODE&gt; while I want to group all of them into &lt;CODE&gt;type2&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2015 19:24:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276435#M83402</guid>
      <dc:creator>splunknewbieste</dc:creator>
      <dc:date>2015-10-19T19:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping using regex, then do stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276436#M83403</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I would do something like that:&lt;BR /&gt;
 - creation of a temporary variable type!path which takes different value according to the value of Path&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval type_path = case(match(Path, "\/x\/y\/"), path_type1, match(Path,"\/x\/y\/\d+"), path_type2, match(Path,"\/z\/t\/"), path_type3)| stats avg(duration) by type_path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;regards&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2015 20:00:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276436#M83403</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2015-10-19T20:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping using regex, then do stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276437#M83404</link>
      <description>&lt;P&gt;Above can be applied after your regex filter.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2015 20:29:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276437#M83404</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-10-19T20:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping using regex, then do stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276438#M83405</link>
      <description>&lt;P&gt;Yes, I think that works. Thanks @clorne. &lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2015 20:36:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-using-regex-then-do-stats/m-p/276438#M83405</guid>
      <dc:creator>splunknewbieste</dc:creator>
      <dc:date>2015-10-19T20:36:51Z</dc:date>
    </item>
  </channel>
</rss>

