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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...