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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...