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!

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...