Splunk Search

Can you help me come up with the regex to get the domain + scheme?

jtotzek
Explorer

Hi,

I tried many things but I still cannot get to the correct result.

my field value looks like this
http://34.223.245.254/path/user.html
http://sub.domain.com/D2-Client
https://sub.domain.ph

and in the output I just want
http://34.223.245.254
http://sub.domain.com
https://sub.domain.ph

so far it looks like this:

BASE-SEARCH | rex field="MY_FIELD_NAME" "(REGEX)" | stats values("domain")
Tags (2)
0 Karma
1 Solution

renjith_nair
Legend

@jtotzek,

Give this a try and see if it works,

|rex field=YOUR_FIELD_NAME "(?<domain>https?:\/\/[^\/]+)"
Happy Splunking!

View solution in original post

ddrillic
Ultra Champion

You can try -

BASE-SEARCH | erex _raw url "http://34.223.245.254,http://sub.domain.com,https://sub.domain.ph"

Under Job you should see the generated regex...

0 Karma

renjith_nair
Legend

@jtotzek,

Give this a try and see if it works,

|rex field=YOUR_FIELD_NAME "(?<domain>https?:\/\/[^\/]+)"
Happy Splunking!

jtotzek
Explorer

wow, perfect! I was almost there! thanks a lot!

0 Karma

renjith_nair
Legend

@jtotzek, glad it worked for you. Please accepts answer to close the thread

Happy Splunking!
0 Karma

renjith_nair
Legend

@jtotzek, do you have any other question on this ? If not, kindly accept as answer .

Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...