<?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: Search query: Unique values based on time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480264#M134607</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks for the help. Dedup logic seems to be working.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jan 2020 16:58:34 GMT</pubDate>
    <dc:creator>siddharth1479</dc:creator>
    <dc:date>2020-01-14T16:58:34Z</dc:date>
    <item>
      <title>Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480247#M134590</link>
      <description>&lt;P&gt;Hi Community,&lt;BR /&gt;
I'm using the search query to search for the user activity and I get the results with duplicate rows with the same user with the same time. The time format is as follows: YYYY-DD-MM HH:MM:SS:000. I get the result as following:&lt;/P&gt;

&lt;P&gt;USER                |                 TIME&lt;BR /&gt;
abcd                 |    2020-06-01 08:58:51&lt;BR /&gt;
abcd                 |    2020-06-01 08:58:51&lt;BR /&gt;
abcd                 |    2020-06-01 08:58:51&lt;/P&gt;

&lt;P&gt;abcd                 |    2020-06-01 09:32:27&lt;BR /&gt;
abcd                 |    2020-06-01 09:32:27&lt;BR /&gt;
abcd                 |    2020-06-01 09:32:27&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;The output I desire is:&lt;/P&gt;

&lt;P&gt;USER                |                 TIME&lt;BR /&gt;
abcd                 |    2020-06-01 08:58:51&lt;BR /&gt;
abcd                 |    2020-06-01 09:32:27&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Search query I'm using is:&lt;BR /&gt;
index="uam" User="abcd" | eval access_time=strftime(_time, "%Y-%d-%m %H:%M:%S") | fields "USER" "TIME"&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;How do I get the unique values, because it seems that Splunk compares the time upto milliseconds. &lt;BR /&gt;
Can anyone please help me out?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Sid&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:36:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480247#M134590</guid>
      <dc:creator>siddharth1479</dc:creator>
      <dc:date>2020-09-30T03:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480248#M134591</link>
      <description>&lt;P&gt;&lt;CODE&gt;stats&lt;/CODE&gt; is your friend &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/stats"&gt;here&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="uam" User="abcd" 
| eval Timeime=strftime(_time, "%Y-%d-%m %H:%M:%S")
| stats count by User Time
| fields - count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jan 2020 19:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480248#M134591</guid>
      <dc:creator>wmyersas</dc:creator>
      <dc:date>2020-01-07T19:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480249#M134592</link>
      <description>&lt;P&gt;Hey @wmyersas ,&lt;BR /&gt;
Thanks for the help.&lt;/P&gt;

&lt;P&gt;As I said, Splunk compares the time difference by milliseconds and not by seconds, its still shows the same result which it showed before. &lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Sid&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2020 21:12:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480249#M134592</guid>
      <dc:creator>siddharth1479</dc:creator>
      <dc:date>2020-01-07T21:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480250#M134593</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index="uam" User="abcd" 
 | eval access_time=strftime(_time, "%Y-%d-%m %H:%M:%S")
 | stats values(User) as USER by access_time
 | rename access_time as TIME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hi, try this.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2020 21:42:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480250#M134593</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-07T21:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480251#M134594</link>
      <description>&lt;P&gt;Looks like a typo there:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="uam" User="abcd" 
 | eval access_time=strftime(_time, "%Y-%d-%m %H:%M:%S")
 | rename access_time as TIME
 | stats count by USER TIME
 | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should sort it&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 16:10:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480251#M134594</guid>
      <dc:creator>sheamus69</dc:creator>
      <dc:date>2020-01-08T16:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480252#M134595</link>
      <description>&lt;P&gt;If you've already formatted the time into a new format, then you don't need to worry about the milliseconds &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2020 15:54:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480252#M134595</guid>
      <dc:creator>wmyersas</dc:creator>
      <dc:date>2020-01-09T15:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480253#M134596</link>
      <description>&lt;P&gt;I was going off OP - but you're right, he was missing a rename in there &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2020 15:55:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480253#M134596</guid>
      <dc:creator>wmyersas</dc:creator>
      <dc:date>2020-01-09T15:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480254#M134597</link>
      <description>&lt;P&gt;Hi, sorry for late reply. I tried this but it isn't helping. I still get duplicate "Seconds".&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 15:43:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480254#M134597</guid>
      <dc:creator>siddharth1479</dc:creator>
      <dc:date>2020-01-13T15:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480255#M134598</link>
      <description>&lt;P&gt;Hi, sorry for late reply. I tried this but it isn't helping. I still get duplicate "Seconds".&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 15:43:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480255#M134598</guid>
      <dc:creator>siddharth1479</dc:creator>
      <dc:date>2020-01-13T15:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480256#M134599</link>
      <description>&lt;P&gt;index="uam" User="abcd" &lt;BR /&gt;
