<?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: Count unique values of a field in one result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138732#M38101</link>
    <description>&lt;P&gt;If Splunk is already identifying the field 'sid' for you as multivalued field for events having multiple values of it, try this:- &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | where mvcount(sid)=2 AND mvindex(sid,0)!=mvindex(sid,1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the field sid is not extracted by Splunk automatically, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex max_match=0 "sid=(?&amp;lt;sid&amp;gt;\w+)" | where mvcount(sid)=2 AND mvindex(sid,0)!=mvindex(sid,1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Jul 2015 14:49:01 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2015-07-27T14:49:01Z</dc:date>
    <item>
      <title>Count unique values of a field in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138729#M38098</link>
      <description>&lt;P&gt;I have the following result from a simple search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;I, [2015-07-23T15:30:39+02:00 (1437658239.654) #38640]  INFO -- ccceedb1a97f382d192a93fab686319b
[...]
"GET /?sid=ccceedb1a97f382d192a93fab686319b 
[...]
https://[...]?sid=756a0279d436826f3ad51ba00f49d65d" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 (PSBrowserEmbedded) Safari/537.36" [...]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(part of the search result hidden due to confidentiality requirements)&lt;/P&gt;

&lt;P&gt;However, it is not a normal behavior of the system for 'sid' to have two different values in one result. So I'm trying to find all results for a certain time frame where there are multiple values (i.e. more than one unique value) of 'sid' in &lt;STRONG&gt;one result&lt;/STRONG&gt;. I'm guessing it should be something similar to this:&lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/105397/count-unique-values-from-a-text-result.html"&gt;http://answers.splunk.com/answers/105397/count-unique-values-from-a-text-result.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But in one result.&lt;/P&gt;

&lt;P&gt;How can I do this?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 12:55:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138729#M38098</guid>
      <dc:creator>valentin_bogdan</dc:creator>
      <dc:date>2015-07-27T12:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values of a field in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138730#M38099</link>
      <description>&lt;P&gt;stats dc(field)&lt;/P&gt;

&lt;P&gt;you can extract the field or use can user regualrexpression.&lt;/P&gt;

&lt;P&gt;-Krishna Rajapantula&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 13:16:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138730#M38099</guid>
      <dc:creator>krishnarajapant</dc:creator>
      <dc:date>2015-07-27T13:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values of a field in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138731#M38100</link>
      <description>&lt;P&gt;Thanks  krishnarajapantula,&lt;/P&gt;

&lt;P&gt;However, this doesn't seem to work for me. The search brings me no results (having the same time range as the initial search).&lt;/P&gt;

&lt;P&gt;I was thinking it might be a bit more complex search, but am open to try any other suggestions.&lt;/P&gt;

&lt;P&gt;BR&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 14:21:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138731#M38100</guid>
      <dc:creator>valentin_bogdan</dc:creator>
      <dc:date>2015-07-27T14:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values of a field in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138732#M38101</link>
      <description>&lt;P&gt;If Splunk is already identifying the field 'sid' for you as multivalued field for events having multiple values of it, try this:- &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | where mvcount(sid)=2 AND mvindex(sid,0)!=mvindex(sid,1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the field sid is not extracted by Splunk automatically, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex max_match=0 "sid=(?&amp;lt;sid&amp;gt;\w+)" | where mvcount(sid)=2 AND mvindex(sid,0)!=mvindex(sid,1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jul 2015 14:49:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138732#M38101</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-07-27T14:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values of a field in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138733#M38102</link>
      <description>&lt;P&gt;Hi Valentin,&lt;/P&gt;

&lt;P&gt;U can use &lt;CODE&gt;|transaction&lt;/CODE&gt; command which will group with respect to session ID's..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "(?im)sid=(?\w+)" | transaction sid | stats count by sid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it will help.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 15:39:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138733#M38102</guid>
      <dc:creator>neelamssantosh</dc:creator>
      <dc:date>2015-07-27T15:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values of a field in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138734#M38103</link>
      <description>&lt;P&gt;Thank you somesoni2,&lt;/P&gt;

&lt;P&gt;Your answer seems to have worked best for me and returns results as I needed. Apparently, 'sid' is not extracted automatically by Splunk, so I had to use the second suggestion.&lt;/P&gt;

&lt;P&gt;Thanks to everyone for looking into this.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 07:46:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-unique-values-of-a-field-in-one-result/m-p/138734#M38103</guid>
      <dc:creator>valentin_bogdan</dc:creator>
      <dc:date>2015-07-28T07:46:50Z</dc:date>
    </item>
  </channel>
</rss>

