influxdata / influxdata/telegraf

sqlserver: not all expected metrics collected when using database_type = "SQLServer"

Open
#13,724 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
17.8k
Forks
5.8k
Avg merge
1d 20h
Merged PRs (30d)
161

Description

### Relevant telegraf.conf

```toml
[[inputs.sqlserver]]
interval = "30s"
servers = [
"Server=server1;Port=1433;User Id=telegraf;Password=XXXXX;app name=telegraf;log=1;",
]

database_type = "SQLServer"
health_metric = true
auth_method = "connection_string"
```

### Logs from Telegraf

```text
2023-08-04T15:30:49Z I! Starting Telegraf 1.27.3
2023-08-04T15:30:49Z I! Available plugins: 237 inputs, 9 aggregators, 28 processors, 23 parsers, 59 outputs, 4 secret-stores
2023-08-04T15:30:49Z I! Loaded inputs: sqlserver
2023-08-04T15:30:49Z I! Loaded aggregators:
2023-08-04T15:30:49Z I! Loaded processors:
2023-08-04T15:30:49Z I! Loaded secretstores:
2023-08-04T15:30:49Z I! Loaded outputs: file influxdb
2023-08-04T15:30:49Z I! Tags enabled: host=XXX
2023-08-04T15:30:49Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"XXX", Flush Interval:10s
2023-08-04T15:30:49Z I! [inputs.sqlserver] Config: database_type: SQLServer , query_version:0 , azuredb: false
2023-08-04T15:30:49Z I! [inputs.sqlserver] Config: Effective Queries: []string{"SQLServerDatabaseIO", "SQLServerProperties", "SQLServerMemoryClerks", "SQLServerVolumeSpace", "SQLServerAvailabilityReplicaStates", "SQLServerRecentBackups", "SQLServerPerformanceCounters", "SQLServerWaitStatsCategorized", "SQLServerSchedulers", "SQLServerRequests", "SQLServerCpu", "SQLServerDatabaseReplicaStates"}
```

### System info

Telegraf 1.27.3

### Docker

_No response_

### Steps to reproduce

1. Run the default config of the sqlserver plugin with `database_type = "SQLServer"` configured against a server that has resource governor (Workload Groups/Resource Pools) configured
2. Do the same with configuring `query_version = 2`
3. Compare the results

### Expected behavior

Results should be similar, there should be no metrics missing when using the new style queries (`database_type = "SQLServer"`)

### Actual behavior

Certain values are not present.
For example for the object `SQLServer:Workload Group Stats` with `query_version = 2` the following counters are returned:

- Blocked tasks
- CPU Limit Violation Count
- CPU usage %
- CPU Usage (time)
- Lock Wait Count
- Lock Wait Time
- Preemptive CPU Usage (time)
- Queued Request Count
- Queued requests
- Reduced Memory Grant Count
- Request Count
- Requests completed/sec

with `database_type = "SQLServer"` only these are returned:

- Blocked tasks
- CPU usage %
- Queued requests
- Requests completed/sec

### Additional info

This seems to be due to the queries itself, I get the same mismatch when running

https://github.com/influxdata/telegraf/blob/2ac45b8d25629642ded419e7ce079ae8427a5a98/plugins/inputs/sqlserver/sqlqueriesV2.go#L406

and

https://github.com/influxdata/telegraf/blob/2ac45b8d25629642ded419e7ce079ae8427a5a98/plugins/inputs/sqlserver/sqlserverqueries.go#L333

and compare the output.

If this is intended (or the new queries are known to not yet be fully compatible with the v2 ones) I would suggest to document this somewhere.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with plugins/inputs/sqlserver/sqlqueriesV2.go around line 406 and plugins/inputs/sqlserver/sqlserverqueries.go around line 333, then compare the Workload Group Stats queries and their outputs. Reproduce against a SQL Server with Resource Governor configured using the default configuration and query_version = 2. Done means the SQLServer database_type returns the expected counters, or the documented incompatibility is clearly recorded.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.