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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...