<?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: Counting a field for number of messages per unique value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-field-for-number-of-messages-per-unique-value/m-p/70735#M17719</link>
    <description>&lt;P&gt;You don't say where in the process you're stuck, but in this answer I'm assuming the following:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;The unique identifier is present in all points 1-4 so that they can be identified correctly.&lt;/LI&gt;
&lt;LI&gt;The unique identifier is extracted to some field in Splunk (let's call it &lt;CODE&gt;txnid&lt;/CODE&gt; in this example)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;If you've got that far, this is my suggestion on how to proceed. Run &lt;CODE&gt;transaction&lt;/CODE&gt; to group the events together. &lt;CODE&gt;transaction&lt;/CODE&gt; will, among other things it does, create two fields called &lt;CODE&gt;eventcount&lt;/CODE&gt; and &lt;CODE&gt;duration&lt;/CODE&gt;. &lt;CODE&gt;eventcount&lt;/CODE&gt; is exactly what it says - the number of events in each transaction. So you could build your transactions, then check which ones don't have exactly 4 events in them, and the ones that do have it. This can then be used in your stats calculation.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | transaction txnid | stats dc(txnid) as total_txn_count, count(eval(eventcount=4)) as txn_success, count(eval(eventcount!=4)) as txn_fail
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 Sep 2012 22:17:02 GMT</pubDate>
    <dc:creator>Ayn</dc:creator>
    <dc:date>2012-09-25T22:17:02Z</dc:date>
    <item>
      <title>Counting a field for number of messages per unique value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-field-for-number-of-messages-per-unique-value/m-p/70734#M17718</link>
      <description>&lt;P&gt;I have transactions being logged to Splunk, but I get multiple messages per transaction.&lt;BR /&gt;
We are in the middle tier and the 4 messages are as follows:&lt;BR /&gt;
Point 1 - We receive a request from a requester with a unique identifier.&lt;BR /&gt;
Point 2 - We send the request to a backend system&lt;BR /&gt;
Point 3 - We receive a response from a backend system&lt;BR /&gt;
Point 4 - We send the response to the requester.&lt;/P&gt;

&lt;P&gt;Having all 4 points would indicate a successful transaction.  If we don't get all 4 points, then it is a failed request.  What I've got is the count of the points based on unique identifier, but I need a Total Count of transaction (total # of unique IDs), count of Success and count of failures.&lt;/P&gt;

&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2012 21:18:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-field-for-number-of-messages-per-unique-value/m-p/70734#M17718</guid>
      <dc:creator>sysprg1</dc:creator>
      <dc:date>2012-09-25T21:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a field for number of messages per unique value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-field-for-number-of-messages-per-unique-value/m-p/70735#M17719</link>
      <description>&lt;P&gt;You don't say where in the process you're stuck, but in this answer I'm assuming the following:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;The unique identifier is present in all points 1-4 so that they can be identified correctly.&lt;/LI&gt;
&lt;LI&gt;The unique identifier is extracted to some field in Splunk (let's call it &lt;CODE&gt;txnid&lt;/CODE&gt; in this example)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;If you've got that far, this is my suggestion on how to proceed. Run &lt;CODE&gt;transaction&lt;/CODE&gt; to group the events together. &lt;CODE&gt;transaction&lt;/CODE&gt; will, among other things it does, create two fields called &lt;CODE&gt;eventcount&lt;/CODE&gt; and &lt;CODE&gt;duration&lt;/CODE&gt;. &lt;CODE&gt;eventcount&lt;/CODE&gt; is exactly what it says - the number of events in each transaction. So you could build your transactions, then check which ones don't have exactly 4 events in them, and the ones that do have it. This can then be used in your stats calculation.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | transaction txnid | stats dc(txnid) as total_txn_count, count(eval(eventcount=4)) as txn_success, count(eval(eventcount!=4)) as txn_fail
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Sep 2012 22:17:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-field-for-number-of-messages-per-unique-value/m-p/70735#M17719</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-09-25T22:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a field for number of messages per unique value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-field-for-number-of-messages-per-unique-value/m-p/70736#M17720</link>
      <description>&lt;P&gt;That worked perfectly.  Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2012 13:00:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-field-for-number-of-messages-per-unique-value/m-p/70736#M17720</guid>
      <dc:creator>sysprg1</dc:creator>
      <dc:date>2012-09-26T13:00:18Z</dc:date>
    </item>
  </channel>
</rss>

