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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...