Splunk Search

How to show only certain values in a chart

acontarciego
Explorer

I have a search that get code values:
How can I show only the count of 4 values in a chart and have the rest reported as "OTHER".

Tags (1)
0 Karma

Ayn
Legend
... | top 4 yourfield useother=t
0 Karma

acontarciego
Explorer

One more twist. How do I show this in a time chart?

0 Karma

Ayn
Legend

Ah, that's a bit trickier. This is the solution I can think of right now - possibly there's a 'neater' solution, but if there is one I'll have to sleep on it. 🙂

... | stats count(eval(yourfield=="value1")) as value1, count(eval(yourfield=="value2")) as value2, count(eval(yourfield=="value3")) as value3, count(eval(yourfield=="value4")) as value4, count(eval(match(yourfield,"value1|value2|value3|value4"))) as OTHER | transpose
0 Karma

acontarciego
Explorer

Thanks, Ayn.
That works if I want the top 4 values. I forgot to mention that the 4 values I want will not necessarily by the top 4 by count.

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!

How much can you really learn in 3 minutes?

Observability can certainly be hard to understand – there's a lot of jargon and buzzwords and it seems to ...

Event Series: The Agentic SOC: Trust Before Autonomy

AI is fundamentally changing security operations, but true progress requires more than just automation—it ...

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...