Splunk Enterprise Security

Extract only host name from the URL field-

yat135
Observer

Hi,

I have a field "blockedUri" which can contain two types of value (string or URL). Below is an example :

 

blockedUri = eval

blockedUri = https://analytics.google.com/sample.js

 

I need a splunk search query that will trim and return the only hostname of the value if it's a URL or if it is a normal string simply return the string.

 

The result should be as below :

 

eval

analytics.google.com

 

Thanks in advance

Labels (1)
Tags (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=blockURL "http(s):\/\/(?<hostname>[^\/]+)"
| eval result=coalesce(hostname,blockedURL)
0 Karma
Get Updates on the Splunk Community!

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Splunk App for Anomaly Detection End of Life Announcement

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...