Reporting

rounding numbers in splunk

a212830
Champion

Hi,

I have some search output that is 6 decimal places in the table output. I don't want any decimal places. How do I remove these?

Search is:

index=coreops sourcetype="snmp_stats" HOST=IVE* |stats avg(CONNECTIONS) as CONNECTIONS, avg(MEM) as MEM, avg(CPU) as CPU by HOST |sort - num(CONNECTIONS)

Tags (2)
1 Solution

emiller42
Motivator

You can simply use a fieldformat command to change how the number is displayed without actually changing the content.

index=coreops sourcetype="snmp_stats" HOST=IVE* |stats avg(CONNECTIONS) as CONNECTIONS, avg(MEM) as MEM, avg(CPU) as CPU  by HOST | fieldformat CONNECTIONS=round(CONNECTIONS, 2) | fieldformat MEM=round(MEM, 2) | fieldformat CPU=round(CPU, 2) | sort - num(CONNECTIONS)

Fieldformat documentation

View solution in original post

emiller42
Motivator

You can simply use a fieldformat command to change how the number is displayed without actually changing the content.

index=coreops sourcetype="snmp_stats" HOST=IVE* |stats avg(CONNECTIONS) as CONNECTIONS, avg(MEM) as MEM, avg(CPU) as CPU  by HOST | fieldformat CONNECTIONS=round(CONNECTIONS, 2) | fieldformat MEM=round(MEM, 2) | fieldformat CPU=round(CPU, 2) | sort - num(CONNECTIONS)

Fieldformat documentation

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