Splunk Search

show unique values from yesterday

splunkapprentic
Explorer

Hello, please help!
I want to display only the unique names from yesterday that are not in today's list

Initial search:

Date Name Value
09/18/2016 ABC 2
09/18/2016 XYZ 9
09/18/2016 EFG 8
09/19/2016 ABC 3

Final search:

Date Name Value
09/18/2016 XYZ 9
09/18/2016 EFG 8

0 Karma
1 Solution

sundareshr
Legend

Try this

index=xyz  earliest=-1d@d | eval Date=strftime(_time, "%m/%d/%Y") | eval when=if(_time>relative_time(now(), "@d"), "Today", "Yesterday") | dedup Name Date | eval Value=Value."#".Date | chart values(Value) as Value over Name by when | where isnull(Today) AND isnotnuill(Yesterday) | table Name Yesterday | rex field=Value "(?<Value>[^\#]+)\#(?<Date>.*)" | table Date Name Value

*UPDATED*

BASE SEARCH | eval when=if(strptime(Date, "%m/%d/%Y")>relative_time(now(), "@d"), "Today", "Yesterday") | dedup Name Date | eval Value=Value."#".Date | chart values(Value) as Value over Name by when | where isnull(Today) AND isnotnuill(Yesterday) | table Name Yesterday | rex field=Value "(?[^\#]+)\#(?.*)" | table Date Name Value

OR THIS*

base search | sort - Date | dedup Name | where strptime(Date, "%m/%d/%Y")<relative_time(now(), "@d")) 

View solution in original post

0 Karma

somesoni2
Revered Legend

Assuming that you've a working search giving you your initial output, try this

your current search giving fields  Date Name Value | stats Values(Date) as Date values(Value) as Value by Name | where mvcount(Date)=1 AND strptime(Date, "%m/%d/%Y")>relative_time(now(), "@d")
0 Karma

sundareshr
Legend

Try this

index=xyz  earliest=-1d@d | eval Date=strftime(_time, "%m/%d/%Y") | eval when=if(_time>relative_time(now(), "@d"), "Today", "Yesterday") | dedup Name Date | eval Value=Value."#".Date | chart values(Value) as Value over Name by when | where isnull(Today) AND isnotnuill(Yesterday) | table Name Yesterday | rex field=Value "(?<Value>[^\#]+)\#(?<Date>.*)" | table Date Name Value

*UPDATED*

BASE SEARCH | eval when=if(strptime(Date, "%m/%d/%Y")>relative_time(now(), "@d"), "Today", "Yesterday") | dedup Name Date | eval Value=Value."#".Date | chart values(Value) as Value over Name by when | where isnull(Today) AND isnotnuill(Yesterday) | table Name Yesterday | rex field=Value "(?[^\#]+)\#(?.*)" | table Date Name Value

OR THIS*

base search | sort - Date | dedup Name | where strptime(Date, "%m/%d/%Y")<relative_time(now(), "@d")) 
0 Karma

splunkapprentic
Explorer

I don't think I have the _time records 😞

0 Karma

splunkapprentic
Explorer

yeah! the last one seems to do the job 😉

0 Karma

sundareshr
Legend

@splunkapprentice please accept this answer to close it out.

0 Karma

sundareshr
Legend

Try the updated query

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...