Splunk Search

How to assemble a field via indirect references to other fields

dmankin
New Member

I have logs where the these fields exist:

raw_message="Dropped table {table_name}" table_name="jobs"

and I want to add a message field that combines these (probably using eval) like so:

message="Dropped table jobs"

How can I do this for arbitrary expansions in the raw_message? i.e. I don't know the full list of "{field_name}" fields that may appear in arbitrary raw_messages.

If it helps, I can reformat raw_message at the source to use different delimiters.

Tags (1)
0 Karma

somesoni2
SplunkTrust
SplunkTrust

It may not be the complete solution to your problem as your second field names are dynamic, but give this a try (runanywhere search, first line are to generate sample data)

| gentimes start=-1 | eval raw_message="Dropped table {table_name}" | table raw_message | eval table_name="jobs" 
| eval message=replace(raw_message.table_name,"^([\{]+)\{[^\}]+\}(.+)$","\1\2")
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...