Getting Data In

Splunk Query required to add Inclusion and exclusion condition

Tajuddin
Explorer

 

The following query retrieves confroom_ipaddress values from the lookup table that do not match IP addresses found in the indexed logs:

| inputlookup lookup_ist_cs_checkin_rooms.csv where NOT [search index=fow_checkin message="display button:panel-*" | rex field=message "ipaddress: (?<ipaddress>[^ ]+)" | stats values(ipaddress) as confroom_ipaddress | table confroom_ipaddress] | rename confroom_ipaddress as ipaddress1

I would like to add an additional condition to include IP addresses that match those found in the following logs:

 
index=fow_checkin "Ipaddress(from request header)" | rex field=message "IpAddress\(from request header\):\s*(?<ip_address>\S+)$" | stats values(ip_address) as ip_address2

This means we need to include IP addresses from lookup_ist_cs_checkin_rooms.csv that match with the message "Ipaddress(from request header)" andexclude IP addresses from lookup_ist_cs_checkin_rooms.csv that match with the message "display button:panel-*"  as well. Please help.

0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

So, if an ip address from lookup_ist_cs_checkin_rooms.csv matches with a message "display button:panel-*" and it matches with an ip address in a message with "Ipaddress(from request header)", do you want to include it or exclude it? That is, which condition takes precedence?

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Your initial search might not be the best way to get what you're searching in the first place. Remember that Splunk's subsearches have their limits and might behave weirdly and give empty or wrong results if those limits are reached.

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So, if an ip address from lookup_ist_cs_checkin_rooms.csv matches with a message "display button:panel-*" and it matches with an ip address in a message with "Ipaddress(from request header)", do you want to include it or exclude it? That is, which condition takes precedence?

0 Karma
Get Updates on the Splunk Community!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

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 ...