-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add an optional health metric for the sqlserver input plugin #8544
Conversation
* First iteration of health metric changes * Update tests and add new column * Revert config * Update central config docs * Update README * Update README again
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.
I think this is largely covered already by the regular output stats collected by inputs.internal
Thanks @ssoroka ! I took a look at inputs.internal and it looks like these metrics are reported either at the agent level or at the plugin level. However, we're looking to gather metrics per connection (i.e server/database combination). Having this data point will help us check which connection failed vs which connection succeeded in a plugin and also number of queries that were successfully executed per connection. From my understanding, I think it is not possible to gather such metrics per connection from inputs.internal as of today. It would be great if you can help clarify and let us know your thoughts. Thanks! |
@ssoroka Please let us know if per connection level metric is possible from inputs.internal. From the docs, we could not its usage for such granularity. Thanks! |
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.
Hey @coquagli thanks for submitting this PR. I think the code looks quite good already. I have one major remark about using explicit returns. In telegraf we use explicit returns instead of implicit ones, so please change those.
Thanks for the review @srebhan! I've pushed another iteration to address your comments. |
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.
The only remaining thing you have to look into is the first return
in getConnectionIdentifiers()
, not sure but you might want to return the defaults!?
All other comments are suggestions or a matter of taste, so please change or keep as you like. Just leave me a comment on those what your decision is and resolve the resolved comments. :-)
Hey, @srebhan thanks for the great suggestions. I pushed some more changes. |
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.
Looks perfect to me. Thank you very much for the nice collaboration!
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.
ok, looks good. Just needs a merge conflict fixed.
Should be good now @ssoroka. |
Required for all PRs:
Add the ability to collect a per-connection health metric for the sqlserver input plugin. This health metric is optional and is disabled by default. Users can leverage this metric to detect if their SQL Server monitoring is not working as intended. The details below are fairly comprehensive and are copied from the updated README.
Health Metric
All collection versions (version 1, version 2, and database_type) support an optional plugin health metric called
sqlserver_telegraf_health
. This metric tracks if connections to SQL Server are succeeding or failing. Users can leverage this metric to detect if their SQL Server monitoring is not working as intended.In the configuration file, toggling
health_metric
to true will enable collection of this metric. By default, this value is set to false and the metric is not collected. The health metric emits one record for each connection specified by servers in the configuration file.The health metric emits the following tags:
sql_instance
- Name of the server specified in the connection string. This value is emitted as-is in the connection string. If the server could not be parsed from the connection string, a constant placeholder value is emitteddatabase_name
- Name of the database or (initial catalog) specified in the connection string. This value is emitted as-is in the connection string. If the database could not be parsed from the connection string, a constant placeholder value is emittedThe health metric emits the following fields:
attempted_queries
- Number of queries that were attempted for this connectionsuccessful_queries
- Number of queries that completed successfully for this connectiondatabase_type
- Type of database as specified bydatabase_type
in the configuration file. Ifdatabase_type
from the configuration file is empty, theQueryVersion
andAzureDB
fields are concatenated insteadIf
attempted_queries
andsuccessful_queries
are not equal for a given connection, some metrics were not successfully gathered for that connection. Ifsuccessful_queries
is 0, no metrics were successfully gathered.