Splunk Search

How to count valuse and display againts another field?

Matrix20085
Explorer

Sorry, I am unsure how to describe what I am looking for using Splunk terminology, and I am sure that is why I am having trouble finding the answer.

What I am looking for:

User    |  Status   | coun
---------------------------------
Mike   |   True       |    2
            |   False      |    1
--------------------------------
Loagn |  True      |    4
             |   False    |    2

 

So far my search looks like this:

index=logs EventType="logon"
| stats values(Status) as Status count by User



It is almost there, but in the count column, it combines the count for True and False and only gives a single number.

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Each row is an event with various fields - if you want to combine the results events by User, try something like this:

index=logs EventType="logon"
| stats count by User Status
| stats list(Status) as Status list(count) as count by User

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
index=logs EventType="logon"
| stats count by User Status
0 Karma

Matrix20085
Explorer

This is where I started, but it lists the User for each Status they have. I was hoping to have the user listed once with all of their different statues next to them.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Each row is an event with various fields - if you want to combine the results events by User, try something like this:

index=logs EventType="logon"
| stats count by User Status
| stats list(Status) as Status list(count) as count by User

Matrix20085
Explorer

Nailed it! Thanks so much.

0 Karma
Get Updates on the Splunk Community!

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureThursday, March 27, 2025  |  11AM PST / 2PM EST | Register NowStep boldly ...

Splunk AppDynamics with Cisco Secure Application

Web applications unfortunately present a target rich environment for security vulnerabilities and attacks. ...