Splunk Search

How do I get the value of one field if the value of another field matches?

harshal_chakran
Builder

Hi,

I have 2 data logs "datasource1" and "datasource2", under same sourcetype name="DATALOGS", for e.g.

datasource1

variable1=111

variable2= 222

variable3= 333


datasource2

variable1=aaa

variable2= bbb

variable3= ccc

Now i want to get the value of variable1, if and only if variable2 value matches "123".

How to do this. Please Help...!!!

Tags (4)
0 Karma

somesoni2
Revered Legend

It would b great if you can provide sample output you're expecting...

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

How about:

variable2=123 | fields variable1

?

Ayn
Legend
... | eval myval=if(match(variable2,"123"),variable1,"")
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...