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

 

Labels (1)
Tags (2)
0 Karma
1 Solution

gcusello
Legend

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
Legend

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!

Improve Your Security Posture

Watch NowImprove Your Security PostureCustomers are at the center of everything we do at Splunk and security ...

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...