Splunk Search

How to convert version number so the dots are consistent

splunkyj
Path Finder

See the example values below. How do I convert the value of the version field, so that they have the same number of decimals?

version=7.3.2

version=8.0.2.1

I would like this to be converted to:

version=7.3.2.0

version=8.0.2.1

Labels (2)
0 Karma
1 Solution

to4kawa
Ultra Champion
| makeresults 
| eval version="7.3.2" | appendpipe [| eval version="8.0.2.1" |appendpipe [eval version="7.2"|appendpipe [eval version="7"]]]
| eval count=mvcount(split(version,"."))
| eval version=version.substr(".0.0.0.0",1,(abs(count - 4) * 2) )

Maybe it's easier this way.

View solution in original post

to4kawa
Ultra Champion
| makeresults 
| eval version="7.3.2" | appendpipe[eval version="8.0.2.1" | appendpipe[eval version="7.2"| appendpipe[eval version="7"]]] 
| eval versions=mvindex(mvappend(split(version,"."),split("0000000","")),0,3)
| eval version=mvjoin(versions,".")

I couldn't make it with regular expressions.

0 Karma

to4kawa
Ultra Champion
| makeresults 
| eval version="7.3.2" | appendpipe [| eval version="8.0.2.1" |appendpipe [eval version="7.2"|appendpipe [eval version="7"]]]
| eval count=mvcount(split(version,"."))
| eval version=version.substr(".0.0.0.0",1,(abs(count - 4) * 2) )

Maybe it's easier this way.

splunkyj
Path Finder

@to4kawa thank you so much again!! You rock! Both worked, I just went with this one because it's simpler. Or looked to be, let me know if the other one is more efficient. But they both worked well! One day I wanna be like you 🙂

0 Karma

to4kawa
Ultra Champion
| makeresults 
| eval version="7.3.2" | appendpipe [| eval version="8.0.2.1"]
| rex field=version mode=sed "s/\b(\d)\b/0\1/g s/\.//g"
| eval version=substr(version."0000000",1,8)
| rex field=version mode=sed "s/(\d\d)/\1./g s/0(\d)\b/\1/g s/\.$//"

I want the shift instruction.

Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...