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!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...