Splunk Enterprise

Extract and insert specific numbers from multivalue attribute

pwilkins24
New Member

Hello, I'm fairly new using Splunk and I'm trying to determine which command would be best to extract and insert data from the ap_name column into the space_id column I made using the following eval command:

| inputlookup <lookup value> | search ap_name=* | eval space_id = building_num + "-" + room

The first hyphen within the AP name indicates the floor number the AP is on. The hurdles I'm experiencing are the following:

- Extract and insert ONLY the first number(s) after the first hyphen within the AP name
- If the floor number is between 0 - 9 inserting a "0" to the space ID result

I'm also unsure if it would be easier to make another eval column using the extraction for the floor number, then add the new value into the space_id. Any assistance and/or guidance on this is greatly appreciated!

ap_groupap_latitudeap_longitudeap_namebuilding_numinstall_statuslocationmodel_idroomspace_id
test1123123234234sample-14-40272In useSample Tower (027231514340272-1434
test2345345456456sample2-1-191110In useSample Two House (1110)3151601110-160
test3567567678678sample3-10-90189In useSample Three Tower (0189)31510070189-1007
Labels (2)
0 Karma

pwilkins24
New Member

Thank you so much @ITWhisperer!! 

The only thing I need to troubleshoot now are both the values of building_num and room are both showing up as "Null".

Here are the results I'm seeing from the query:

ap_groupap_latitudeap_longitudeap_namebuilding_numfloorinstall_statuslocationmodel_idroomspace_id
test1123123234234sample-14-4027214In useSample Tower (0272)3151434Null-14-Null
test2345345456456sample-1-1911101In useSample Two House (1110)315160Null-01-Null
0 Karma

bowesmana
SplunkTrust
SplunkTrust

ITWhisper's solution is using your space id field, to get building and room, but you can do it like this

 

| eval space_id=printf("%s-%02d-%s", building_num, floor, room)

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If I understood your requirement correctly, try something like this

| eval floor=mvindex(split(ap_name,"-"),1)
| eval space_id=printf("%s-%02d-%s",mvindex(split(space_id,"-"),0),floor,mvindex(split(space_id,"-"),1))
0 Karma
Get Updates on the Splunk Community!

Developer Spotlight with Brett Adams

In our third Spotlight feature, we're excited to shine a light on Brett—a Splunk consultant, innovative ...

Index This | What can you do to make 55,555 equal 500?

April 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...