Splunk Search

How to rename fields only from a certain search (Search1) OR (Search 2)?

erikschubert
Engager

Hello everyone,

I have a search in the following format:

(index="index1" group=a) OR (index="index2" group=a)....

Later on in the search I want to rename the field host to splunkname, but only those found in events coming from the second "search". The problem ist that both "searches" return events with a field called host.

When I tried this, it didnt work:
(index="index1" group=a) OR (index="index2" group=a| rename host AS splunkname)

How could I solve this?

Labels (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @erikschubert,

you have to use eval if:

index="index1" group=a) OR (index="index2" group=a)....
| eval splunkname=if(index=indexB,host, splunkname)

you said that splunkname is equal to host for the second search but you didn't specified what's the value of splunkname for the first search, I supposed that there's this field, anyway take the approach to the problem and the general solution.

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...