Splunk Search

How to write a search to list the count of the number of times an ID appears and the timestamp it was last found?

albyva
Communicator

How can I get splunk to count the number of times an ID appears and to list the last date it was found?

Splunk Data:

Jan 19 21:35:27 score="9.3", ip=192.168.2.1, id=123, name="blahblah1"
Jan 19 21:35:28 score="1.0", ip=192.168.2.2, id=456, name="blahblah2"
Jan 19 21:35:29 score="2.5", ip=192.168.2.3, id=789, name="blahblah3"
Jan 19 21:35:30 score="9.3", ip=192.168.2.4, id=123, name="blahblah1"

What I want to see is an output that looks like:

COUNT ID   NAME      SCORE  DATE
-------------------------------------------
2     123  blahblah1  9.3   Jan 19 21:35:30    (note the last date)
1     456  blahblah2  1.0   Jan 19 21:35:28
1     789  blahblah3  2.5   Jan 19 21:35:29

What I've been doing is running:

searchstring | stats count by id name score

and that gets me most of what I need, but I can't seem to incorporate the latest Date without it screwing up everything.
Any suggestions?

Thanks,

0 Karma
1 Solution

albyva
Communicator

I figured it out.

searchstring | stats count latest(_time) as LastHit by id, name, score | convert ctime(LastHit)

View solution in original post

albyva
Communicator

I figured it out.

searchstring | stats count latest(_time) as LastHit by id, name, score | convert ctime(LastHit)

Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...