Skip to content

database_observability: add cloud provider labels to all metrics#4942

Merged
matthewnolf merged 1 commit intomainfrom
mn/csp-labels-2
Dec 10, 2025
Merged

database_observability: add cloud provider labels to all metrics#4942
matthewnolf merged 1 commit intomainfrom
mn/csp-labels-2

Conversation

@matthewnolf
Copy link
Contributor

@matthewnolf matthewnolf commented Nov 26, 2025

PR Description

This change adds cloud provider information as labels to all metrics exported by the database_observability components. This enables more effective correlation and attribution across Grafana Cloud.

Some of the implementation is duplicated across MySQL and Postgres components. The reasoning being that cloud-providers sometimes vary their naming / URI structure to include engine information. Keeping things strongly tied to the database engine helps make this determination easier.

Which issue(s) this PR fixes

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@matthewnolf matthewnolf marked this pull request as ready for review November 27, 2025 13:52
@matthewnolf matthewnolf requested a review from a team as a code owner November 27, 2025 13:52
Copy link
Contributor

@fridgepoet fridgepoet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need a changelog entry as well?

@gaantunes
Copy link
Contributor

Will this remove the need for the arn config?

} else {
cloudProvider, err := populateCloudProviderFromDSN(string(c.args.DataSourceName))
if err != nil {
c.reportError("failed to collect cloud provider information from config", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we differentiate the error message across the two cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b48a715

cloudProvider.AWS = &database_observability.AWSCloudProviderInfo{
ARN: arn.ARN{
Resource: fmt.Sprintf("db:%s", matches[1]),
Region: matches[3],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we should check matches before accessing it (here and later for Azure)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b48a715

} else {
cloudProvider, err := populateCloudProviderFromDSN(string(c.args.DataSourceName))
if err != nil {
c.reportError("failed to collect cloud provider information from config", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: error message is repeated here as well

Suggested change
c.reportError("failed to collect cloud provider information from config", err)
c.reportError("failed to collect cloud provider information from DSN", err)

@matthewnolf matthewnolf requested a review from a team as a code owner December 9, 2025 16:02
@matthewnolf
Copy link
Contributor Author

Will this remove the need for the arn config?

No, we will still use the arn if it is configured.

@matthewnolf matthewnolf merged commit 166829e into main Dec 10, 2025
43 checks passed
@matthewnolf matthewnolf deleted the mn/csp-labels-2 branch December 10, 2025 13:52
dehaansa pushed a commit to iamrajiv/alloy that referenced this pull request Dec 10, 2025
dehaansa pushed a commit to madhub/alloy that referenced this pull request Dec 10, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants