-
Notifications
You must be signed in to change notification settings - Fork 18
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
Authentication bearer token #29
Comments
Yabeda exporter extends exporter from Prometheus Ruby client which is a Rack middleware. Probably, easiest way is to just place bearer checking middleware (like this one: https://github.com/yujideveloper/rack-bearer_auth) before exporter with the same path. Something like this: use Rack::BearerAuth::Middleware do
match path: "/metrics", token: "very_secret"
end
use Yabeda::Prometheus::Exporter |
Thank you very much for your quick reply. I may rephrase my question. What is the best practice not to make the metrics path publicly accessible? Especially via a bearer token, or is another way more common? |
hey 👋🏻 here is an idea that I'm using at the moment: constraints ->(request) { request.authorization&.match?(/^Bearer\s+#{ENV.fetch('PROMETHEUS_TOKEN', nil)}$/) } do
mount Yabeda::Prometheus::Exporter, at: "metrics"
end Then |
Thanks for all the work on this great gem. Is there a simple way to protect the "/metrics" endpoint using a bearer token? Or is it the way to go to use a middleware for this? As far as I know, it is possible to configure prometheus server so that you can use bearer token for scraping servers.
The text was updated successfully, but these errors were encountered: