Skip to content

Commit d07e7b9

Browse files
[receiver/sqlserver] Add more metrics (#32932)
**Description:** This change adds a query, scraper, and some more metrics for data from the performance counter SQL server table. The query itself is mostly taken from Telegraf's SQL server plugin. This also reuses the existing metric `sqlserver.lock.wait.rate`, so now it will be available both from Windows performance counters, as well as other OSs when directly connecting to the SQL server instance. **Naming and format feedback on new metrics would be greatly appreciated.** **Link to tracking Issue:** #29865 **Testing:** Added tests for the query itself, as well as the new scraper. Co-authored-by: Daniel Jaglowski <[email protected]>
1 parent 5e41c6b commit d07e7b9

18 files changed

+3769
-149
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: sqlserverreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add more metrics
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [29865]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
Added metrics are:
20+
- sqlserver.resource_pool.disk.throttled.read.rate
21+
- sqlserver.resource_pool.disk.throttled.write.rate
22+
- sqlserver.processes.blocked
23+
These metrics are only available when directly connecting to the SQL server instance
24+
25+
# If your change doesn't affect end users or the exported elements of any package,
26+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
27+
# Optional: The change log or logs in which this entry should be included.
28+
# e.g. '[user]' or '[user, api]'
29+
# Include 'user' if the change is relevant to end users.
30+
# Include 'api' if there is a change to a library API.
31+
# Default: '[user]'
32+
change_logs: []

receiver/sqlserverreceiver/documentation.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,36 @@ This metric is only available when the receiver is configured to directly connec
246246
| logical_filename | The logical filename of the file being monitored. | Any Str |
247247
| file_type | The type of file being monitored. | Any Str |
248248
249+
### sqlserver.processes.blocked
250+
251+
The number of processes that are currently blocked
252+
253+
This metric is only available when the receiver is configured to directly connect to SQL Server.
254+
255+
| Unit | Metric Type | Value Type |
256+
| ---- | ----------- | ---------- |
257+
| {processes} | Gauge | Int |
258+
259+
### sqlserver.resource_pool.disk.throttled.read.rate
260+
261+
The number of read operations that were throttled in the last second
262+
263+
This metric is only available when the receiver is configured to directly connect to SQL Server.
264+
265+
| Unit | Metric Type | Value Type |
266+
| ---- | ----------- | ---------- |
267+
| {reads}/s | Gauge | Int |
268+
269+
### sqlserver.resource_pool.disk.throttled.write.rate
270+
271+
The number of write operations that were throttled in the last second
272+
273+
This metric is only available when the receiver is configured to directly connect to SQL Server.
274+
275+
| Unit | Metric Type | Value Type |
276+
| ---- | ----------- | ---------- |
277+
| {writes}/s | Gauge | Double |
278+
249279
## Resource Attributes
250280
251281
| Name | Description | Values | Enabled |

receiver/sqlserverreceiver/factory.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ func setupQueries(cfg *Config) []string {
4343
queries = append(queries, getSQLServerDatabaseIOQuery(cfg.InstanceName))
4444
}
4545

46+
if cfg.MetricsBuilderConfig.Metrics.SqlserverResourcePoolDiskThrottledReadRate.Enabled ||
47+
cfg.MetricsBuilderConfig.Metrics.SqlserverResourcePoolDiskThrottledWriteRate.Enabled ||
48+
cfg.MetricsBuilderConfig.Metrics.SqlserverLockWaitRate.Enabled ||
49+
cfg.MetricsBuilderConfig.Metrics.SqlserverProcessesBlocked.Enabled {
50+
51+
queries = append(queries, getSQLServerPerformanceCounterQuery(cfg.InstanceName))
52+
}
53+
4654
return queries
4755
}
4856

receiver/sqlserverreceiver/internal/metadata/generated_config.go

Lines changed: 33 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/sqlserverreceiver/internal/metadata/generated_config_test.go

Lines changed: 48 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)