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!

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...