SQL_Exporter error: TLS Handshake

A colleague was installing Grafana Agent and SQL Exporter on a Test server as per the instructions that we have successfully used on Dev servers.
When running the command:
sql_exporter.exe -web.listen-address :9401 -config.file my.sqlExporter.yml
they see the exporter start up and listening on port 9401, but when they try to access the localhost:9401/metrics URL in a local browser, the following is seen in the CMD window:
6620 promhttp.go:38 Error gathering metrics: [from Gatherer #1] TLS Handshake failed: Cannot read handshake packet: EOF

The collector configuration is:
# Subtracted from Prometheus’ scrape_timeout to give us some headroom and prevent Prometheus from timing out first.
scrape_timeout_offset: 500ms
# Minimum interval between collector runs: by default (0s) collectors are executed on every scrape.
min_interval: 0s
# Maximum number of open connections to any one target. Metric queries will run concurrently on multiple connections,
# as will concurrent scrapes.
max_connections: 3
# Maximum number of idle connections to any one target. Unless you use very long collection intervals, this should
# always be the same as max_connections.
max_idle_connections: 3
# The target to monitor and the collectors to execute on it.
# Data source name always has a URI schema that matches the driver name. In some cases (e.g. MySQL)
# the schema gets dropped or replaced to match the driver expected DSN format.
data_source_name: ‘sqlserver://username:password@databaseDNSname:1433?database=InstanceName’
# Collectors (referenced by name) to execute on the target.
collectors: [my_sqlexplorer]
# Collector files specifies a list of globs. One collector definition is read from each matching file.
- “my.sqlExporter.collector.yml”

With the help of @mattd on the Grafana Lab Community Slack channel, the solution was to append
to the data_source_name

Note that encrypt=false did not work, as this does not exclude the initial handshake from encryption (see GitHub - denisenkom/go-mssqldb: Microsoft SQL server driver written in go language )

Wanted to note this here in case this helps anyone else in a similar situation

1 Like

glad you found a solution! :+1: