diff --git a/conf/config.yaml.example b/conf/config.yaml.example index d6846642f234..99af131d198c 100644 --- a/conf/config.yaml.example +++ b/conf/config.yaml.example @@ -611,8 +611,9 @@ plugin_attr: # Plugin attributes # - 100 # - 200 # - 500 - # expire: 0 # The expiration time after metrics become inactive, unit: second. - # 0 means the metrics will not expire + # expire: 0 # The expiration time of metrics in seconds. + # 0 means the metrics will not expire. + # Only affect apisix_http_status, apisix_bandwidth, and apisix_http_latency. # If you need to set the expiration time, it is recommended to use 600, which is 10 minutes. server-info: # Plugin: server-info report_ttl: 60 # Set the TTL in seconds for server info in etcd. diff --git a/docs/en/latest/plugins/prometheus.md b/docs/en/latest/plugins/prometheus.md index 7d3982bb0f9f..3200fb48a09c 100644 --- a/docs/en/latest/plugins/prometheus.md +++ b/docs/en/latest/plugins/prometheus.md @@ -96,6 +96,18 @@ plugin_attr: - 505 ``` +### Specifying `expire` + +`expire` sets the expiration time of `apisix_http_status`, `apisix_bandwidth`, and `apisix_http_latency` metrics in seconds. When set to 0, metrics will not expire. + +Here is a configuration example: + +```yaml title="conf/config.yaml" +plugin_attr: + prometheus: + expire: 86400 +``` + ## Metrics endpoint This Plugin will add the metrics endpoint `/apisix/prometheus/metrics` or your custom export URI for exposing the metrics. diff --git a/docs/zh/latest/plugins/prometheus.md b/docs/zh/latest/plugins/prometheus.md index 3029b7556370..39720704d289 100644 --- a/docs/zh/latest/plugins/prometheus.md +++ b/docs/zh/latest/plugins/prometheus.md @@ -43,7 +43,7 @@ description: 本文将介绍 API 网关 Apache APISIX 如何通过 prometheus ::: -## 如何修改暴露指标的 uri +### 如何修改暴露指标的 `export_uri` 你可以在配置文件 `./conf/config.yaml` 的 `plugin_attr` 列表下修改默认的 URI。 @@ -78,6 +78,18 @@ plugin_attr: - 505 ``` +### 如何修改指标的 `expire` + +`expire` 用于设置 `apisix_http_status`、`apisix_bandwidth` 和 `apisix_http_latency` 指标的过期时间(以秒为单位)。当设置为 0 时,指标不会过期。 + +配置示例如下: + +```yaml title="conf/config.yaml" +plugin_attr: + prometheus: + expire: 86400 +``` + ## API `prometheus` 插件会增加 `/apisix/prometheus/metrics` 接口或者你自定义的 URI 来暴露其指标信息。