Splunk Search

Combine RegEx with a condition

mkrauss1
Explorer

Assume the following squid log samples:

(squid-1): 1515606581.001 100 1.2.3.4 TCP_TUNNEL/200 500 CONNECT some.fqdn.com:443 - DIRECT/1.2.3.4
(squid-1): 1515606582.002 200 1.2.3.4 TCP_TUNNEL/200 2000 CONNECT some.fqdn.com:443 - DIRECT/1.2.3.4
(squid-1): 1515606583.003 200 1.2.3.4 TCP_TUNNEL/200 5000 CONNECT some.fqdn.com:443 - DIRECT/1.2.3.4

Example search with a regular expression to filter for TIME, SIZE and URL:

 squid-1  |rex field=_raw "squid-1\):\s+\d+\.\d+\s+(?<TIME>\d+).*TCP_TUNNEL\/200\s+(?<SIZE>.*)\s+CONNECT\s+(?<URL>.*)\:" 
|  top TIME,SIZE,URL

How can i set a condition for the size to list only for example SIZE>1000?

Many thanks

0 Karma
1 Solution

micahkemp
Champion

You would do that after using rex to extract the field:

  squid-1  |rex field=_raw "squid-1\):\s+\d+\.\d+\s+(?<TIME>\d+).*TCP_TUNNEL\/200\s+(?<SIZE>.*)\s+CONNECT\s+(?<URL>.*)\:"
 | search SIZE>1000
 |  top TIME,SIZE,URL

View solution in original post

0 Karma

mayurr98
Super Champion

hey try this

squid-1  |rex field=_raw "squid-1\):\s+\d+\.\d+\s+(?<TIME>\d+).*TCP_TUNNEL\/200\s+(?<SIZE>.*)\s+CONNECT\s+(?<URL>.*)\:" 
| where SIZE>1000  
|  top TIME,SIZE,URL

Let me know if this helps you!

0 Karma

micahkemp
Champion

You would do that after using rex to extract the field:

  squid-1  |rex field=_raw "squid-1\):\s+\d+\.\d+\s+(?<TIME>\d+).*TCP_TUNNEL\/200\s+(?<SIZE>.*)\s+CONNECT\s+(?<URL>.*)\:"
 | search SIZE>1000
 |  top TIME,SIZE,URL
0 Karma

mkrauss1
Explorer

Ah, it was the search command which was missing. THANK YOU!

0 Karma
Get Updates on the Splunk Community!

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

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...