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!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...