Skip to content

[inputs.sqlserver] SQLServerDatabaseIO produces no metrics when running as a Windows service, works correctly with --test #18672

@dancastrolopez-or

Description

@dancastrolopez-or

Environment

Telegraf: 1.37.0
OS: Windows Server 2019 Standard 10.0.17763.0
SQL Server: 2019 (MSSQL 15), named instance
Output plugin: outputs.prometheus_client, metric_version = 2
database_type: SQLServer
Description

The measurement sqlserver_database_io is visible in --test mode but never appears in the /metrics endpoint when Telegraf runs as a Windows service. All other SQLServer queries (sqlserver_performance, sqlserver_waitstats, etc.) work correctly in both modes.

Steps to reproduce

  1. Install Telegraf 1.37.0 as a Windows service
  2. Configure inputs.sqlserver with database_type = "SQLServer"
  3. Run telegraf.exe --config telegraf.conf --test → sqlserver_database_io metrics appear
  4. Start the Telegraf service → query http://localhost:9273/metrics → sqlserver_database_io is absent
    What was verified
  • health_metric shows 13/13 attempted and successful queries — SQLServerDatabaseIO is included based on github
  • No errors or warnings in debug logs related to sqlserver
  • outputs.file with namepass = ["sqlserver_database_io"] produces an empty file
  • sys.dm_io_virtual_file_stats returns 23 rows when executed as a scheduled task in session 0 (NT AUTHORITY\SYSTEM)
  • sys.dm_os_volume_stats works for all files (CROSS APPLY returns no missing entries)
  • NT AUTHORITY\SYSTEM has VIEW SERVER STATE granted
  • No metrics dropped (metrics_dropped = 0)
  • tagexclude has no effect
  • interval = "120s" on inputs.sqlserver has no effect
    Minimal config
[[outputs.prometheus_client]]
  listen = ":9273"
  metric_version = 2
  export_timestamp = true
 
[[inputs.sqlserver]]
  servers = ["Server=localhost;Port=1433;app name=telegraf;log=1;"]
  database_type = "SQLServer"

Expected behavior

sqlserver_database_io metrics appear in /metrics like all other sqlserver_* measurements.

Actual behavior

sqlserver_database_io is completely absent from /metrics. No error is logged. The query is reported as successful by health_metric.

Note

This issue appears similar to #3349. The problem is not specific to this single server but most (90%) of the others servers running the same Telegraf version and config expose sqlserver_database_io correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions