Splunk Search

regex returns no results

CorpusCallosum
Explorer

Hi guys

I am doing an experiment in my local splunk. I imported some http logs including attack patterns. And I am trying to list all /etc/passwd patterns.

First i tried sourcetype=X IPaddressofrequester | regex http_request="(?:etc\/\W*passwd)"

it gives correct results including the http requests have specific IP address and its /etc/passwd requests

However when i exlude the ip address and convert the search like

sourcetype=X regex http_request="(?:etc\/\W*passwd)"

it gives no result. What is wrong with this search? I am trying to list all the request including /etc/passwd in it. after that i will make table of the IP addresses sending /etc/passwd

Could you please help me on this?

Thanks

1 Solution

jtrucks
Splunk Employee
Splunk Employee

You removed the | which is needed.

Do this:

sourcetype=X  | regex http_request="(?:etc/W*passwd)"
--
Jesse Trucks
Minister of Magic

View solution in original post

jtrucks
Splunk Employee
Splunk Employee

You removed the | which is needed.

Do this:

sourcetype=X  | regex http_request="(?:etc/W*passwd)"
--
Jesse Trucks
Minister of Magic

Ayn
Legend

When you ONLY use regex to filter that means the initial search command will need to grab all the matching events from disk and into memory before passing them on to the next command in the search pipeline (regex). This is of course very "expensive" I/O-wise. You should always filter your events as much as possible in the initial search command.

CorpusCallosum
Explorer

Thanks that worked. This solution come up with a new question 🙂 if i add IPaddress to my search the results shown quickly like 10 seconds. However if use only regex it takes 5 min to show results for custom time search around 30 mins traffic. I know regex is expensive but both searches using same regex. What is the reason of that? is that normal?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...