Splunk Search

Limiting precision/decimal

pramodkumar
Path Finder

Hi,
Have scenario, when using avg() am getting values as 15.000000 but i want it as 15 without decimal, please help me.

Tags (3)
0 Karma
1 Solution

sdaniels
Splunk Employee
Splunk Employee

Use eval and the round() function.

<your search> |stats avg(whatever) as yourNumber | eval n=round(yourNumber)

http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/CommonEvalFunctions

View solution in original post

sdaniels
Splunk Employee
Splunk Employee

Use eval and the round() function.

<your search> |stats avg(whatever) as yourNumber | eval n=round(yourNumber)

http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/CommonEvalFunctions

sdaniels
Splunk Employee
Splunk Employee

This is probably better as a separate question with specific details. You can include this link to let people know you've already done some homework. Maybe you could create a macro where you pass in the values you want to round, in order to simplify the length of your search. Is the length and complexity of the search a concern?

0 Karma

sbsbb
Builder

yes but if you are making a "| chart avg(smthing) over somethingelse by something " then you have to eval each column explicitly, for me it is not possible, there must be a better way

0 Karma
Get Updates on the Splunk Community!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...