Splunk Search

How to display percent in a stacked bar chart?

jip31
Motivator

hi

I try to display percent in my bar chart like this but it doesnt works

 

| chart count as total over sig_application by sig_transaction 
| eval total=0 
| foreach count* 
    [ eval total=total + <<FIELD>>] 
| foreach count* 
    [ eval <<FIELD>>=round((<<FIELD>>/total)*100,1)] 
| fields - total

 

is anybody can help please?

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| chart count as total over sig_application by sig_transaction 
| rename * as count*
| rename countsig_transaction as sig_transaction
| addtotals fieldname=total count* 
| foreach count* 
    [ eval <<FIELD>>=round((<<FIELD>>/total)*100,1)] 
| fields - total

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What fields do you get from 

| chart count as total over sig_application by sig_transaction
0 Karma

jip31
Motivator

what do you mean exactly?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What are the fields/column called?

Your foreach count* assumes that that they all start with count?

0 Karma

jip31
Motivator

you are right

it's not the case...

it miss | rename * as count*

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| chart count as total over sig_application by sig_transaction 
| rename * as count*
| rename countsig_transaction as sig_transaction
| addtotals fieldname=total count* 
| foreach count* 
    [ eval <<FIELD>>=round((<<FIELD>>/total)*100,1)] 
| fields - total
0 Karma

jip31
Motivator

thanks to your help but i think its not a good idea to use it because its not really explicit in my chart

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So you also have a column called countsig_transaction?

0 Karma

jip31
Motivator

I just have a column countsig_app

0 Karma
Get Updates on the Splunk Community!

Observability | How to Think About Instrumentation Overhead (White Paper)

Novice observability practitioners are often overly obsessed with performance. They might approach ...

Cloud Platform | Get Resiliency in the Cloud Event (Register Now!)

IDC Report: Enterprises Gain Higher Efficiency and Resiliency With Migration to Cloud  Today many enterprises ...

The Great Resilience Quest: 10th Leaderboard Update

The tenth leaderboard update (11.23-12.05) for The Great Resilience Quest is out &gt;&gt; As our brave ...