Splunk Search

extend a field value

Oti47
Path Finder

hello,
i want to extend a number field to a defined length like:

1324 to 001234
45678 to 045678

How could i do that on a simple way?

Thanks

Tags (2)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

Assuming that you have a field num_field that needs to be zero-padded into 6 characters, and that the value of the field does not exceed 999999;

eval num_field = "000000" . num_field | eval num_field = substr(num_field, -6)

/K

View solution in original post

0 Karma

Oti47
Path Finder

Hi,
yes it works.

Thanks

0 Karma

kristian_kolb
Ultra Champion

Assuming that you have a field num_field that needs to be zero-padded into 6 characters, and that the value of the field does not exceed 999999;

eval num_field = "000000" . num_field | eval num_field = substr(num_field, -6)

/K

0 Karma
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...