Splunk Search

How to replace a field if a specific value is seen

benspader
Explorer

I am trying to replace a value in my search. For example if I get host=10.0.0.1 I want to grab the IP from src_ip=192.168.0.1.

Thanks in advance!

Tags (2)
1 Solution

yannK
Splunk Employee
Splunk Employee

use an eval, and a condition like : fieldA=if(condition is fulfilled, then use value in Other fieldB, else use the pre-existing value in fieldA)

< my search > | eval IP=if(host=="10.0.0.1",src_ip,IP)

View solution in original post

yannK
Splunk Employee
Splunk Employee

use an eval, and a condition like : fieldA=if(condition is fulfilled, then use value in Other fieldB, else use the pre-existing value in fieldA)

< my search > | eval IP=if(host=="10.0.0.1",src_ip,IP)

benspader
Explorer

Thank you yannK! That was very helpful!

cblanton
Communicator

I'm trying to do exactly the same thing, but no matter what the value of the Event field, the new field evaluates to the value of MedRepoCloneMergeTimemin and not "na" as expected.

| eval newfield=if(in(Event,"mock"), "na", MedRepoCloneMergeTimemin)

| eval newfield=if(Event == mock, "na", MedRepoCloneMergeTimemin)

What am I missing? thanks for any ideas.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...