Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query="mssql_connections" -> Scan error on column index 0, name "db": unsupported Scan, storing driver.Value type <nil> into type *string` #115

Open
iulian-olteanu opened this issue Jan 13, 2022 · 1 comment

Comments

@iulian-olteanu
Copy link

Hello,

We have the following error:

I0113 15:51:22.498632 9256 promhttp.go:38] Error gathering metrics: [from Gatherer #1] [, collector="mssql_standard", query="mssql_connections"] scanning of query result failed: sql: Scan error on column index 0, name "db": unsupported Scan, storing driver.Value type <nil> into type *string

The metric definition is

- metric_name: mssql_connections
    type: gauge
    help: 'Number of active connections.'
    key_labels:
      - db
    values: [count]
    query: |
      SELECT DB_NAME(sp.dbid) AS db, COUNT(sp.spid) AS count
      FROM sys.sysprocesses sp
      GROUP BY DB_NAME(sp.dbid)

Do you know what is causing it ?

@jroboyd
Copy link

jroboyd commented Dec 14, 2022

DB_NAME(sp.dbid) is returning NULL for some reason. stack overflow link

Another way of writing it would be:

SELECT db.name AS db, COUNT(sp.spid) AS count
      FROM sys.sysprocesses sp
	  INNER JOIN sys.databases db ON db.database_id = sp.dbid
      GROUP BY db.name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants