Splunk Search

How to extract the host name and database name

dkannanjanakan
New Member

Hi, I would like to extract the Host Name and Database Name from the below string.

URL : jdbc:sqlserver://WBMSSQLOPSD1:5800_databaseName=OPSActivities_dev

search

| rex field=Host "(sqlserver:..\s?(?<HostName>[^:]+))" 

Above regex extracts the Host name, I would like to extract database name as well. Please help.

Expected output WBMSSQLOPSD1:OPSActivities_dev

Thanks,
Dhana

0 Karma

cpetterborg
SplunkTrust
SplunkTrust

What about:

|  makeresults 
|  eval Host="URL : jdbc:sqlserver://WBMSSQLOPSD1:5800_databaseName=OPSActivities_dev"
|  rex field=Host "//(?P<server>[^:]+):[^=]*=(?P<DB>.*)"

and to combine them:

|  makeresults 
|  eval Host="URL : jdbc:sqlserver://WBMSSQLOPSD1:5800_databaseName=OPSActivities_dev"
|  rex field=Host "//(?P<server>[^:]+):[^=]*=(?P<DB>.*)"
| eval expected=server.":".DB
0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...