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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...