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!

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 ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

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 ...