apisix icon indicating copy to clipboard operation
apisix copied to clipboard

request help: about prometheus metrics for deny access

Open tiger333777 opened this issue 6 years ago • 7 comments

Issue description

Question 1: monitoring address of apisix Prometheus: http://xx.yy.com/apisix/prometheus/metrics How does Prometheus restrict IP access or /apifix/Prometheus/ metrics to some monitoring servers Question 2: Prometheusmonitoring address: http://xx.yy.com/apisix/prometheus/metrics Can I reduce /apifix/Prometheus/metrics to /metrics

问题1:apisix prometheus 的监控地址:http://xx.yy.com/apisix/prometheus/metrics prometheus 怎么限制IP访问,或是全局的 /apisix/prometheus/metrics 限制到某些监控服务器上 问题2: 普米监控地址:http://xx.yy.com/apisix/prometheus/metrics 能否将 /apisix/prometheus/metrics 减缩为/metrics,要怎么做

Environment

  • apisix version (cmd: apisix version):apisix 1.5
  • OS:centos 7

tiger333777 avatar Sep 24 '20 03:09 tiger333777

ping @membphis Do these two issues need a new feat to solve?

idbeta avatar Nov 05 '20 09:11 idbeta

问题1:apisix prometheus 的监控地址:http://xx.yy.com/apisix/prometheus/metrics prometheus 怎么限制IP访问,或是全局的 /apisix/prometheus/metrics 限制到某些监控服务器上

you can take a look at this doc: https://github.com/apache/apisix/blob/master/doc/plugin-interceptors.md#plugin-interceptors

welcome to add this link to Prometheus plugin doc.

问题2: 普米监控地址:http://xx.yy.com/apisix/prometheus/metrics 能否将 /apisix/prometheus/metrics 减缩为/metrics,要怎么做

not support now. you need to update the source code of the plugin Prometheus.

another way, add a new field and allow the users to specify the export URI path.

membphis avatar Nov 05 '20 13:11 membphis

问题2: 普米监控地址:http://xx.yy.com/apisix/prometheus/metrics 能否将 /apisix/prometheus/metrics 减缩为/metrics,要怎么做

support to specify the export path, how abou this way?

plugin_attr:
  promethus:
    export_uri: /apisix/prometheus/metrics 

membphis avatar Nov 05 '20 13:11 membphis

Look like we need to distinguish plugin attr (which need to reload to take effect) and plugin metadata (which don't need to reload). And we need to consider the plugin attr when we check if the plugin version is changed during loading plugins.

spacewander avatar Nov 06 '20 01:11 spacewander

I think we can remove plugin_attr finally.

I love plugin metadata way.

for this issue, we can add new field export_uri: /apisix/prometheus/metrics via plugin metadata.

membphis avatar Nov 06 '20 15:11 membphis

plugin attr is for configuration which need to take effect via the init function, like skywalking background timer and this one. It need to have the same lifecyle as the plugin lists (updated via reload). Therefore we can't remove it.

spacewander avatar Nov 07 '20 10:11 spacewander

plugin attr is mainly for providing the default value, we can use the default value of plugin metadata to support this too.

here is an example: https://github.com/apache/apisix/blob/master/apisix/plugins/http-logger.lua#L61

if the admin user did not set any new value, then the plugin will use the default value(same as plugin attr).

if the admin user set a new value by plugin metadata API, then the plugin will use the new value.

membphis avatar Nov 08 '20 03:11 membphis