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!

What's New in Splunk Cloud Platform 9.3.2411?

Hey Splunky People! We are excited to share the latest updates in Splunk Cloud Platform 9.3.2411. This release ...

Buttercup Games: Further Dashboarding Techniques (Part 6)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...