Splunk Search

How to get values from a Splunk field to particular decimals?

Poojitha
Communicator

Hi Team,

I have a field like below :

Cost :
0.4565534553453
0.0000435463466
0.0021345667788
0.0000000005657

I want to get values from this cost field which has value till 4 decimals i.e only 0.4565534553453 and 0.0021345667788. 

How can I achieve this in my splunk query. Please can anyone help me .

Regards,
NVP


Labels (3)
0 Karma

harishalipaka
Motivator

@Poojitha 

| makeresults| eval Cost="0.4565534553453" | table Cost
| append [ | makeresults| eval Cost="0.0000435463466" | table Cost]
| append [| makeresults| eval Cost="0.0021345667788" | table Cost ]
| append [ | makeresults| eval Cost="0.0000000005657" | table Cost ]
 | rex field=Cost "(?<Cost_New>\d+\.\d{4})" |where Cost_New > 0 |table Cost
Thanks
Harish
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Your example is inconsistent with your description.

Rounding a value to 4 decimal digits is one thing but your description suggests that you simply want to filter out values that not smaller than 0.0001

0 Karma

JacekF
Path Finder

Try something like that:
| eval cost_rounded = round(Cost, 4)
| where cost_rounded > 0

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=Cost "(?<truncated_cost>\d+\.\d{4})"
0 Karma
Get Updates on the Splunk Community!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...