-
Notifications
You must be signed in to change notification settings - Fork 6.2k
feat(go.d): add generic sql collector #21281
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR introduces a new generic SQL collector module for Netdata that enables monitoring of MySQL, PostgreSQL, and Oracle databases through custom SQL queries. The collector provides a flexible framework for executing arbitrary SQL queries and converting results into Netdata metrics with dynamic chart generation.
Key changes:
- New SQL collector supporting MySQL, PostgreSQL, and Oracle drivers with configurable connection pooling
- Dynamic chart generation based on query results with customizable metadata
- DSN redaction functionality to protect sensitive credentials in logs
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/go/plugin/go.d/collector/sql/collector.go | Main collector implementation with lifecycle methods and default configuration |
| src/go/plugin/go.d/collector/sql/config.go | Configuration structures for database connection, queries, and chart metadata |
| src/go/plugin/go.d/collector/sql/driver.go | Driver imports and supported drivers registry |
| src/go/plugin/go.d/collector/sql/init.go | Configuration validation logic |
| src/go/plugin/go.d/collector/sql/collect.go | Core collection logic, database operations, and DSN redaction utility |
| src/go/plugin/go.d/collector/sql/charts.go | Dynamic chart creation based on query configuration |
| src/go/plugin/go.d/collector/sql/collector_test.go | Tests for DSN redaction functionality |
| src/go/plugin/go.d/collector/init.go | Module registration in the global collector registry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@cubic-dev-ai review this PR |
@ktsaou I've started the AI code review. It'll take a few minutes to complete. |
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.
2 issues found across 9 files
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="src/go/plugin/go.d/collector/sql/collect.go">
<violation number="1" location="src/go/plugin/go.d/collector/sql/collect.go:94">
A single parse failure marks this metric as permanently skipped, so later valid values are never collected. Drop or reset the skip flag instead of leaving it true for the lifetime of the collector.</violation>
</file>
<file name="src/go/plugin/go.d/collector/sql/driver.go">
<violation number="1" location="src/go/plugin/go.d/collector/sql/driver.go:14">
The supportedDrivers entry "postgres" does not match the driver name registered by github.com/jackc/pgx/v5/stdlib ("pgx"). A config that passes verifyConfig will still hit sql.Open("postgres", ...) and fail with an unknown driver error. Update the key to the actual driver name or register the alias.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
Summary
Fixes #13659
Test Plan
Additional Information
For users: How does this change affect me?