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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...