<?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 get count by unique value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472090#M132826</link>
    <description>&lt;P&gt;I am getting error while running this query. And product-id could be decimal value too, ex: 123.4567.8900. Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 14 Apr 2020 16:55:00 GMT</pubDate>
    <dc:creator>vel4ever</dc:creator>
    <dc:date>2020-04-14T16:55:00Z</dc:date>
    <item>
      <title>How to get count by unique value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472087#M132823</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am new to Splunk. I have below log which is capturing product id,&lt;/P&gt;

&lt;P&gt;Header product-id, 12345678900&lt;BR /&gt;
Header product-id, 12345678901&lt;BR /&gt;
Header product-id, 12345678900&lt;/P&gt;

&lt;P&gt;I would like to group by unique product id and count,&lt;/P&gt;

&lt;P&gt;12345678900 2&lt;BR /&gt;
12345678901 1&lt;/P&gt;

&lt;P&gt;Here product-id is not a field in splunk. How can write a query for this? &lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 01:36:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472087#M132823</guid>
      <dc:creator>vel4ever</dc:creator>
      <dc:date>2020-04-14T01:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to get count by unique value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472088#M132824</link>
      <description>&lt;P&gt;If your log is literally lines like &lt;CODE&gt;Header product-id, 12345678900&lt;/CODE&gt; then you can extract the last value (assuming all digits) and stats-by on that.&lt;/P&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search)
| rex "Header product-id, (&amp;lt;productId&amp;gt;\d+)"
| stats count by productId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If this doesn't work, please post the actual events you get back and I'm sure people here can help!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 02:35:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472088#M132824</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-04-14T02:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to get count by unique value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472089#M132825</link>
      <description>&lt;P&gt;hi @vel4ever &lt;/P&gt;

&lt;P&gt;try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
 | eval raw="Header product-id, 12345678900" 
 |eval ID=mvindex(split(raw," "),-1) |stats count by ID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2020 10:44:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472089#M132825</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2020-04-14T10:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get count by unique value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472090#M132826</link>
      <description>&lt;P&gt;I am getting error while running this query. And product-id could be decimal value too, ex: 123.4567.8900. Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 16:55:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472090#M132826</guid>
      <dc:creator>vel4ever</dc:creator>
      <dc:date>2020-04-14T16:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get count by unique value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472091#M132827</link>
      <description>&lt;P&gt;I am not getting any results for this query. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 16:55:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472091#M132827</guid>
      <dc:creator>vel4ever</dc:creator>
      <dc:date>2020-04-14T16:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get count by unique value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472092#M132828</link>
      <description>&lt;P&gt;Use rex command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex "product-id,\s(?&amp;lt;product_id&amp;gt;[\d\.]+)" | stats count by product_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2020 17:22:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-count-by-unique-value/m-p/472092#M132828</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-04-14T17:22:00Z</dc:date>
    </item>
  </channel>
</rss>

