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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...