Splunk Search

How to extract a URL from a text string and assign it to a variable in Splunk?

Cuyose
Builder

I cannot find a working example of this anywhere. I can find examples a mile long on google, but am having trouble actually assigning them to a variable in Splunk.

0 Karma
1 Solution

Cuyose
Builder

I got what I needed using the following:

|rex field=_raw "(?(https?:\/\/([-\w\.]+)+(:\d+)?))"

View solution in original post

0 Karma

Cuyose
Builder

I got what I needed using the following:

|rex field=_raw "(?(https?:\/\/([-\w\.]+)+(:\d+)?))"
0 Karma

sundareshr
Legend

Try this, for 3 capturing groups. You can name each group, if desired.

... | rex "https?:\/\/([^\.]+)\.([^\.]+)\.([^\/]+)"
0 Karma

twinspop
Influencer

Need a sample log entry

0 Karma

Cuyose
Builder

http or https
then ://
then anything up to .
then anything up to .
then anything up to first /

0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...