| eval access_time=strftime(_time, "%Y-%d-%m %H:%M:%S") &lt;BR /&gt;
| fields "USER" "TIME"&lt;BR /&gt;
| dedup "USER","TIME"&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480256#M134599</guid>
      <dc:creator>heissenberg</dc:creator>
      <dc:date>2020-09-30T03:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480257#M134600</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Maybe you can try to dedup using a stringconcat on user and time fields? &lt;/P&gt;

&lt;P&gt;Something like:&lt;/P&gt;

&lt;P&gt;index="uam" User="abcd" &lt;BR /&gt;
  | eval access_time=strftime(_time, "%Y-%d-%m %H:%M:%S")&lt;BR /&gt;
  | rename access_time as TIME&lt;BR /&gt;
  | eval key=tostring(TIME)+tostring(User)&lt;BR /&gt;
  | dedup key&lt;BR /&gt;
  | table User, TIME&lt;/P&gt;

&lt;P&gt;Kind regards,&lt;BR /&gt;
Willem Jongeneel&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480257#M134600</guid>
      <dc:creator>willemjongeneel</dc:creator>
      <dc:date>2020-09-30T03:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480258#M134601</link>
      <description>&lt;P&gt;@siddharth1479 &lt;BR /&gt;
&lt;CODE&gt;|stats values(User) as USER by access_time&lt;/CODE&gt;&lt;BR /&gt;
This will be aggregated by the access_time string.&lt;BR /&gt;
Are they really duplicates?&lt;BR /&gt;
Please show me the results.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 16:50:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480258#M134601</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-13T16:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480259#M134602</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
|eval _raw="USER,TIME
abcd ,2020-06-01 08:58:51
abcd ,2020-06-01 08:58:51
abcd ,2020-06-01 08:58:51

abcd ,2020-06-01 09:32:27
abcd ,2020-06-01 09:32:27
abcd ,2020-06-01 09:32:27"
| multikv forceheader=1
| rename COMMENT as "your result"
| table USER,TIME
| stats values(USER) as USER by TIME
| table USER,TIME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is OK.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 16:58:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480259#M134602</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-13T16:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480260#M134603</link>
      <description>&lt;P&gt;@siddharth1479 Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="uam" User="abcd" | eval access_time=strftime(_time, "%Y-%d-%m %H:%M:%S") | rename access_time as TIME|fields "USER" "TIME"| dedup USER TIME
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jan 2020 17:18:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480260#M134603</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2020-01-13T17:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480261#M134604</link>
      <description>&lt;P&gt;Then change your time format to something less granular &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 22:13:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480261#M134604</guid>
      <dc:creator>wmyersas</dc:creator>
      <dc:date>2020-01-13T22:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480262#M134605</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks for the help. Seems to be working with this logic and also made some changes to the logs itself to uniquely identify each entry only once.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 16:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480262#M134605</guid>
      <dc:creator>siddharth1479</dc:creator>
      <dc:date>2020-01-14T16:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480263#M134606</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I think you need to rename the access_time as TIME, and yes dedup logic seems to be working.&lt;/P&gt;

&lt;P&gt;Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 16:57:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480263#M134606</guid>
      <dc:creator>siddharth1479</dc:creator>
      <dc:date>2020-01-14T16:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Search query: Unique values based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480264#M134607</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks for the help. Dedup logic seems to be working.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 16:58:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-Unique-values-based-on-time/m-p/480264#M134607</guid>
      <dc:creator>siddharth1479</dc:creator>
      <dc:date>2020-01-14T16:58:34Z</dc:date>
    </item>
  </channel>
</rss>

