feat(database): add mount point telemetry labels to database metrics - #32078
feat(database): add mount point telemetry labels to database metrics#32078vinanrra wants to merge 3 commits into
Conversation
|
Deployment failed for project vault-ui with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes vfernandezg seems not to be a GitHub user. Have you signed the CLA already but the status is still pending? Recheck it. |
1 similar comment
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes vfernandezg seems not to be a GitHub user. Have you signed the CLA already but the status is still pending? Recheck it. |
|
Deployment failed for project vault-ui with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed for project vault-ui with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
- Add mount namespace, mount point, and connection name labels to database plugin metrics when operator opts in via add_mount_point_database_metrics telemetry configuration - Introduce metricsLabelsForConnection method to backend to generate telemetry labels based on mount context - Update newDatabaseWrapper calls to pass metrics labels through newDatabaseWrapperWithMetricsLabels - Extend databaseBackend struct with mountNamespace, mountPoint, and includeMountPointInMetrics fields - Update gauge collection to conditionally append namespace and mount_point labels when configured - Add comprehensive test coverage in telemetry_labels_test.go validating label emission with real database backend - Update middleware and plugin factory to support labeled metrics propagation - Add telemetry configuration helpers and test fixtures for database mount point metrics - Operators can now correlate database plugin metrics across different mounts and namespaces for better observability
…t to changelog/32078.txt - Align with standard changelog naming convention using issue number
…umentation - Add validate() method to PluginFactoryConfig to check for required fields (Sys and Logger) before plugin initialization - Prevent nil dereference panics by surfacing validation errors early to callers - Refactor PluginFactoryWithConfig to use cfg directly instead of local variable assignments, improving consistency - Update comments in backend.go to clarify mount point telemetry label behavior when opt-in is disabled - Update telemetry.go documentation to reflect namespace labels in addition to mount_point and connection_name - Add comprehensive test suite (plugin_factory_test.go) covering config validation scenarios
c7f59b9 to
82b6eea
Compare
|
Deployment failed for project vault-ui with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
Description
Part of #32077.
What does this PR do?
Database secrets engine metrics are currently keyed only by the plugin type string (for example, PostgreSQL emits
database.pgx.*). There is no way to break them down by the mount, the namespace, or the configured connection, so every connection of a given type across every mount and namespace collapses into a single time series. This makes it impossible to answer questions like "which mount is driving credential churn?" or "is connectionorders-primaryslower thanreporting-replica?".This PR adds opt-in
namespace,mount_point, andconnection_namelabels to the database plugin metrics, gated behind a new telemetry configuration option. Labels (rather than metric-name segments) are used deliberately, so existing dashboards and queries keep working unchanged — the same approach and rationale as the existingadd_mount_point_rollback_metricsoption.Summary of changes
namespace,mount_point, andconnection_namelabels to database plugin metrics when the operator opts in via the newadd_mount_point_database_metricstelemetry configuration.metricsLabelsForConnectionmethod on the backend to build telemetry labels from the mount context (returns no labels unless opted in).newDatabaseWrapperWithMetricsLabels(the existingnewDatabaseWrappersignature is preserved as a thin wrapper for compatibility).databaseBackendstruct withmountNamespace,mountPoint, andincludeMountPointInMetricsfields, populated fromlogical.BackendConfig.pluginInstancesgauge collection to conditionally appendnamespaceandmount_pointlabels, guarding against empty values.PluginFactoryConfig+PluginFactoryWithConfig;PluginFactory/PluginFactoryVersionsignatures unchanged).configutil.Telemetry→metricsutil.TelemetryConstConfig→Core→logical.BackendConfig) plus a config-parse test and fixture.telemetry_labels_test.gothat validates label emission against a real database backend and plugin process.Operators can now correlate database plugin metrics across different mounts and namespaces for better observability.
Configuration
Behavior
Metric names are unchanged. Labels are added only when the option is enabled:
Affected series: the middleware operations (
PluginVersion,Initialize,NewUser,UpdateUser,DeleteUser,Close) in both theirdatabase.<op>anddatabase.<type>.<op>forms including the.errorcounters, plus thevault.secrets.database.backend.pluginInstances.countgauge.Backward compatibility
IncrCounterWithLabels(key, val, nil)is defined asIncrCounter(key, val)in go-metrics).PluginFactory,PluginFactoryVersion) are unchanged; new inputs are added via an additivePluginFactoryConfig.logical.BackendConfigfields (MountPath,MountNamespace,IncludeMountPointInMetrics) are additive and optional.Testing
namespace,mount_point,connection_name), and that metric names are unchanged.postgresql-database-pluginprocess, creates a connection, and asserts the labels appear only when opted in and are absent by default.BackendConfig.gofmtclean; both the root andsdkmodules build; affected suites pass.Known limitations / follow-ups
namespacelabel uses the telemetry-normalized value (rootfor the root namespace), consistent with other Vault per-mount metrics.Related
database.{NAME}.*telemetry is keyed by plugin type, not by mount or connection name (docs inaccuracy + request for per-mount labels) #32077. This PR implements the feature-request portion — opt-in per-namespace / per-mount / per-connection telemetry labels for the database secrets engine.Closesthat issue: the documentation inaccuracy it also reports (the docs describedatabase.{NAME}.*as the named engine, when{NAME}is the plugin type —pgxfor PostgreSQL) lives inhashicorp/web-unified-docsand needs a separate docs PR. Leaving the issue open tracks that remaining work.TODO only if you're a HashiCorp employee
Backport Labels: If this fix needs to be backported, use the appropriate
backport/label that matches the desired release branch.Jira: If this change has an associated Jira, it's referenced either in the PR description, commit message, or branch name.
RFC: If this change has an associated RFC, please link it in the description.
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
Not applicable — the change is stateless (no storage, schema, or data migrations). Reverting the pull request fully reverts the behavior; with the option disabled, no metric output changes at all.
If applicable, I've documented the impact of any changes to security controls.
This change adds optional telemetry labels; it does not alter authentication, authorization, or any access-control path. When an operator explicitly enables
add_mount_point_database_metrics, the mount path, namespace, and configured connection name become visible as metric labels wherever telemetry is already exposed (for example thesys/metricsendpoint or a configured sink). This is opt-in and off by default, metric names are unchanged, and time-series cardinality remains under operator control since it scales with the number of configured connections.