Splunk Search

How to write a query to show the top performer (Single Value)?

ranjitbrhm1
Communicator

Hello All, I want to write something that shows a single value with the below data
Customer M 5 Units
Customer N 15 Units
Customer O 52 Units
Customer P 54 Units
Customer W 522 Units
Customer Q 51 Units

I want to see who is my biggest customer here. Obviously my biggest customer is W. But is there a way where i can show the biggest customer name on my dashboard? Like Biggest customer - "Customer W" I dont need to know any other details, Just the biggest customer name.
Thanks

Tags (2)
0 Karma
1 Solution

niketn
Legend

@ranjitbrhm1, you can sort Units in descending order and then retain only the first row. Then save the search with Single Value visualization on your dashboard. If you are on Splunk Enterprise 6.6. or higher and want to show top 5 Customers you can retain | head 5 and use Single Value with Trellis Layout to show all 5 customers.

<yourCurrentSearch>
| sort - Units
| head 1

Following is a run anywhere example based on your sample data:

| makeresults
| eval data="Customer=M,Units=5;Customer=N,Units=15;Customer=O,Units=52;Customer=P,Units=54;Customer=W,Units=522;Customer=Q,Units=51"
| makemv data delim=";"
| mvexpand data
| rename data as _raw
| KV
| table Customer Units
| sort - Units
| head 1

PS: You can also try out Status Indicator Custom Visualization for Similar output as Single Value.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@ranjitbrhm1, you can sort Units in descending order and then retain only the first row. Then save the search with Single Value visualization on your dashboard. If you are on Splunk Enterprise 6.6. or higher and want to show top 5 Customers you can retain | head 5 and use Single Value with Trellis Layout to show all 5 customers.

<yourCurrentSearch>
| sort - Units
| head 1

Following is a run anywhere example based on your sample data:

| makeresults
| eval data="Customer=M,Units=5;Customer=N,Units=15;Customer=O,Units=52;Customer=P,Units=54;Customer=W,Units=522;Customer=Q,Units=51"
| makemv data delim=";"
| mvexpand data
| rename data as _raw
| KV
| table Customer Units
| sort - Units
| head 1

PS: You can also try out Status Indicator Custom Visualization for Similar output as Single Value.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...