prometheus plugin publicly exposes metrics, even if not enabled
I'm a beginner and want to return a 404 for a request to http://mydomain.example/apisix/prometheus/metrics.
Additional to the issues (linked below) about exposing metrics publicly, which I find problematic too, they are even exposed if the Prometheus plugin is not enabled (I mean "enabled" by following https://github.com/apache/apisix/blob/master/doc/plugins/prometheus.md ).
To get a 404, I have to open config.yaml and uncomment - prometheus the plugin, even if I didn't enable anything.
Instead I think it should be the default. In case there are reasons for this, could you provide a list of plugins that publicly expose paths?
When I query /apisix/admin/routes, I don't see /apisix/prometheus/metrics, even though the route exists. How can I find these routes? I'm concerned there are more exposed routes I'm not aware of.
Related:
https://github.com/apache/apisix/issues/1509 https://github.com/apache/apisix/issues/2296
@poidl Thank you very much for your reminder, I think we need to solve this issue in version 2.0 .
Hi, thanks for the advice. The Prometheus metrics usually use another port to expose the service instead of a business port, such as controller, scheduler, ingress, etc., which is a new non-business port to expose the service.
Currently, Apache APISIX uses the 80/443 port to expose the metrics service, which is unreasonable and may have information leakage risk, but I suggest to merge it into the Apache APISIX project as a feature after full discussion of the technical solution.
I see, thanks!
I lack the technical background to participate in a full discussion. The important thing for me is that APISIX exposes a route only if I explicitly tell it to do so.
What about serving the metrics at 9101 (or some other port), and if you want to expose it on 80/443, just define the 9101 as upstream and define a route /apisix/prometheus/metrics as usual? Would this defeat the purpose of a metrics tool, in the sense that it should even be accessible if apisix is cannot or does not serve routes as usual for some reason. For example, would there be a requirement for metrics logging before any route has been defined?
In that case the only solution I could think of is deploying a separate reverse proxy that exposes 9101 on 80/443, independent of apisix.
ping @membphis
@poidl https://github.com/apache/apisix/blob/master/doc/plugin-interceptors.md#plugin-interceptors
please take a look at this doc, make a try.
I think we can close #1509 #2296 now, waiting for your response.
Great, thanks! Ok from my side this can be closed. I'll try the new feature and open another issue in case I have trouble using the interceptors!