Splunk Search

requests that starts with certain ips

xvxt006
Contributor

Hi,

i wanted to get times only for clietips that starts with certain ips. So i have this query below. This is not giving any data. When i have clientip="^(?:10..+|167.115..+|192.168..+|63.85.50.241)"
then it works (requests that does not start with those ips).
Can someone tell me what is wrong with this?

sourcetype=access_combined_wcookie host="xxxx*" regex clientip="^(?:10..+|16.115..+|199.168..+|63.12.23.241)" TimeInSecs> "1" AND TimeInSecs <= "1.5" | timechart count(uri) as "1-1.5"

Tags (1)
0 Karma
1 Solution

Ayn
Legend

I'm pretty sure your first example should not work at all if you put that as a filter string for the search command. search does not support regexes.

What your search string at the end does is it tries to find events with the STRING "regex" and values for the field "clientip" that are actually literally the string " (?:10..+ [...]" (and so on).

I think you're doing this a bit more complicated than it needs to be. Just doing something like this would work:

sourcetype=access_combined_wcookie host="xxxx*" (clientip="10.*" OR clientip="16.115.*" OR clientip="199.168.*" OR clientip="63.12.23.241") TimeInSecs> "1" AND TimeInSecs <= "1.5" | timechart count(uri) as "1-1.5"

View solution in original post

Ayn
Legend

I'm pretty sure your first example should not work at all if you put that as a filter string for the search command. search does not support regexes.

What your search string at the end does is it tries to find events with the STRING "regex" and values for the field "clientip" that are actually literally the string " (?:10..+ [...]" (and so on).

I think you're doing this a bit more complicated than it needs to be. Just doing something like this would work:

sourcetype=access_combined_wcookie host="xxxx*" (clientip="10.*" OR clientip="16.115.*" OR clientip="199.168.*" OR clientip="63.12.23.241") TimeInSecs> "1" AND TimeInSecs <= "1.5" | timechart count(uri) as "1-1.5"

Ayn
Legend

Nope, * is just a character functioning as a wildcard in the search command. Regular expressions cannot be used directly in the search command - if you would want to filter by regular expression for one reason or another you would have to use the regex command further along the search pipeline.

0 Karma

xvxt006
Contributor

Hi Ayn, Thanks for your reply. Actually i was using the way you suggested and thought of using regex. I am wondering how this is working - clientip="^(?:10..+|167.115..+|192.168..+|63.85.50.241)" (which gives ips does not start with those).
You said search does not support regex. when we have query like this clientip="10." OR clientip="16.115.", i am thinking * is regex right?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...