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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...