Splunk Search

How to determine that a field value is "new" on a given day

JohnR
Engager

I have a search that displays unique users per day (based on a "user id" field). I also would like another search that displays "new" unique users per day, looking back to some fixed date. I suspect maybe I need a sub-search using "earliest" and "latest", but I don't know how to put it together.

Labels (1)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

Try and see 🙂

But at first glance seems OK (if you correct the field names - in one step you're calling the field userid, in next one you're sorting by uid)

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

You mean you want to find users which in a given day logged in but have never logged in before?

<your search>
| timechart span=1d values(userid) as users
| expandmv users
| stats earliest(_time) as _time by users

 Something like that.

0 Karma

JohnR
Engager

Thanks. If I just wanted a count of new users per day, would this work...

| bin _time span=1d
| stats earliest(_time) as _time by userid
| stats dc(uid) by _time
| sort _time

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Try and see 🙂

But at first glance seems OK (if you correct the field names - in one step you're calling the field userid, in next one you're sorting by uid)

0 Karma

somesoni2
Revered Legend

Try something like this

index=foo sourcetype=bar earliest=-14d latest=now
| eval period=if(_time>=relative_time(now(),"@d"), "Today","Older")
| stats values(period) as periods by user_id
| where mvcount(periods)=1 AND periods="Today"
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!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

Ready to make your IT operations smarter and more efficient? Discover how to automate Splunk alerts with Red ...