静态配置
默认情况下,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
# llm_latency_buckets: # 自 API7 Enterprise 3.9.7 版本起可用。
# # 在 3.9.14 及后续版本中,这些 buckets 同时适用于 `type=total` 和 `type=ttft`,单位为毫秒。
# - 100
# - 500
# - 1000
# - 5000
# llm_prompt_tokens_buckets: # 自 API7 Enterprise 3.9.14 版本起可用。
# # 设置 `apisix_llm_prompt_tokens_dist` 直方图的 buckets,单位为 token。
# - 100
# - 1000
# - 10000
# llm_completion_tokens_buckets: # 自 API7 Enterprise 3.9.14 版本起可用。
# # 设置 `apisix_llm_completion_tokens_dist` 直方图的 buckets,单位为 token。
# - 100
# - 1000
# - 10000
你可以使用 内置变量 来创建 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,node,request_type,request_llm_model,llm_model,mcp_request_type, andmcp_tool_name要为
apisix_http_status指标禁用的标签。自 API7 Enterprise 3.9.7 版本起,还支持禁用
request_type、request_llm_model和llm_model标签。自 API7 Enterprise 3.9.14 版本起,还支持禁用
mcp_request_type和mcp_tool_name标签。latency
array[string]
vaild vaule:
Any combination of
type,route,route_id,service,service_id,consumer,node,request_type,request_llm_model,llm_model,mcp_request_type, andmcp_tool_name要为
apisix_http_latency指标禁用的标签。自 API7 Enterprise 3.9.7 版本起,还支持禁用
request_type、request_llm_model和llm_model标签。自 API7 Enterprise 3.9.14 版本起,还支持禁用
mcp_request_type和mcp_tool_name标签。bandwidth
array[string]
vaild vaule:
Any combination of
type,route,route_id,service,service_id,consumer,node,request_type,request_llm_model,llm_model,mcp_request_type, andmcp_tool_name要为
apisix_bandwidth指标禁用的标签。自 API7 Enterprise 3.9.7 版本起,还支持禁用
request_type、request_llm_model和llm_model标签。自 API7 Enterprise 3.9.14 版本起,还支持禁用
mcp_request_type和mcp_tool_name标签。llm_latency
array[string]
vaild vaule:
Any combination of
type,route,route_id,service,service_id,consumer,node,request_type,request_llm_model, andllm_model要为
apisix_llm_latency指标禁用的标签。自 API7 Enterprise 3.9.7 版本起可用。
自 API7 Enterprise 3.9.14 版本起,还支持禁用
type标签。llm_prompt_tokens
array[string]
vaild vaule:
Any combination of
route,route_id,matched_uri,matched_host,service,service_id,consumer,node,request_type,request_llm_model, andllm_model要为
apisix_llm_prompt_tokens指标禁用的标签。自 API7 Enterprise 3.9.7 版本起可用。
llm_completion_tokens
array[string]
vaild vaule:
Any combination of
route,route_id,matched_uri,matched_host,service,service_id,consumer,node,request_type,request_llm_model, andllm_model要为
apisix_llm_completion_tokens指标禁用的标签。自 API7 Enterprise 3.9.7 版本起可用。
llm_active_connections
array[string]
vaild vaule:
Any combination of
route,route_id,matched_uri,matched_host,service,service_id,consumer,node,request_type,request_llm_model, andllm_model要为
apisix_llm_active_connections指标禁用的标签。自 API7 Enterprise 3.9.7 版本起可用。
llm_prompt_tokens_dist
array[string]
vaild vaule:
Any combination of
route,route_id,matched_uri,matched_host,service,service_id,consumer,node,request_type,request_llm_model, andllm_model要为
apisix_llm_prompt_tokens_dist指标禁用的标签。自 API7 Enterprise 3.9.14 版本起可用。
llm_completion_tokens_dist
array[string]
vaild vaule:
Any combination of
route,route_id,matched_uri,matched_host,service,service_id,consumer,node,request_type,request_llm_model, andllm_model要为
apisix_llm_completion_tokens_dist指标禁用的标签。自 API7 Enterprise 3.9.14 版本起可用。