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?:\/\/[^\/]+)"
---
What goes around comes around. If it helps, hit it with Karma 🙂

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?:\/\/[^\/]+)"
---
What goes around comes around. If it helps, hit it with Karma 🙂

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

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

renjith_nair
Legend

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

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...