apisix icon indicating copy to clipboard operation
apisix copied to clipboard

prometheus plugin publicly exposes metrics, even if not enabled

Open poidl opened this issue 6 years ago • 6 comments

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 avatar Oct 06 '20 17:10 poidl

@poidl Thank you very much for your reminder, I think we need to solve this issue in version 2.0 .

membphis avatar Oct 07 '20 03:10 membphis

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.

Miss-you avatar Oct 20 '20 09:10 Miss-you

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.

poidl avatar Oct 27 '20 10:10 poidl

ping @membphis

moonming avatar Oct 29 '20 11:10 moonming

@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.

membphis avatar Oct 30 '20 14:10 membphis

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!

poidl avatar Nov 01 '20 20:11 poidl