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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...