Splunk Search

Pie Chart Query

hhopkins
Engager

I have created pie charts with data like this:
index=default counter=10 color=blue
index=default counter=5 color=green
index=default counter=2 color=red

My pie chart query would be:
index=default | stats sum(counter) by color

That works fine, but what if I want the same result but my data looks like this?
index=default bluecounter=10 greencounter=5 redcounter=2

I can't figure out how to make the stats query to show the same breakdown by color.

Tags (3)
0 Karma

Kate_Lawrence-G
Contributor

Hi,

The way you have it now you can't report by color since color (and counter) aren't really defined anymore.

If your stuck with the data in that format you would have to do a rex and pull out the field manually

(*note that is written for _raw and will be different if *counter are actually defined fields - more on rex here)

rex (?"(\w+)counter" | rex
(?="(\d+)" | stats
sum(counter) by color

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...