Dashboards & Visualizations

Filler gauge not displaying percentage properly

yumology
Path Finder

My raw data:

Filesystem                                Type              Size        Used       Avail      UsePct    MountedOn
/dev/xvda                                 ext3               16G        2.3G         13G         16%    /
/dev                                      devtmpfs          249M        4.0K        249M          1%    /dev

My search:

host="server1" source="df" | gauge usedPct

My results:

x
16%

Upon trying to chart this in any gauge format it displays as 0. Do I need to somehow convert this "16%" to just "16" in order for the gauge to work? Perhaps it thinks it's a string, how would I convert it to an integer? "gauge tonumber(usedPct)" does not return results...

Tags (1)
0 Karma
1 Solution

sdaniels
Splunk Employee
Splunk Employee

Yes, gauge is expecting a number. I think you could use 'trim' to get rid of the '%' and then convert it to a number.

... | eval myString = trim(usedPct, "%") | eval myNum = tonumber(myString) | gauge myNum

View solution in original post

sdaniels
Splunk Employee
Splunk Employee

Yes, gauge is expecting a number. I think you could use 'trim' to get rid of the '%' and then convert it to a number.

... | eval myString = trim(usedPct, "%") | eval myNum = tonumber(myString) | gauge myNum

Lazarix
Communicator

I know this is old, but a shorter way to do this is:
host="server1" source="df" usedPct | eval usedPct = trim(usedPct, "%")

This will allow you to keep the original column, just reformatted without percent, rather than creating a new field called "myString"

0 Karma

yumology
Path Finder

Worked like a charm! Thanks!

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