Splunk Search

How to use multiple regular expressions in a single search query to extract only the URLs in my data?

neelakanta
Explorer

I would like to use multiple regexes in single query. source data is full of random logs which has many fields. I am interested only on URL.

regex url="(:1000\/[a-zA-Z0-9]{10,20}\?[a-zA-Z0-9]{30} OR \/\/[0-9a-zA-Z.]{50,80}\/[0-9a-zA-Z.]{32}\/)"
regex url="(:1000\/[a-zA-Z0-9]{10,20}\?[a-zA-Z0-9]{30} | \/\/[0-9a-zA-Z.]{50,80}\/[0-9a-zA-Z.]{32}\/)"

does not return any results whereas individual regex fetches results.

0 Karma
1 Solution

neelakanta
Explorer

those who would want to use multiple regex they can do this way:

index= source_index |regex url=":1000/[a-zA-Z0-9]{10,20}?[a-zA-Z0-9]{30}|[0-9a-zA-Z.]{50,80}/[0-9a-zA-Z.]{32}/" |table fields1 field2 field3

make sure no spaces around "|"

View solution in original post

tachifelix
Path Finder

you can use pipe character to separate it

regex url="(:1000/[a-zA-Z0-9]{10,20}?[a-zA-Z0-9]{30} OR //[0-9a-zA-Z.]{50,80}/[0-9a-zA-Z.]{32}/)|(:1000/[a-zA-Z0-9]{10,20}?[a-zA-Z0-9]{30} | //[0-9a-zA-Z.]{50,80}/[0-9a-zA-Z.]{32}/)"
0 Karma

neelakanta
Explorer

those who would want to use multiple regex they can do this way:

index= source_index |regex url=":1000/[a-zA-Z0-9]{10,20}?[a-zA-Z0-9]{30}|[0-9a-zA-Z.]{50,80}/[0-9a-zA-Z.]{32}/" |table fields1 field2 field3

make sure no spaces around "|"

neelakanta
Explorer

Fields are ip time host url accesstype
xx.xxx.xx.xx "01/06/2012:HH:MM:SS IST" hostname "ip:1000/abcd01234?/abcd1234/"
yy.yyy.yy.yy "01/06/2012:HH:MM:SS IST" hostname "domainname/abcd01234?/abcd1234/.php"

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Can you provide some samples of the data you are trying to search?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...