Splunk Search

Convert table (stats output) to fields for eval?

batzel
Engager

How can I take table output like the above and convert it into key=value pairs, so I can eval them further?

I came up with a different way to do what I needed, but am still pondering the dead-end I reached before that.

Say I have data like:
id=0001 status=class1
id=0002 status=classb
id=0003 status=classb
id=f3e9 status=foo

I do: | stats distinct_count(id) as C by status

Now I have a table:
status C
class1 1
classb 2
foo 1

How can I take table output like the above and convert it into key=value pairs, so I can eval them further? Say, I want to know the ratio of class1 to classb. That is, I want to know (class1's value) / (classb's value).

Tags (2)
0 Karma

jonuwz
Influencer

try something like this :

... | eval series="dummy" | chart limit=0 distinct_count(id) as C over series by status | fields - series

If you have a genuine series (like _time) you can just use "over _time" instead of using "eval series="dummy " and "by series"

i.e.

... | chart limit=0 distinct_count(id) as C over _time by status
0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...