Splunk Search

[Help] Creating a new Field for matching Value

Zyon
Engager

Hi,

Currently, my Splunk search is:

sourcetype="Blacklist" OR sourcetype="log" | eval blacklisted=if(sourcetype=="Blacklist",_raw,null()) | fields - _raw | fields blacklisted,SRC 

I am able to see two fields, blacklisted and SRC.

May i ask if it is possible to do the following:

  • Create a new field to store values that matches between the 2 fields.

Thanks a lot!

Tags (1)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

If by "matches between the 2 fields" you mean if they equal each other, you can do this:

sourcetype="Blacklist" OR sourcetype="log" | eval blacklisted=if(sourcetype=="Blacklist",_raw,null()) | fields - _raw | fields blacklisted,SRC | eval matches = if(blacklisted==SRC, "match", "no match")

If you're thinking of something else then please elaborate.

View solution in original post

0 Karma

gkanapathy
Splunk Employee
Splunk Employee
0 Karma

Zyon
Engager

Thanks a lot!

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

If by "matches between the 2 fields" you mean if they equal each other, you can do this:

sourcetype="Blacklist" OR sourcetype="log" | eval blacklisted=if(sourcetype=="Blacklist",_raw,null()) | fields - _raw | fields blacklisted,SRC | eval matches = if(blacklisted==SRC, "match", "no match")

If you're thinking of something else then please elaborate.

0 Karma

Zyon
Engager

Yes, this is what i'm thinking of. Thanks a lot!

0 Karma
Get Updates on the Splunk Community!

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...

Adoption of Infrastructure Monitoring at Splunk

  Splunk's Growth Engineering team showcases one of their first Splunk product adoption-Splunk Infrastructure ...

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...