Splunk Search

How to combine a set of values as 'Other' in a pie chart?

spamphile
Engager

I'm trying to display a pie chart like so:

chart count by transaction.inputSource | lookup transaction_input_sources code AS transaction.inputSource OUTPUT transaction_input_source AS transaction.inputSource

There are only 5 input sources I really care about in the pie chart. The other input sources I would like to combine and just show as one "Other" slice. In my lookup table, I've named the input sources I don't care about as "Other". But now when the chart renders, it shows each of those values as its own slice:

alt text

How do I combine these values as one slice in the pie chart? Any help is greatly appreciated. Thanks!

0 Karma
1 Solution

amitm05
Builder

You'd have to combine the remaining input sources (which you want to show as Other) as one and then apply your stats function on it. That will solve it for you.

E.g. Lets say you have input_source values as - A, B, C, D, E, F, G, H.
You want A, B, C, D, E to reflect as they are and remaining F, G, H as Other.
You need to do an eval before your stats command which would combine F, G, H in one. Something like -
....... | eval input_source = case(input_source == "F", "Other", input_source == "G", "Other", input_source == "H", "Other", 1==1, input_source ) | stats ...

Basically, with above eval, your input_source will now have the values as - A, B, C, D, E, Other.
So when you do a stats like -
| stats count by input_source

This would create your Pie Chart with your 5 required input sources and combine the rest in "Other".

Hope this helps.
Please accept this as an answer if it resolves your problem.

View solution in original post

amitm05
Builder

You'd have to combine the remaining input sources (which you want to show as Other) as one and then apply your stats function on it. That will solve it for you.

E.g. Lets say you have input_source values as - A, B, C, D, E, F, G, H.
You want A, B, C, D, E to reflect as they are and remaining F, G, H as Other.
You need to do an eval before your stats command which would combine F, G, H in one. Something like -
....... | eval input_source = case(input_source == "F", "Other", input_source == "G", "Other", input_source == "H", "Other", 1==1, input_source ) | stats ...

Basically, with above eval, your input_source will now have the values as - A, B, C, D, E, Other.
So when you do a stats like -
| stats count by input_source

This would create your Pie Chart with your 5 required input sources and combine the rest in "Other".

Hope this helps.
Please accept this as an answer if it resolves your problem.

spamphile
Engager

Thanks so much

0 Karma
Get Updates on the Splunk Community!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...