<?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 count multiple events per line in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114064#M30109</link>
    <description>&lt;P&gt;all I get is a count of every instance of email domain (count of 1) and all other fields are blank, maybe I am substituting in the wrong place, I replaced step 3 with your latest&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jan 2015 23:08:07 GMT</pubDate>
    <dc:creator>Dallastek</dc:creator>
    <dc:date>2015-01-28T23:08:07Z</dc:date>
    <item>
      <title>How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114058#M30103</link>
      <description>&lt;P&gt;Im trying to count how many events by category per email domain and do a total of events going to each domain. My query looks like this (note I macroed all the different email domains)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysearch `myemail`
| stats  values(Dst_Email_Domain) AS Email_Domain count by Name  
| sort  - count 
| stats list values(Name) sum dc(Name) by Email_Domain 
| sort  - sum(count) 
| rename  "list(Name)" TO Category, list(count) TO Count, sum(count) TO Total 
| fields Email_Domain, Category, Count, Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So this gives me 4 columns: Email_Domain, Category, Count, Total. I get a count in Category for each domain but the count is the same for each item in category e.g. invoice=50, customer bill=100, credit card=75 across all email domains. the Totals seems right, but I can't get the individual events in the category field to count right per each domain. (hope that explains it)&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 20:01:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114058#M30103</guid>
      <dc:creator>Dallastek</dc:creator>
      <dc:date>2015-01-28T20:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114059#M30104</link>
      <description>&lt;P&gt;Can you post an sample of scrubbed events?  what might help&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 20:16:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114059#M30104</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2015-01-28T20:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114060#M30105</link>
      <description>&lt;P&gt;output looks something like this: (note im only 1 mo. into using splunk) the counts in the category column are the same for all domains, the total column seems to have the correct counts for the # of emails going out, but it does not match up with the category column.&lt;BR /&gt;
Email_Domain        Category        Count       Total&lt;BR /&gt;
gmail.com           customerbill            100              470&lt;BR /&gt;
                    creditcard       50&lt;BR /&gt;
                    Invoice          100&lt;BR /&gt;
                    confidential              220&lt;BR /&gt;
yahoo.com           customerbill             100                 250&lt;BR /&gt;
                    creditcard        50&lt;BR /&gt;
                    Invoice          100&lt;BR /&gt;
hotmail.com         customerbill             100                300&lt;BR /&gt;
                    creditcard       50&lt;BR /&gt;
                    Invoice          100&lt;BR /&gt;
                    confidential             220 &lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 20:29:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114060#M30105</guid>
      <dc:creator>Dallastek</dc:creator>
      <dc:date>2015-01-28T20:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114061#M30106</link>
      <description>&lt;P&gt;The problem happens in step 3 - you have grouped all of your email domains into a single multi-valued variable. After that, in step 5, you can no longer count by each value of email domain. Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype=mysearch `myemail`
 | stats count as Count by Name  Email_Domain
 | appendpipe [ stats sum(Count) as Total by Email_Domain | eval Name="**Total**" ]
 | sort Email_Domain
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This may not order exactly as you want, so you could also do this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype=mysearch `myemail`
 | stats count as Count by Name Email_Domain
 | eventstats sum(Count) as sortTotal
 | appendpipe [ stats sum(Count) as Total by Email_Domain | eval Name="**Total**" ]
 | sort -sortTotal Email_Domain Name
 | fields -sortTotal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am not sure if the email domain total will sort to the end, but you can try it.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 20:31:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114061#M30106</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-01-28T20:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114062#M30107</link>
      <description>&lt;P&gt;Didn't work, most of the fields in my table end up being blank&lt;BR /&gt;
that either gives me no results or just a value of 1 100 times&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 20:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114062#M30107</guid>
      <dc:creator>Dallastek</dc:creator>
      <dc:date>2015-01-28T20:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114063#M30108</link>
      <description>&lt;P&gt;Okay, what do you get if you do this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  sourcetype=mysearch `myemail`
  | stats count as Count by Name Email_Domain
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jan 2015 22:43:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114063#M30108</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-01-28T22:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114064#M30109</link>
      <description>&lt;P&gt;all I get is a count of every instance of email domain (count of 1) and all other fields are blank, maybe I am substituting in the wrong place, I replaced step 3 with your latest&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 23:08:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114064#M30109</guid>
      <dc:creator>Dallastek</dc:creator>
      <dc:date>2015-01-28T23:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114065#M30110</link>
      <description>&lt;P&gt;Just run the following search all by itself: you should get 3 columns: Name Email_Domain Count&lt;BR /&gt;&lt;BR /&gt;
They should make sense to you.&lt;/P&gt;

&lt;P&gt;I just want to see if you can get the basic counts or if there is something more fundamentally wrong here.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   sourcetype=mysearch `myemail`
   | stats count as Count by Name Email_Domain
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Jan 2015 06:42:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114065#M30110</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-01-29T06:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to count multiple events per line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114066#M30111</link>
      <description>&lt;P&gt;That search did give me the 3 columns,&lt;BR /&gt;
After playing with it some more and using some of your suggestions as a guideline this is what we  came up with and it works perfectly &lt;BR /&gt;
sourcetype=mysearch  &lt;CODE&gt;myemail&lt;/CODE&gt; | top Name by Dst_Email_Domain limit=500 | stats list(Name), list(count), sum(count) by Dst_Email_Domain&lt;/P&gt;

&lt;P&gt;guess I was over thinking it earlier&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:45:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-multiple-events-per-line/m-p/114066#M30111</guid>
      <dc:creator>Dallastek</dc:creator>
      <dc:date>2020-09-28T18:45:16Z</dc:date>
    </item>
  </channel>
</rss>

