<?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: aggregating stats by wildcard or arbitrary number of fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/aggregating-stats-by-wildcard-or-arbitrary-number-of-fields/m-p/48451#M11563</link>
    <description>&lt;P&gt;I'm pretty sure that this technique will fall apart if you want to do anything more complicated, but ..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup example.csv | fields - uid | search msg="click" | stats count(AB*) | transpose | rex field=column ^count\((?&amp;lt;column&amp;gt;.*?)\) | rename column as field | rename "row 1" as count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field   count
AB_test1    4
AB_test2    4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 31 Aug 2012 15:11:20 GMT</pubDate>
    <dc:creator>jonuwz</dc:creator>
    <dc:date>2012-08-31T15:11:20Z</dc:date>
    <item>
      <title>aggregating stats by wildcard or arbitrary number of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/aggregating-stats-by-wildcard-or-arbitrary-number-of-fields/m-p/48450#M11562</link>
      <description>&lt;P&gt;Imagine I have the following data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;msg     uid      AB_test1     AB_test2
click   1        A            A
reqst   2        B            A
click   3        B            B
reqst   4        A            B
click   5        B            A
reqst   6        B            A
click   7        A            A
reqst   8        A            B
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to do a stats query aggregating the results of my various AB tests for the "click" msg. I can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;msg="click" | stats count by AB_test1, AB_test2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But imagine I now have &lt;CODE&gt;AB_test3&lt;/CODE&gt; through &lt;CODE&gt;AB_test10&lt;/CODE&gt; or a variable number of tests running at once. I don't want to have to do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;msg="click" | stats count by AB_test1, AB_test2, ... AB_test10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd like to do something similar to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;msg="click" | stats count by AB_*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this possible, or is there some similar syntax that essentially groups data by an arbitrary set of fields?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2012 12:45:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/aggregating-stats-by-wildcard-or-arbitrary-number-of-fields/m-p/48450#M11562</guid>
      <dc:creator>mikesherov</dc:creator>
      <dc:date>2012-08-31T12:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating stats by wildcard or arbitrary number of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/aggregating-stats-by-wildcard-or-arbitrary-number-of-fields/m-p/48451#M11563</link>
      <description>&lt;P&gt;I'm pretty sure that this technique will fall apart if you want to do anything more complicated, but ..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup example.csv | fields - uid | search msg="click" | stats count(AB*) | transpose | rex field=column ^count\((?&amp;lt;column&amp;gt;.*?)\) | rename column as field | rename "row 1" as count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field   count
AB_test1    4
AB_test2    4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Aug 2012 15:11:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/aggregating-stats-by-wildcard-or-arbitrary-number-of-fields/m-p/48451#M11563</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-08-31T15:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating stats by wildcard or arbitrary number of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/aggregating-stats-by-wildcard-or-arbitrary-number-of-fields/m-p/48452#M11564</link>
      <description>&lt;P&gt;I suppose that there is no hope of transforming the data into this format:&lt;/P&gt;

&lt;P&gt;msg   uid testName testResult&lt;BR /&gt;&lt;BR /&gt;
click   1     test1        A&lt;BR /&gt;&lt;BR /&gt;
click   1     test2        A  &lt;/P&gt;

&lt;P&gt;BTW, it would be nice if you could wildcard the stats command as you showed! But you can't, and I can't see any other easy way to do what you want.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2012 15:17:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/aggregating-stats-by-wildcard-or-arbitrary-number-of-fields/m-p/48452#M11564</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-08-31T15:17:12Z</dc:date>
    </item>
  </channel>
</rss>

