Splunk Search

How to write a search to return a value from one of three columns in a CSV lookup based on a field?

irfans
Explorer

I am trying to write a lookup that will pull a value out from one of three different columns.

for example

Col_A, Val_A, Val_B, Val_C

I want to look up only one of the values depending on a field.

So if lookup_field = Val_B , I want to use Col_A and pull out value from Val_B column.

woodcock
Esteemed Legend

This does the same thing (I do not believe there is a way to do this exactly the way you described):

... | lookup myLookup Col_A OUTPUT Val_A Val_B Val_C | eval desiredValue=case(lookup_field="Val_A", Val_A, lookup_field="Val_B", Val_B, lookup_field="Val_C", Val_C) | fields - Val_*
0 Karma

somesoni2
SplunkTrust
SplunkTrust

Can you post some sample data from the lookup?

0 Karma

alexandermunce
Communicator

This is a slightly complicated one - however if you can provide some sample data then there may be a more suitable way to approach the logic here.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...