Dashboards & Visualizations

Splunk Chart - Percentage

chrisludke
Engager

Looking for assistance in adding a percentage to an existing chart result. I have the following Splunk search that is able to chart the maximum value found of ValueA and ValueB and chart by hosts. ValueA  is the maximum count found (lets say total number of objects). ValueB is the maximum observed usage of ValueA. I do not use a bin or time reference directly in the search, rather using Splunk's pre-build time reference on-demand (Example , "last 24 hours" when executing the search)

index=indextype  sourcetype=sourcetype  "search_string"  |  chart  max(valueA)  max(valueB)  by  host

Labels (1)
0 Karma
1 Solution

livehybrid
SplunkTrust
SplunkTrust

Hi @chrisludke 

Try the following to eval a percentage, note that Ive named the field on the stats so it is easier to reference. 

| stats max(valueA) as max_valueA, max(valueB) as max_valueB by host 
| eval percentage = round((max_valueB / max_valueA) * 100, 2) 
| table host, max_valueA, max_valueB, percentage

 

Here is a sample query:

| makeresults 
| eval valueA=1000, valueB=932, host="Test"
| stats max(valueA) as max_valueA, max(valueB) as max_valueB by host 
| eval percentage = round((max_valueB / max_valueA) * 100, 2) 
| table host, max_valueA, max_valueB, percentage

livehybrid_0-1747146955151.png

 

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

View solution in original post

0 Karma

chrisludke
Engager

Worked perfectly. Exactly what I needed. Thanks so much for your quick response!

0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @chrisludke 

Try the following to eval a percentage, note that Ive named the field on the stats so it is easier to reference. 

| stats max(valueA) as max_valueA, max(valueB) as max_valueB by host 
| eval percentage = round((max_valueB / max_valueA) * 100, 2) 
| table host, max_valueA, max_valueB, percentage

 

Here is a sample query:

| makeresults 
| eval valueA=1000, valueB=932, host="Test"
| stats max(valueA) as max_valueA, max(valueB) as max_valueB by host 
| eval percentage = round((max_valueB / max_valueA) * 100, 2) 
| table host, max_valueA, max_valueB, percentage

livehybrid_0-1747146955151.png

 

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...