Splunk Search

How to search for a field using value of other field

deepakmr8
New Member

Hi,

I have two fields, both these fields will be in two different events, now  i want to search for events, where aggr_id=*session_ID*, basically i'm looking to search for field1=*field2*

field1: session_ID= 1234567890

field2: aggr_id= ldt:1234567890:09821

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It is not usually good to start a search with a wildcard, so assuming aggr_id always starts with Idt:, you could do something like this 

| makeresults
| eval aggr_id="ldt:1234567890:09821"
| search 
    [| makeresults
    | eval session_ID= 1234567890
    | eval aggr_id="ldt:".session_ID."*"
    | table aggr_id
    | dedup aggr_id]

The makeresults just set up dummy data and should be replaced by your index search

<index search> [search index
    | eval aggr_id="ldt:".session_ID."*"
    | table aggr_id
    | dedup aggr_id]

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @deepakmr8 ,

if the rule in the second field is fixed, you could use a regex to extract the relevant part fo the match:

<your_search>
| rex field=aggr_id "^\w+:(?<extract>[^:]+)"
| search session_ID=extract

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...