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!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...