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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...