Splunk Search

How to create a Splunk regex to match URI?

danast
Engager

Hi everyone,

I am trying to come up with a Splunk regex search for detecting URIs of URLs.
What I am interested in is the last random character and length string after the forward slash of the URLs below:

txx.zlx.mam-bg.ru/avuTbur334vxasd
zlx.axa.babishop18.ml/aipiruqwbXasal2

My fast solution to this so far is:

`... | regex uri="^/[a-zA-Z0`-9]{8,20}$"

However, I am unable to verify if this works as I don't have access to the logs currently.
Any suggestions for improvement would be appreciated.

Tags (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Have you seen the URL Toolbox app (https://splunkbase.splunk.com/app/2734/)? It will parse the URL for you.

If you really want or need to do it yourself, provide some sample data and we should be able to help you find a regex string that works with it.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Have you seen the URL Toolbox app (https://splunkbase.splunk.com/app/2734/)? It will parse the URL for you.

If you really want or need to do it yourself, provide some sample data and we should be able to help you find a regex string that works with it.

---
If this reply helps you, Karma would be appreciated.

danast
Engager

Rich thanks for the link to the app, I will give it a try later.

I asked some sample URLs to be emailed, here they are:

http://www.zdp.xu9lb084.IRISHKO.RU/bnhwf28dzmxoo
http://ylg.zc90xzeu.mama-bg.ru/aoxzc28jlcabog
http://hzm.hzm.6ju4a0t6.river-runningasd.ga/gqnckvx30hxgdtils

As you can see the last random character/length string after the domain suffix and / connect all of them. What I am trying to do here is to go through logs and find any urls that have such string. From what I know the length of the string varies between 8-20 characters.

Any suggestions for improvement would be appreciated.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The URL Toolbox app can do that easily.

This regex string matches your sample text: \.\w+\/(?<URI>.*).

---
If this reply helps you, Karma would be appreciated.
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!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

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