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
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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...