Splunk Search

How do I create a search that displays Host, Total Event Count, Latest Event, and Earliest Event?

JoshuaJ
New Member

When I first log in to Splunk, one of the first things I see is called "Data Summary" (under what to search) which displays the host, total number of events indexed, earliest event, and the latest event from each host. I'm trying the recreate this table with very little success so hopefully you can help me out.

So far I have this:
* | stats count by host | sort by -count

This gives me a table with the host and total event count in descending order, but I can't figure out how to display the earliest and latest events. Any ideas? Thanks.

Tags (4)
0 Karma

lguinn2
Legend

Splunk uses the metadata command to produce the Data Summary. Try this

| metadata type=hosts
| fields host firstTime lastTime totalCount
| sort -totalCount
| fieldformat firstTime=strftime(firstTime,"%x %X")
| fieldformat lastTime=strftime(lastTime,"%x %X")

This will be much, much faster than using stats.

Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

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

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...