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!

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Announcing the General Availability of Splunk Enterprise Security 8.1!

We are pleased to announce the general availability of Splunk Enterprise Security 8.1. Splunk becomes the only ...

Developer Spotlight with William Searle

The Splunk Guy: A Developer’s Path from Web to Cloud William is a Splunk Professional Services Consultant with ...