<?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 an event based on a unique variable? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252943#M75697</link>
    <description>&lt;P&gt;Hi @zach5871&lt;/P&gt;

&lt;P&gt;Glad you were able to find a solution through @rich7177 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Please don't forget to resolve the post by clicking "Accept" directly below his answer. This will make your question easier to find for other users with a similar issue. Oh, and don't forget to upvote rich by clicking the up arrow to the left of his answer since he helped you out. Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 01 Feb 2016 18:51:48 GMT</pubDate>
    <dc:creator>ppablo</dc:creator>
    <dc:date>2016-02-01T18:51:48Z</dc:date>
    <item>
      <title>How to count an event based on a unique variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252940#M75694</link>
      <description>&lt;P&gt;My question may be somewhat misleading, but I'm trying to plot a timechart of one event field based on common variables within each event. &lt;/P&gt;

&lt;P&gt;So each call activity produces three event records with a common &lt;CODE&gt;"CC{@id}" "CC.dialogId"&lt;/CODE&gt;. I have a working search counting the number of calls:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="fe_test" sourcetype=fe_xml  source=$site_token$ $group_token$ | stats min(_time) AS start max(_time) AS end by "CC{@id}" "CC.dialogId"  | stats count AS "Total Calls"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives a stats count of total calls. And I have a working timechart that plots how active each site is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="fe_test" source=$site_token$ $group_token$ | timechart count by site_name limit=15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the results are multiplied by a factor of 3. I'm trying to have the timechart of "site_name" events tied to the common &lt;CODE&gt;"CC{@id}" "CC.dialogId"&lt;/CODE&gt; to that record. &lt;/P&gt;</description>
      <pubDate>Sun, 31 Jan 2016 03:46:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252940#M75694</guid>
      <dc:creator>zach5871</dc:creator>
      <dc:date>2016-01-31T03:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to count an event based on a unique variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252941#M75695</link>
      <description>&lt;P&gt;There are a couple of mechanisms to do this if I'm reading your question correctly.  &lt;/P&gt;

&lt;P&gt;If you mean you have events that come in groups of three, and when you do a timechart count of them you get three times the results, then your easiest way to handle this is to restrict your search more.  This assumes that there's a way to identify only ONE of the three events that come in, but if there is you can just add that addition search filter to your base search.  Like, "sessionstart" or something.  I don't have any samples of your data, so I couldn't fathom what this would be, but maybe you can find something.&lt;/P&gt;

&lt;P&gt;Otherwise if  CC.dialogid is actually unique for each set of three events (i.e. it never repeats, or at least not often), then you could create a &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.2/SearchReference/Transaction"&gt;transaction&lt;/A&gt; out of it.  I don't have any sample data, but a guess would be...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="fe_test" sourcetype=fe_xml source=$site_token$ $group_token$ 
| transaction "CC{@id}" "CC.dialogId" maxspan=1h 
| timechart count by site_name limit=15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives you information much like stats does, too (or can - see the docs I liked), but should in any case make timechart behave properly.&lt;/P&gt;

&lt;P&gt;Or, as a quick fix, and I really don't recommend this because it's too fragile, you could just divide your answer by three at the end of all that.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  &lt;CODE&gt;...|eval count=count/3 ...&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jan 2016 19:46:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252941#M75695</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-01-31T19:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to count an event based on a unique variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252942#M75696</link>
      <description>&lt;P&gt;This is exactly the solution I was looking for! As background, this is a mobile radio system that logs the "cc{@id}" as an initiated call across all sites with users listening to that group. Each site then creates a start, stop, and update with the same common "cc{@id}". Thank you once again. This software has gained attention around here faster than I can gain the knowledge to suffice. I'm sure I'll be back...&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2016 13:10:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252942#M75696</guid>
      <dc:creator>zach5871</dc:creator>
      <dc:date>2016-02-01T13:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to count an event based on a unique variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252943#M75697</link>
      <description>&lt;P&gt;Hi @zach5871&lt;/P&gt;

&lt;P&gt;Glad you were able to find a solution through @rich7177 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Please don't forget to resolve the post by clicking "Accept" directly below his answer. This will make your question easier to find for other users with a similar issue. Oh, and don't forget to upvote rich by clicking the up arrow to the left of his answer since he helped you out. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2016 18:51:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-an-event-based-on-a-unique-variable/m-p/252943#M75697</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2016-02-01T18:51:48Z</dc:date>
    </item>
  </channel>
</rss>

