Skip to content
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 database_observability.mysql component #2053

Merged
merged 35 commits into from
Nov 26, 2024
Merged

Add database_observability.mysql component #2053

merged 35 commits into from
Nov 26, 2024

Conversation

cristiangreco
Copy link
Collaborator

@cristiangreco cristiangreco commented Nov 7, 2024

PR Description

Add new component database_observability.mysql.

Which issue(s) this PR fixes

Relates to #1827

Notes to the Reviewer

PR Checklist

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

@cristiangreco cristiangreco force-pushed the feat-dbo11y-component branch 4 times, most recently from b65a89c to 9472049 Compare November 14, 2024 09:45
@cristiangreco cristiangreco changed the title [draft] Add dbo11y component [draft] Add db-o11y component Nov 14, 2024
@cristiangreco cristiangreco force-pushed the feat-dbo11y-component branch 3 times, most recently from 852d168 to 21028c3 Compare November 14, 2024 15:52
@cristiangreco cristiangreco changed the title [draft] Add db-o11y component [draft] Add grafanacloud.database_observability component Nov 14, 2024
@cristiangreco cristiangreco force-pushed the feat-dbo11y-component branch 4 times, most recently from 71331b1 to be1f752 Compare November 21, 2024 14:52
@cristiangreco cristiangreco marked this pull request as ready for review November 21, 2024 17:35
@cristiangreco cristiangreco changed the title [draft] Add grafanacloud.database_observability component Add grafanacloud.database_observability component Nov 21, 2024
Copy link
Collaborator

@matthewnolf matthewnolf left a comment

Choose a reason for hiding this comment

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

LGTM on the SQL collector part!

@clayton-cornell clayton-cornell added the type/docs Docs Squad label across all Grafana Labs repos label Nov 21, 2024
Copy link
Contributor

@wildum wildum left a comment

Choose a reason for hiding this comment

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

Nice work, looking forward to see the cool features that this component can enable!

docs/sources/reference/components/grafanacloud/_index.md Outdated Show resolved Hide resolved
}

type Exports struct {
Targets []discovery.Target `alloy:"targets,attr"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that this component should expose targets to be scrapped. If you want this component to expose its own metrics you can use the Registerer that's part of the component options that you get in the New() function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My understanding is that opts.Registerer is for metrics regarding the component itself. If I switch to using opts.Registerer then the connection_info metric is available at http://localhost:12345/metrics.

Our intention is to expose metrics that can be piped into a remote write, e.g.

grafanacloud.database_observability.mysql "orders_db" {
  data_source_name = "mysql:3306"
  forward_to = [loki.write.logs_service.receiver] // not used in this example
}

prometheus.scrape "orders_db" {
  targets = grafanacloud.database_observability.mysql.orders_db.targets
  honor_labels = true
  forward_to = [prometheus.remote_write.metrics_service.receiver]
}

prometheus.remote_write "metrics_service" {
  endpoint {
    url = sys.env("GCLOUD_HOSTED_METRICS_URL")
    basic_auth {
      username = sys.env("GCLOUD_HOSTED_METRICS_ID")
      password = sys.env("GCLOUD_RW_API_KEY")
    }
  }
}

Is there a different way of doing this?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's correct, but given that you are planning to use the existing exporter for the metrics + that you only have the "connection_info" as a metric here, I thought that it would fit as a metric regarding the component itself. If you want to expose more metrics from this component in the future and you think that it doesn't fit as metrics about the component itself then you can expose them the way you did

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We want the metrics to come out of database_observability.mysql (or whatever final name). If we create them as metrics attached to the component itself then one would need to scrape the Alloy /metrics endpoint to ingest those metrics, right? It's not what we want in this case: don't think the discriminator should be the fact we currently have only 1 metric, as it pushes us toward a totally different usage model.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes that's correct. I get your point and that's ok if you want to go this way. I do think that the amount of metrics you have matters a bit in the solution because if it stays with one metric that's actually a constant then it seems overkill to have the scrape complexity in the component + require the need to scrape this component just for this one info. But if you think that you might add more metrics to it later and that it would be worth it for users to scrape it then that's totally fine.

Also it may not work with clustering if the target is not exactly the same across all instances (not sure if that's the case or not for you. If it is then it should be warned in the doc because this is a common pitfall that confuses users)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not planning to make this work for clustering. I do see your point about the number of metrics, I think we want to keep the door open for now and have this component produce its own metrics. Things will be more clear once we approach moving out of "experimental".

@cristiangreco cristiangreco force-pushed the feat-dbo11y-component branch 3 times, most recently from 6b3702a to 084baff Compare November 25, 2024 17:10
@cristiangreco cristiangreco changed the title Add grafanacloud.database_observability component Add database_observability.mysql component Nov 25, 2024
@cristiangreco
Copy link
Collaborator Author

@wildum I think all major points are addressed and what's left is probably not a blocker for merging this PR? Could you please take another look?

Copy link
Contributor

@wildum wildum left a comment

Choose a reason for hiding this comment

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

Thanks for working on the feedback, I just have a few little comments left and then we can merge it

@cristiangreco cristiangreco requested a review from wildum November 26, 2024 15:22
@wildum wildum merged commit c92ae07 into main Nov 26, 2024
18 checks passed
@wildum wildum deleted the feat-dbo11y-component branch November 26, 2024 15:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age type/docs Docs Squad label across all Grafana Labs repos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants