Splunk Search

How to write rex to get "domain.com"?

f_666dhn
Explorer

I have field user-agent like this

user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36\r\nHost: domain.com\r\nConnection: Keep-Alive\r\n"
 
How's the SPL query, if I just wanna get the "domain.com".

Thanks.

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @f_666dhn,

to extract the domain from the field "user-agent", you could use a regex like this:

| rex field=user-agent "Host:\s+(?<domain>[^\\]+)"

that you can test at https://regex101.com/r/Qtk4iq/1

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...