Splunk Search

Split multi-valued field

bcarr12
Path Finder

Hi all,

What would be the best way to split values out of a field that I know are multi-valued, but are written as one long string?

For example:

field=VALUE --> V is a unique value, A is a unique value, L is a unique value, etc

this field could have unique patterns, such as:

field=V
field=VL (V in a unique value, L is a unique value)
field=VU (V is a unique value, U is a unique value)
field=AL (A is a unique value, L is a unique value)
etc...

0 Karma

DalJeanis
Legend

How many different potential values are we talking about?

Do you have an exhaustive list of the potential values, or might there be "leftovers"

| makeresults | eval myfield="V VL VU AL AXV ZTU" |makemv myfield | mvexpand myfield | table myfield
| rename COMMENT as "The above inputs your sample data, plus a couple of other use cases"

| rename COMMENT as "Pull out the values we know about"
| rex field=myfield "(?<subfield>A|L|U|V)" max_match=0

| rename COMMENT as "Calculate anything left by deleting the stuff already captured"
| eval remainder=myfield
| rex field=remainder mode=sed "s/A|L|U|V//g"

| rename COMMENT as "Concatenate the remainder onto the end of the capture field, sort and dedup"
| eval subfield2=mvdedup(mvappend(subfield,remainder))

Basically, the A|L|U|V is the only thing you need to code and be careful of. Make sure that if there is any overlap between the capture values, that the longer one is placed first. For example, if app and apple and grapple and grappa are potential values, then these orders are correct - grapple|apple|grappa|app or grappa|grapple|apple|app. (There are a couple more potentially correct versions, but you get the idea.)

If you want the values you identify and pull out to be case-insensitive, then change these two lines to include (?i) -

| rex field=myfield "(?i)(?<subfield>A|L|U|V)" max_match=0

| rex field=remainder mode=sed "s/(?i)A|L|U|V//g"
0 Karma

bcarr12
Path Finder

Appreciate the suggestion, unfortunately there are too many different combinations so this solution may not work. Maybe I just need to do something as simple as adding a delimeter between each value and then use the split command from there? Just not sure of the best way to add a delimeter in where there currently isn't one.

0 Karma

woodcock
Esteemed Legend
0 Karma

bcarr12
Path Finder

Thanks for the suggestion, I think this would work if the values were delimited by something, but in this case the values are not delimited by anything

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!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2026-2027 SplunkTrust is officially open. If ...