静态配置
默认情况下,prometheus 配置在 默认配置 中预先配置。
要自定义这些值,请将相应的配置添加到 config.yaml。例如:
plugin_attr:
prometheus: # Plugin: prometheus attributes
export_uri: /apisix/prometheus/metrics # Set the URI for the Prometheus metrics endpoint.
metric_prefix: apisix_ # Set the prefix for Prometheus metrics generated by APISIX.
enable_export_server: true # Enable the Prometheus export server.
export_addr: # Set the address for the Prometheus export server.
ip: 127.0.0.1 # Set the IP.
port: 9091 # Set the port.
fetch_metric_timeout: 5 # Only available in API7 Enterprise.
# Timeout for fetching metrics in seconds. If exceeded, the API only returns
# basic metrics, including nginx_http_current_connections, http_requests_total,
# etcd_reachable, prometheus_disable, node_info, etcd_modify_indexes,
# shared_dict_capacity_bytes, and shared_dict_free_space_bytes.
allow_degradation: false # Only available in API7 Enterprise.
# If true, allow degradation when shared memory is insufficient.
degradation_pause_steps: [ 60 ] # Only available in API7 Enterprise.
# Time to skip the execution of the plugin in seconds when the plugin is in
# degradation while reclaiming the shared memory used by the plugin.
# metrics: # Create extra labels for metrics.
# http_status: # These metrics will be prefixed with `apisix_`.
# extra_labels: # Set the extra labels for http_status metrics.
# - upstream_addr: $upstream_addr
# - status: $upstream_status
# expire: 0 # The expiration time of metrics in seconds.
# 0 means the metrics will not expire.
# http_latency:
# extra_labels: # Set the extra labels for http_latency metrics.
# - upstream_addr: $upstream_addr
# expire: 0 # The expiration time of metrics in seconds.
# 0 means the metrics will not expire.
# bandwidth:
# extra_labels: # Set the extra labels for bandwidth metrics.
# - upstream_addr: $upstream_addr
# expire: 0 # The expiration time of metrics in seconds.
# 0 means the metrics will not expire.
# default_buckets: # Set the default buckets for the `http_latency` metrics histogram.
# - 10
# - 50
# - 100
# - 200
# - 500
# - 1000
# - 2000
# - 5000
# - 10000
# - 30000
# - 60000
# - 500
你可以使用 内置变量 来创建 extra_labels。有关更多详细信息,请参阅 添加额外标签。
重新加载 APISIX 以使更改生效。
参数
请参阅 插件通用配置 了解所有插件可用的配置选项。
prefer_name
boolean
default:
false如果为 true,则在 Prometheus 指标中导出路由/服务名称而不是其 ID。
插件元数据
以下插件元数据仅在 API7 企业版中可用。
disabled_labels
object
应禁用的标签,以减少指标数量并防止资源瓶颈。
status
array[string]
vaild vaule:
Any combination of
code,route,route_id,matched_uri,matched_host,service,service_id,consumer, andnode要禁用的标签的状态。
latency
array[string]
vaild vaule:
Any combination of
type,route,route_id,service,service_id,consumer, andnode要禁用的标签的延迟。
bandwidth
array[string]
vaild vaule:
Any combination of
type,route,route_id,service,service_id,consumer, andnode要禁用的标签的带宽。