<?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: Is it possible to count the number of times a field occurs within a transaction? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315909#M94534</link>
    <description>&lt;P&gt;thank you very much!  That was the missing piece, plus I had to move the eventstats prior to the transaction clause.  I suppose given the same field=value, when in the context of the transaction it is seen as 1 occurrence of Consolidate in the event.&lt;/P&gt;

&lt;P&gt;final query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=myindex | eventstats count(eval(match(Consolidate,"True"))) as ConsolidateTrue by RequestId| transaction RequestId |  table RequestId ConsolidateTrue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;results in &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; RequestId   ConsolidateTrue
 123               2
 456               1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;thank you for the assist cmerriman!!!&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2017 19:39:38 GMT</pubDate>
    <dc:creator>popdeluxe</dc:creator>
    <dc:date>2017-05-23T19:39:38Z</dc:date>
    <item>
      <title>Is it possible to count the number of times a field occurs within a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315904#M94529</link>
      <description>&lt;P&gt;Is it possible to get the number of times a Field occurs within an event?&lt;/P&gt;

&lt;P&gt;I've read posts on how to arrive at unique values of a Field using mvcount.   In my case however I have custom logging that includes the same field=value across multiple lines.  I'm trying to find a way of counting the number of times this Field occurs within the transaction, so that I can afterwards filter, perhaps with a where clause, based on that that count.&lt;/P&gt;

&lt;P&gt;Example logging:&lt;/P&gt;

&lt;P&gt;(1)&lt;BR /&gt;
RequestId=123 RequestType=A&lt;BR /&gt;
RequestId=123 Consolidate=True&lt;BR /&gt;
RequestId=123 RequestType=A&lt;BR /&gt;
RequestId=123 Consolidate=True&lt;/P&gt;

&lt;P&gt;(2)&lt;BR /&gt;
RequestId=456 RequestType=A&lt;BR /&gt;
RequestId=456 RequestType=A&lt;BR /&gt;
RequestId=456 Consolidate=True&lt;/P&gt;

&lt;P&gt;I'm trying to arrive at a search that can build a transaction with RequestId where the count (number of occurrences of Consolidate) is 2.  So the search would return the transaction with RequestId 123 but not 456.  Hoping this makes sense.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 17:32:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315904#M94529</guid>
      <dc:creator>popdeluxe</dc:creator>
      <dc:date>2017-05-23T17:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to count the number of times a field occurs within a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315905#M94530</link>
      <description>&lt;P&gt;try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|eventstats count(eval(match(Consolidate,"True"))) as ConsolidateTrue|search ConsolidateTrue=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you could add another count if you want False, also.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 17:47:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315905#M94530</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-05-23T17:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to count the number of times a field occurs within a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315906#M94531</link>
      <description>&lt;P&gt;thank you cmerriman.&lt;/P&gt;

&lt;P&gt;eventstats is gathering the total count of Consolidate=True across all events.  Is it possible to get the count by individual transaction?  Using the logging example, this search.....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex | transaction RequestId | eventstats count(eval(match(Consolidate,"True"))) as ConsolidateTrue| table RequestId ConsolidateTrue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;RequestId   ConsolidateTrue
123               3
456               3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm trying to find a way of identifying RequestId 123 has 2 Consolidate fields, and 456 only has 1 (so that I can filter this event out)&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 18:46:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315906#M94531</guid>
      <dc:creator>popdeluxe</dc:creator>
      <dc:date>2017-05-23T18:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to count the number of times a field occurs within a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315907#M94532</link>
      <description>&lt;P&gt;Add this to the end of your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "(?&amp;lt;mvc&amp;gt;RequestId=123 Consolidate=True)" | where mvcount(mvc) &amp;gt; 2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2017 18:54:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315907#M94532</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-23T18:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to count the number of times a field occurs within a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315908#M94533</link>
      <description>&lt;P&gt;sorry, try adding by RequestId in the eventstats.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex | transaction RequestId | eventstats count(eval(match(Consolidate,"True"))) as ConsolidateTrue by RequestId| table RequestId ConsolidateTrue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2017 18:55:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315908#M94533</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-05-23T18:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to count the number of times a field occurs within a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315909#M94534</link>
      <description>&lt;P&gt;thank you very much!  That was the missing piece, plus I had to move the eventstats prior to the transaction clause.  I suppose given the same field=value, when in the context of the transaction it is seen as 1 occurrence of Consolidate in the event.&lt;/P&gt;

&lt;P&gt;final query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=myindex | eventstats count(eval(match(Consolidate,"True"))) as ConsolidateTrue by RequestId| transaction RequestId |  table RequestId ConsolidateTrue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;results in &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; RequestId   ConsolidateTrue
 123               2
 456               1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;thank you for the assist cmerriman!!!&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 19:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-count-the-number-of-times-a-field-occurs/m-p/315909#M94534</guid>
      <dc:creator>popdeluxe</dc:creator>
      <dc:date>2017-05-23T19:39:38Z</dc:date>
    </item>
  </channel>
</rss>

