Dashboards & Visualizations

help for formatting a pie chart

jip31
Motivator

Hi

I use the search below in order to display the data in a pie chart

| inputlookup host.csv 
| lookup PanaBatteryStatus.csv "Hostname00" as host OUTPUT BatteryTemp00 
| where BatteryTemp00 > 30 
| stats count as NbHostBattSup30
| appendcols 
    [| inputlookup host.csv 
    | stats count as NbIndHost] 
| eval NbHostBattInf30 = (NbIndHost - NbHostBattSup30) 
| eval NbHostBattSup30=NbHostBattSup30, NbHostBattInf30=NbHostBattInf30 
| table NbHostBattSup30 NbHostBattInf30
| transpose

I would like to just display one decimal
So I do this but it doesn't works

    | eval NbHostBattSup30=round(NbHostBattSup30, 1), NbHostBattInf30=round(NbHostBattInf30, 1)

I would also have the result in bold and to display the integer value in addition to the percentage
could you help me please??

0 Karma
1 Solution

Sukisen1981
Champion

Try this on your default _audit index.
Copy paste this code and run

index="_audit" 
| stats count by info
| eventstats sum(count) as count1
| eval perc=round(count*100/count1,1)
| eval info=info+"-"+"count:"+count+","+"percentage:"+perc
| fields info,perc

View solution in original post

0 Karma

woodcock
Esteemed Legend

Try this:

| inputlookup host.csv 
| lookup PanaBatteryStatus.csv "Hostname00" as host OUTPUT BatteryTemp00 
| where BatteryTemp00 > 30 
| stats count as NbHostBattSup30
| appendcols 
[| inputlookup host.csv 
| stats count as NbIndHost] 
| eval NbHostBattInf30 = (NbIndHost - NbHostBattSup30) 
| eval NbHostBattSup30=NbHostBattSup30, NbHostBattInf30=NbHostBattInf30 
| table NbHostBattSup30 NbHostBattInf30 
| untable foo key value
| fields - foo
0 Karma

jip31
Motivator

hi
with this, I have any percentage...

0 Karma

woodcock
Esteemed Legend

More words.

0 Karma

Sukisen1981
Champion

Try this on your default _audit index.
Copy paste this code and run

index="_audit" 
| stats count by info
| eventstats sum(count) as count1
| eval perc=round(count*100/count1,1)
| eval info=info+"-"+"count:"+count+","+"percentage:"+perc
| fields info,perc
0 Karma

jip31
Motivator

I have no right on this index and I try to adapt your code in mine but it doesnt works...

0 Karma

woodcock
Esteemed Legend

Did you mean to click Answer? It doesn't really make sense to, if you cannot test it.

0 Karma

Sukisen1981
Champion

Hi @jip31 - Can you not install the free splunk enterprise on your local and try out the above code?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...