Splunk Search

Why is regex not returning any results when used in a tstats search?

pgort
New Member

I have a correlation search that triggers on users accessing too many URLs categorized as unknown.

| tstats allow_old_summaries=true count(Web.user) as "Count" from datamodel=Web where nodename=Web.Blocked Web.url_category="unknown" Web.rule!="Allow_Public_IP" AND Web.src_zone="TRUST" by "Web.user" 
| rename "Web.user" as "user"
| regex Web.url !="\d+\.\d+\.\d+\.\d+\/$"
| where 'Count'>100

| regex Web.url !="\d+\.\d+\.\d+\.\d+\/$" is the problem line. It does not filter out IP addresses (or anything for that matter). Right now, Cisco Spark traffic is cluttering our URL traffic logs as the "url" is an IP address with a trailing / rather than a DNS name.

I need the regex to ignore logs of just an IP followed by a slash: "10.0.0.1/" but still return all other values like: "10.0.0.1/index.html" or "google.com". I can't tell if I'm calling regex correctly for tstats or how regex sees the value of Web.url to know if I can use the $ at the end.

0 Karma
1 Solution

sjohnson_splunk
Splunk Employee
Splunk Employee

You need to add Web.url to your tstats statement as part of the by statement otherwise the field isn't available for the regex statement.

View solution in original post

0 Karma

sjohnson_splunk
Splunk Employee
Splunk Employee

You need to add Web.url to your tstats statement as part of the by statement otherwise the field isn't available for the regex statement.

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...