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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...