Splunk Search

How To Count A Field In 3 New Fields And Table Them Together?

vtsguerrero
Contributor

I have a field called "Status" and I wanna count when Status=P, when Status=I, when Status=E and then use the command | table _time, P, I, E
In my database they're all just one field, I kinda have to create 3 new fields splitting'em...
Thanks in advance!

Tags (4)
0 Karma
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi vtsguerrero,

take this run everywhere example and adapt it to your needs:

index=_internal | stats count(eval(like(sourcetype, "splunkd"))) AS P count(eval(like(sourcetype, "%web%"))) AS I

This will count sourcetype="splunkd" as P and sourcetype="*web*" as I. So if you use this on the Status field in your case.

hope this helps to get you started ...

cheers, MuS

View solution in original post

vtsguerrero
Contributor

The result table should be something like this:

| table _time, Channel, Code, StatusP, StatusI, StatusE

but the Status field in my database is only one field. I need to count and store'em individually

0 Karma

MuS
SplunkTrust
SplunkTrust

Hi vtsguerrero,

take this run everywhere example and adapt it to your needs:

index=_internal | stats count(eval(like(sourcetype, "splunkd"))) AS P count(eval(like(sourcetype, "%web%"))) AS I

This will count sourcetype="splunkd" as P and sourcetype="*web*" as I. So if you use this on the Status field in your case.

hope this helps to get you started ...

cheers, MuS

vtsguerrero
Contributor

Thanks a lot @MuS !

I knew how to the count, but for only one field, first time I use three fields at once, worked liked a charm! Tks!

0 Karma

vtsguerrero
Contributor

Forgot to mention that I may have other fields in my table grid query....

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...