a6-plugin-prometheus
概览
prometheus 插件以 Prometheus 文本格式暴露 Apache APISIX指标,包括 HTTP 状态码、请求延迟、带宽、上游健康状态和系统状态。Apache APISIX提供内置指标端点,可由 Prometheus 抓取,并使用 Grafana 进行可视化。
适用场景
- 监控每个路由、服务或消费者的请求速率、错误率和延迟。
- 跟踪上游健康检查状态。
- 观察系统整体性能和资源使用情况。
- 使用 Prometheus + Grafana 构建仪表板和告警。
插件配置参考(路由/服务/全局规则)
| 字段 | 类型 | 是否必填 | 默认值 | 说明 |
|---|---|---|---|---|
prefer_name | boolean | 否 | false | 在指标标签中使用路由/服务名称而不是 ID |
该插件的路由级配置很少,大多数选项在 APISIX config.yaml 中管理。
导出的指标
核心指标
| 指标 | 类型 | 描述 |
|---|---|---|
apisix_http_status | 计数器 | 按路由、服务和消费者统计的 HTTP 状态码 |
apisix_http_latency | 直方图 | 请求延迟(毫秒),类型包括 request、upstream 和 apisix |
apisix_bandwidth | 计数器 | 带宽(字节),类型包括 ingress 和 egress |
apisix_http_requests_total | 仪表 | 收到的 HTTP 请求总数 |
apisix_nginx_http_current_connections | 仪表 | 按状态分列的当前连接 |
apisix_upstream_status | 仪表 | 上游健康状态(1 表示健康,0 表示不健康) |
apisix_etcd_reachable | 仪表 | etcd 可达性(1 表示可达,0 表示不可达) |
apisix_etcd_modify_indexes | 仪表 | etcd 修改次数 |
apisix_node_info | 仪表 | APISIX 节点主机名和版本 |
apisix_shared_dict_capacity_bytes | 仪表 | 共享内存容量 |
apisix_shared_dict_free_space_bytes | 仪表 | 共享内存空闲空间 |
apisix_stream_connection_total | 计数器 | TCP/UDP 流连接总数 |