Splunk Search

how to store a value from rex and reuse this value in another search

silverem78
Engager

Dear fellows,

I have two logs and i am looking to do some correlation between them.

In the log1, i am looking for IP_x (ex: 2.2.2.2)associated with IP_1 (1.1.1.1), then reuse the value of IP_x (2.2.2.2) in another search.

When i execute, i got nothing.

index=* sourcetype=log1 [search index=* sourcetype=log2  src_ip="1.1.1.1" 
| rex field=_raw "src-ip (?<src-ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | eval src_ip =src-ip | table src_ip ] src_ip

if i do this, i got the details

index=* sourcetype=log1 2.2.2.2

when i execute manually the search , i got the table with 2.2.2.2

search index=* sourcetype=log2  src_ip="1.1.1.1" 
| rex field=_raw "src-ip (?<src-ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | eval src_ip =src-ip | table src_ip

Any helps will be welcomed

Labels (3)
0 Karma

aasabatini
Motivator

Hi @silverem78 

try this:

index=* sourcetype=log1 [search index=* sourcetype=log2  src_ip="1.1.1.1" 
| rex field=_raw "src-ip (?<src-ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | eval src_ip =src-ip | fields src_ip ] 

if doesn't works can you run this search and share the result?

search index=* sourcetype=log2  src_ip="1.1.1.1" 
| rex field=_raw "src-ip (?<src-ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | eval src_ip =src-ip | table src_ip | fieldformat
“The answer is out there, Neo, and it’s looking for you, and it will find you if you want it to.”
0 Karma

silverem78
Engager

I got an error with:

search index=* sourcetype=log2  src_ip="1.1.1.1" 
| rex field=_raw "src-ip (?<src-ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | eval src_ip =src-ip | table src_ip | fieldformat

 

I got nothing  (with no error) :

index=* sourcetype=log1 [search index=* sourcetype=log2  src_ip="1.1.1.1" 
| rex field=_raw "src-ip (?<src-ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | eval src_ip =src-ip | fields src_ip ] 

  it is like "[search index=* sourcetype=log2 src_ip="1.1.1.1"
| rex field=_raw "src-ip (?<src-ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | eval src_ip =src-ip | fields src_ip ] " doesnt provide value. 2.2.2.2 ...

0 Karma

aasabatini
Motivator

Hi @silverem78 

sorry for the error try this search and please share the result

 

 index=* sourcetype=log2  src_ip="1.1.1.1" 
| rex field=_raw "src-ip (?<src-ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | eval src_ip =src-ip | table src_ip | format

 

“The answer is out there, Neo, and it’s looking for you, and it will find you if you want it to.”
0 Karma

silverem78
Engager

Hi

 

I got an error.

0 Karma

aasabatini
Motivator

Hi @silverem78 

 

Can you share the error?

 

“The answer is out there, Neo, and it’s looking for you, and it will find you if you want it to.”
0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud's AI Assistant in Action Series: Onboarding New Hires & ...

This is the fifth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Now Playing: Splunk Education Summer Learning Premieres

It’s premiere season, and Splunk Education is rolling out new releases you won’t want to miss. Whether you’re ...

The Visibility Gap: Hybrid Networks and IT Services

The most forward thinking enterprises among us see their network as much more than infrastructure – it's their ...