Splunk Search

Field reference in search (Not in dashboard) (i.e. Token replacement in search)

jeanyvesnolen
Path Finder

Hello,

I try with no success since here to do something like :

| makeresults | eval super_important_field="super_important_value"| eval Rule_Tile="Some interesting Rule Title about $super_important_field$" | <<SOMETHING>>

To at the end got a fields containing :

"Some interesting Rule Title about some_super_important_value"

Just like token replacement in dashboard but in search.

Tags (3)
0 Karma
1 Solution

micahkemp
Champion

This is an admittedly annoying thing about how Enterprise Security works, as it gives you field values in that format with no builtin, convenient method to template them out. The solution I opted for previously was to create a custom search command that would perform the templating, but this will also work for most cases (with the exception being if your field names happen to look like regexes):

| makeresults 
| eval super_important_field="super_important_value" 
| eval Rule_Title="Some interesting Rule Title about $super_important_field$ things"
| foreach * [eval Rule_Title=replace(Rule_Title, "\$<<FIELD>>\$", <<FIELD>>)]

View solution in original post

micahkemp
Champion

This is an admittedly annoying thing about how Enterprise Security works, as it gives you field values in that format with no builtin, convenient method to template them out. The solution I opted for previously was to create a custom search command that would perform the templating, but this will also work for most cases (with the exception being if your field names happen to look like regexes):

| makeresults 
| eval super_important_field="super_important_value" 
| eval Rule_Title="Some interesting Rule Title about $super_important_field$ things"
| foreach * [eval Rule_Title=replace(Rule_Title, "\$<<FIELD>>\$", <<FIELD>>)]

jeanyvesnolen
Path Finder

As an aprovement I've done the folowing in order to "not" be confused by regex syntax
| eval rule_title=replace(rule_title,"\$","§")
| rename rule_title as TicketShort | foreach * [
| eval TicketShort=if(match(TicketShort, "§<>§"), replace(TicketShort, "§<>§",<>),TicketShort)
]

0 Karma

jeanyvesnolen
Path Finder

(PS : I have to find the command to complete the "<>"

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...