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!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...