Splunk Search

How get a count of last Status

t_splunk_d
Path Finder

I trying figure out what is the best search query for reporting on the count of different unique status.
Following is the records:
ID NAME STATUS LASTUPDATEDTIME
1 Group1 Started 12:15
1 Group1 Processing 12:30
1 Group1 Transfering 12:45
1 Group1 Completed 1:06
2 Group1 Started 12:17
2 Group1 Processing 12:32
2 Group1 Transfering 12:46
3 Group1 Started 12:55

When I try | stats count by STATUS - it does give me the correct numbers.
I am looking for the result:

Started - 1
Completed - 1
Transferring - 1

I want to report count of last Status.

Thank you.

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi
let me better understand your request:
each ID can have different status and you want to count only the occurrences of last status of each ID, correct?
If this is your request try something like this:

your_search 
| stats latest(STATUS) AS STATUS by ID 
| stats count by STATUS

Bye.
Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi
let me better understand your request:
each ID can have different status and you want to count only the occurrences of last status of each ID, correct?
If this is your request try something like this:

your_search 
| stats latest(STATUS) AS STATUS by ID 
| stats count by STATUS

Bye.
Giuseppe

niketn
Legend

@t_splunk_d, | stats count by STATUS should be best way of finding count based on different unique status. Is there any issue that you are facing when you run this command?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

adonio
Ultra Champion

count of last status will always give you 1 if i understand the question correctly...
try the following, considering ID field is ID:
... |stats lastest(STATUS) by ID
hope it helps

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...