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 runtime metrics to prometheus #82

Open
vkuznet opened this issue Sep 9, 2022 · 6 comments
Open

Add runtime metrics to prometheus #82

vkuznet opened this issue Sep 9, 2022 · 6 comments

Comments

@vkuznet
Copy link
Contributor

vkuznet commented Sep 9, 2022

Following approach of https://github.com/arl/statsviz/tree/1ff44fae9a7555de21fe9ad6fa09787373cf23fa we can add runtime metrics to our metrics endpoint and expose them to Prometheus. For that we should get runtime.MemStats object and convert it to our metrics code base web/metrics.go

The list of supported runtime metrics can be found here

@d-ylee
Copy link
Contributor

d-ylee commented Dec 19, 2022

For this, are we converting the values in runtime.MemStats, then formatting it in accordance to Prometheus metrics? Would these be steps to add this to our metrics endpoint?

  1. Add the runtime metrics as fields to the Metrics struct:

    type Metrics struct {

  2. Then add the metrics to the struct:

    func metrics() Metrics {

  3. Then format the metrics so that Prometheus would be happy parsing them?

    func promMetrics(prefix string) string {

@vkuznet
Copy link
Contributor Author

vkuznet commented Dec 20, 2022

yes, it is correct procedure.

@d-ylee d-ylee self-assigned this Jan 6, 2023
@d-ylee d-ylee changed the title Add runtime metircs to prometheus Add runtime metrics to prometheus Jan 12, 2023
@d-ylee
Copy link
Contributor

d-ylee commented Feb 1, 2023

@vkuznet I tried this method using Prometheus' Go Client. I implemented this temporarily on the /runtimemetrics endpoint Would this be something we want to use?
d-ylee@0619377

@vkuznet
Copy link
Contributor Author

vkuznet commented Feb 2, 2023

Dennis, the new code looks solid to me, and since you implemented new metrics on dedicated end-point we can proceed with their deployment and build new dashboard for them. Then, we can compare existing dashboard with new one, and, finally, merge them together. Feel free to merge and proceed with deployment on testbed. But since you put them on dedicated end-point we'll need an additional exporter to scrape them for Prometheus since k8s manifest file only allow single end-point/port to use via annotations, see https://github.com/dmwm/CMSKubernetes/blob/master/kubernetes/cmsweb/services/dbs2go-global-r.yaml#L60-L62

@d-ylee
Copy link
Contributor

d-ylee commented Feb 2, 2023

@vkuznet Would it be an issue if the metrics scraped have the same name as the original metric? Or should I modify the prefix on the new endpoint?

@vkuznet
Copy link
Contributor Author

vkuznet commented Feb 2, 2023

Even though Promeethes us very flexible I think it would be wise to setup originally different prefix. In a long run you want to merge both metrics under single end-point and having single prefix but until everything is tested I do not want to break existing (production) dashboards, e.g. https://monit-grafana.cern.ch/d/kJOvR2h7k/dbs2go?orgId=11

@d-ylee d-ylee removed their assignment Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants