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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...