Splunk Search

Can you help me with a query that uses the stats command?

andreiraduta
New Member

Hello,

I have a list of users and the time they entered a building.
I'm trying to find the earliest + latest time.

This is the code that i have:

host="myhost" 
| table first_name last_name qr_code created_date date_mday  

| sort by date_mday
| dedup qr_code 

| stats earliest(created_date)  as created_date

the stats line breaks my code.

Any suggestions or hints?

Thank you

Tags (2)
0 Karma

Sukisen1981
Champion

Try something like this -

host="myhost" 
| dedup qr_code
|eventstats earliest(created_date) as created_date
| table first_name last_name qr_code created_date date_mday
| sort by date_mday

Remember, Splunk treats time as numbers. Depending on how your created_date field, looks like you may have to convert epoch/unix times.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...