Splunk Search

How do I remove 2 decimal places from values returned in a search?

splunksurekha
Path Finder

When I run the search below, I get correct results without any decimal value in it.

`linux-cpu` | search application=sc10_LMS host=* sub_module=* | stats max(pctLoad) AS pctLoad by host sub_module application | eval Health=if(pctLoad < 50,1,0) | eval Warn=if(pctLoad>= 50 AND pctLoad <80,1,0) | eval Crit=if(pctLoad>=80,1,0) | stats  sum(Crit) as Critical sum(Warn) as Warning sum(Health) as Healthy dc(host) as Total by sub_module | sort - Critical Warning

sub_module  Critical    Warning     Healthy     Total
sc10_LMS_A      4          4         12         20 

But when I put the same search in my dashboard which takes arguments from the drop-down like below, it gives me a result with decimal values only for Critical and Warning. How can I get rid of this decimal value?

`linux-cpu` | search application=$application$ host=$host$ sub_module=$submodule$ | stats $function$(pctLoad) AS pctLoad by host sub_module application | eval Health=if(pctLoad < 50,1,0) | eval Warn=if(pctLoad>= 50 AND pctLoad <80,1,0) | eval Crit=if(pctLoad>=80,1,0) | stats  sum(Crit) as Critical sum(Warn) as Warning sum(Health) as Healthy dc(host) as Total by sub_module | sort - Critical Warning

sub_module  Critical    Warning     Healthy     Total
sc10_LMS_A       4.00        4.00      12         20
Tags (1)

richgalloway
SplunkTrust
SplunkTrust

Try this

... | stats ... | eval Critical=round(Critical,0) | eval Warning=round(Warning,0) | sort ...
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

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 GA in US-AWS!

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