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!

[Puzzles] Solve, Learn, Repeat: Reprocessing XML into Fixed-Length Events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...