Splunk Search

Combine Dynamic Fields Starting with same value

DanielWick
New Member

So I have multiple fields whose field names could end with a different values. Examples of these fields are below:
foo.foo_a = 1
foo.foo_b = 2
foo.foo_123 = null
foo.foo_test = 4

What I want to do is combine all of these values into a single value.
Essentially, I want a new value like below
new_value= foo.foo_*
where new_value would then be equal to:
1
2
4

If anybody could help guide me on this, it would be greatly appreciated.

I was hoping that something like
stats list(foo.foo_*) by field
would have worked, but it doesn't provide the output that I am looking for, which is all of the fields combined into one.

0 Karma

somesoni2
Revered Legend

Give this a try. It , combines all foo.foo_* field values, concatenated by space, into field foo. If you want different delimiter, just update the 2nd expression in foreach-eval.

your current search with all foo.foo_* fields
| eval foo="" 
| foreach foo.foo_* [ eval foo=if(foo="",'<<FIELD>>',foo." ".'<<FIELD>>']
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...