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

Export site metrics in Prometheus #727

Closed
wants to merge 4 commits into from
Closed

Conversation

labkode
Copy link
Member

@labkode labkode commented May 8, 2020

Run like this:

red:reva gonzalhu$ cmd/revad/revad -c examples/metrics/metrics.toml

Test like this:

red:reva gonzalhu$ curl http://0.0.0.0:9998/metrics
# HELP revad_opencensus_io_http_server_request_count Count of HTTP requests started
# TYPE revad_opencensus_io_http_server_request_count counter
revad_opencensus_io_http_server_request_count 1
# HELP revad_opencensus_io_http_server_request_count_by_method Server request count by HTTP method
# TYPE revad_opencensus_io_http_server_request_count_by_method counter
revad_opencensus_io_http_server_request_count_by_method{http_method="GET"} 1

You may want to copy this branch into one of yours

@redblom
Copy link
Contributor

redblom commented May 13, 2020

@labkode Is it possible to make the site metrics to somehow show up between the current prometheus service metrics (displayed through the exporter). I can only get them displayed if I let the current prometheus service New() function simply return with a promhttp.Handler() and remove/ignore the exporter code. Like so:
return &svc{prefix: conf.Prefix, h: promhttp.Handler()}, nil

@redblom redblom mentioned this pull request May 15, 2020
@labkode
Copy link
Member Author

labkode commented May 18, 2020

@ishank011 can you please take a look a this corner?

@ishank011
Copy link
Contributor

@labkode Will look at it 👍

@labkode labkode requested a review from ishank011 May 18, 2020 08:49
@ishank011
Copy link
Contributor

ishank011 commented May 18, 2020

@labkode @redblom We can define the metrics in the metrics package as has been done in #740, and then import those in the prometheus HTTP service and register them as separate views as done here, and then initialize the counters. Initializing is important, otherwise the metrics don't show. In the metrics pkg, we can define the methods to update the stats.

And since we're using opencensus metrics in the prometheus service, it'd be better in my opinion if we can use the go.opencensus.io/stats package to store these, like done here.

@redblom
Copy link
Contributor

redblom commented May 25, 2020

@ishank011 Thank you for the explanation. I can implement this fine, this works.
@labkode I pushed the new commits.

@ishank011 ishank011 closed this May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants