justwatchcom / sql_exporter

Flexible SQL Exporter for Prometheus.
MIT License
403 stars 109 forks source link

Unknown driver "mssql+pyodbc" #101

Open Kiara0107 opened 1 year ago

Kiara0107 commented 1 year ago

Issue:

{"caller":"job.go:190","err":"sql: unknown driver \"mssql+pyodbc\" (forgotten import?)","job":"example","level":"warn","msg":"Failed to connect","ts":"2023-09-22T09:02:58.038302874Z"}

Is this driver indeed unsupported or am I using it wrongly?

Configuration in config.yml:

---
# jobs is a map of jobs, define any number but please keep the connection usage on the DBs in mind
jobs:
  # each job needs a unique name, it's used for logging and as an default label
- name: "example"
  interval: '30s'
  connections:
  - 'mssql+pyodbc://username:password@host:1433/dbatasks?driver=ODBC+Driver+17+for+SQL+Server&MARS_Connection=yes'
  startup_sql:
  - 'SET lock_timeout = 1000'
  - 'SET idle_in_transaction_session_timeout = 100'
  queries:
  - name: "exceptionlog_count"
    help: "Sum of log entries in ExceptionLog table"
    labels:
      - "db"
    values:
      - "exceptionlog_count"
    query:  EXEC [dbo].[usp_PrometheusExceptionLogMonitoring]
    allow_zero_rows: false

Docker run command:

docker run -d -p 9237:9237 \
-v /etc/query/config.yml:/config/config.yml \
-e CONFIG=/config/config.yml \
--name sql-exporter ghcr.io/justwatchcom/sql_exporter
dewey commented 1 year ago

Hey, unfortunately I don't have access to one of these database servers and this was a community contributed integration as far as I know. I can't really test it unfortunately. If someone wants to take a look there, I'm happy to review a PR. It might just be about importing some package for the driver side-effect.