-
Notifications
You must be signed in to change notification settings - Fork 63
Serve Prometheus metrics on a separate port; fix metrics development workflow #2093
Conversation
Storybook and Tailwind configuration previews: Ready Storybook: https://wordpress.github.io/openverse-frontend/_preview/2093 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
Size Change: -286 B (0%) Total Size: 896 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this PR both in dev and in prod, and it works as expected.
My only (non-blocking) suggestion is to extract Prometheus code into a separate module. I tried doing that in #2109. I think this will make the transition to Nuxt 3 a little bit easier, and the nuxt config file cleaner.
Based on the low urgency of this PR, the following reviewers are being gently reminded to review this PR: @zackkrida Excluding weekend1 days, this PR was updated 5 day(s) ago. PRs labelled with low urgency are expected to be reviewed within 5 weekday(s)2. @sarayourfriend, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings. Footnotes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the inline docs, they're helpful.
Description
Prometheus metrics generally should not be served on a public endpoint. The easiest way to make the metrics publicly inaccessible is to serve them on an entirely separate port. This allows us to easily make security group changes that only allow services internal to our VPC (specifically, Grafana Agent) to access the metrics endpoints.
In the process, I also went ahead and fixed some issues with the Prometheus development workflow, namely that its metrics were disabled by default in development due to a persistent crash when the server automatically restarts after changes. To fix this, we just need to de-register all the existing metrics when the server closes. This allows the
express-prom-bundle
middleware to re-register the same metrics without causing name clashes with the metrics registered during the initial start up.Testing Instructions
Checkout the branch and run the app locally using
just run dev
. Run the prod version as well withjust run prod
. Confirm that in both cases, metrics are only accessible atlocalhost:54641
and no longer atlocalhost:8443/metrics
.Checklist
Update index.md
).main
) ora parent feature branch.
errors.
Developer Certificate of Origin
Developer Certificate of Origin