-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[receiver/sqlserver] Enable direct connection to SQL Server instances #31915
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: sqlserverreceiver | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Enable direct connection to SQL Server | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [30297] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | | ||
Directly connecting to SQL Server will enable the receiver to gather more metrics | ||
for observing the SQL Server instance. The first metric added with this update is | ||
`sqlserver.database.io.read_latency`. | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,29 +13,45 @@ | |
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib | ||
<!-- end autogenerated section --> | ||
|
||
The `sqlserver` receiver grabs metrics about a Microsoft SQL Server instance using the Windows Performance Counters. | ||
Because of this, it is a Windows only receiver. | ||
The `sqlserver` receiver grabs metrics about a Microsoft SQL Server instance. The receiver works by either using the | ||
Windows Performance Counters, or by directly connecting to the instance and querying it. Windows Performance Counters | ||
are only available when running on Windows. | ||
|
||
Make sure to run the collector as administrator in order to collect all performance counters for metrics. | ||
|
||
## Configuration | ||
|
||
The following settings are optional: | ||
- `collection_interval` (default = `10s`): The internal at which metrics should be emitted by this receiver. | ||
- `instance_name` (optional): The instance name identifies the specific SQL Server instance being monitored. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose to allow query-filtering based on instance name and not computer name as I believe instance name makes more sense for this. If anyone wants both, or only computer name I'm happy to discuss. It would be a relatively simple feature/enhancement. |
||
If unspecified, metrics will be scraped from all instances. If configured, the `computer_name` must also be set | ||
when running on Windows. | ||
|
||
Direct connection options (optional, but all must be specified to enable): | ||
- `username`: The username used to connect to the SQL Server instance. | ||
- `password`: The password used to connect to the SQL Server instance. | ||
- `server`: IP Address or hostname of SQL Server instance to connect to. | ||
- `port`: Port of the SQL Server instance to connect to. | ||
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
To collect from a SQL Server with a named instance, both `computer_name` and `instance_name` are required. For a default SQL Server setup, these settings are optional. | ||
Windows-specific options: | ||
- `computer_name` (optional): The computer name identifies the SQL Server name or IP address of the computer being monitored. | ||
- `instance_name` (optional): The instance name identifies the specific SQL Server instance being monitored. | ||
If specified, `instance_name` is also required to be defined. This option is ignored in non-Windows environments. | ||
|
||
Example: | ||
|
||
```yaml | ||
receivers: | ||
sqlserver: | ||
collection_interval: 10s | ||
sqlserver/1: | ||
collection_interval: 5s | ||
username: sa | ||
password: securepassword | ||
server: 0.0.0.0 | ||
port: 1433 | ||
``` | ||
|
||
When a named instance is used, a computer name and a instance name must be specified. | ||
When a named instance is used on Windows, a computer name and a instance name must be specified. | ||
Example with named instance: | ||
|
||
```yaml | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,15 @@ attributes: | |
description: The page operation types. | ||
type: string | ||
enum: [read, write] | ||
physical_filename: | ||
description: The physical filename of the file being monitored. | ||
type: string | ||
logical_filename: | ||
description: The logical filename of the file being monitored. | ||
type: string | ||
file_type: | ||
description: The type of file being monitored. | ||
type: string | ||
|
||
metrics: | ||
sqlserver.user.connection.count: | ||
|
@@ -158,6 +167,16 @@ metrics: | |
unit: "{transactions}/s" | ||
gauge: | ||
value_type: double | ||
sqlserver.database.io.read_latency: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to name this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to cumulative sum based on underlying metric description (refer to |
||
enabled: false | ||
description: Total time that the users waited for reads issued on this file. | ||
unit: "s" | ||
sum: | ||
monotonic: true | ||
aggregation_temporality: cumulative | ||
value_type: double | ||
attributes: [physical_filename, logical_filename, file_type] | ||
extended_documentation: This metric is only available when the receiver is configured to directly connect to SQL Server. | ||
|
||
tests: | ||
config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of the complexity of this PR is enabling support on the non-Windows based OSs, while trying to keep Windows-specific functionality unchanged. I attempted to keep logic that was specific to windows in
_windows
files, logic specific to non-windows in_others
files, and both in the generically named files. This leads to a bit of a challenge trying to follow some code, but I don't know of a better way given the nature of this receiver.Happy to take suggestions on how to make this cleaner if anyone has any.