Splunk Search

How to take precision of decimal point for a particular field?

microsac
Explorer

Hello experts,

I Just want my field `snow_os_version`  to be up to 2 decimal points like the first entry should only be  `3.10`, How to achieve that.

microsac_0-1648557195397.png

 

Tags (2)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @microsac,

it depends on the valuer in SNOW, if you're sure that the format is always "nn.nn", you could use a regex like this:

| rex field=snow_os_version "^(?<snow_os_version>\d+\.(\d|(\d\d)))"

Ciao.

Giuseppe

View solution in original post

microsac
Explorer

Hi @gcusello ..

I tried something similar  rex field=snow_os_version "(?<os_version>\d+\.\d{1})"  but it only upto 1 decimal number like `3.1` i need it to take like `3.10`

0 Karma

somesoni2
Revered Legend

Try like this

Your current search
| eval snow_os_version=replace(snow_os_version,"^(\d+\.\d+).*","\1")

gcusello
SplunkTrust
SplunkTrust

Hi @microsac,

it depends on the valuer in SNOW, if you're sure that the format is always "nn.nn", you could use a regex like this:

| rex field=snow_os_version "^(?<snow_os_version>\d+\.(\d|(\d\d)))"

Ciao.

Giuseppe

Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

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 ...