跳转到内容

指标参考

Nantian Gateway 的控制面和数据面各自暴露 Prometheus 指标。本文档列出所有关键指标及其含义。

控制面指标在 /metrics 端点暴露,可通过 nantian-controlplane-metrics Service 访问。

指标名类型说明
nantian_gateway_controlplane_builds_totalCounter快照构建次数
nantian_gateway_controlplane_build_failuresCounter快照构建失败次数
nantian_gateway_controlplane_published_totalCounter快照发布(推送到数据面)次数
nantian_gateway_controlplane_last_build_successGauge最近一次构建是否成功(1=成功,0=失败)
nantian_gateway_controlplane_snapshot_build_duration_secondsHistogram快照构建耗时
nantian_gateway_controlplane_snapshot_resource_countHistogramVec快照中各类资源的数量分布

snapshot_resource_countresource 标签可选值包括:GatewayHTTPRouteGRPCRouteTCPRouteServiceEndpointSliceSecretAIServiceTokenPolicyWasmPlugin

指标名类型说明
nantian_gateway_controlplane_xds_snapshot_fanout_coalesced_totalCounter合并的快照推送次数
nantian_gateway_controlplane_xds_stream_terminations_totalCounterVecxDS 流终止次数,按原因分类
nantian_gateway_controlplane_xds_status_report_rejections_totalCounterVec状态报告拒绝次数,按原因分类
nantian_gateway_controlplane_xds_snapshot_send_duration_secondsHistogram快照推送耗时
nantian_gateway_controlplane_xds_snapshot_send_timeouts_totalCounter快照推送超时次数
nantian_gateway_controlplane_xds_snapshot_ack_timeouts_totalCounter等待数据面 ACK 超时次数
nantian_gateway_controlplane_xds_publish_ack_lag_secondsHistogram从发布到收到 ACK 的延迟
nantian_gateway_controlplane_xds_publish_nack_lag_secondsHistogram从发布到收到 NACK 的延迟

流终止原因(reason 标签):shutdownclient_disconnectstream_errorsend_timeoutack_timeoutsupersededinvalid_requestother

状态报告拒绝原因(reason 标签):shutdowninvalid_requestunknown_nodeother

指标名类型说明
nantian_gateway_controlplane_node_status_persist_queue_depthGauge节点状态持久化队列深度
nantian_gateway_controlplane_node_status_persist_pending_nodesGauge待持久化的节点数量
nantian_gateway_controlplane_node_status_persist_enqueued_totalCounter入队的事件总数
nantian_gateway_controlplane_node_status_persist_dropped_totalCounter丢弃的事件总数
nantian_gateway_controlplane_node_status_persist_immediate_totalCounter立即持久化次数
nantian_gateway_controlplane_node_status_persist_debounced_totalCounter防抖后持久化次数
nantian_gateway_controlplane_node_status_persist_flush_duration_secondsHistogram持久化写入耗时
指标名类型说明
nantian_gateway_controlplane_reconciler_runner_runs_totalCounterReconciler 运行次数
nantian_gateway_controlplane_reconciler_runner_failures_totalCounterReconciler 失败次数
nantian_gateway_controlplane_reconciler_runner_last_run_successGauge最近一次运行是否成功
nantian_gateway_controlplane_reconciler_runner_run_duration_secondsHistogramVecReconciler 运行耗时
nantian_gateway_controlplane_reconciler_runner_queue_depthGauge队列深度
nantian_gateway_controlplane_reconciler_runner_trigger_enqueued_totalCounter触发入队次数
nantian_gateway_controlplane_reconciler_runner_trigger_deduped_totalCounter触发去重次数
nantian_gateway_controlplane_reconciler_runner_trigger_settled_totalCounter结算触发次数
nantian_gateway_controlplane_reconciler_runner_settle_pendingGauge待结算的触发数
nantian_gateway_controlplane_reconciler_runner_retries_scheduled_totalCounter重试调度次数
nantian_gateway_controlplane_reconciler_runner_retry_pendingGauge待重试任务数

reconciler_runner_run_duration_secondsscope 标签可选值:infrastatusgateway_statusroute_statuspolicy_status

指标名类型说明
nantian_gateway_controlplane_admin_requests_totalCounterVecAdmin API 请求数,按 method、route、status_class 分类
nantian_gateway_controlplane_admin_request_duration_secondsHistogramVecAdmin API 请求延迟

status_class 标签根据 HTTP 状态码派生:2xx3xx4xx5xx

数据面指标在 :19080/metrics 端点暴露,可通过 nantian-dataplane-metrics Service 访问。

指标名类型说明
nantian_gateway_dataplane_readyGauge数据面就绪状态(1=就绪,0=未就绪),per-pod gauge
nantian_gateway_dataplane_runtime_supervisor_http_statesGaugeHTTP 运行时状态(1=运行中,0=未运行)
nantian_gateway_dataplane_traffic_request_events_totalCounter请求事件总数
nantian_gateway_dataplane_traffic_response_flags_totalCounterVec响应标志,按 flag 分类
nantian_gateway_dataplane_traffic_response_duration_secondsHistogram请求延迟分布
nantian_gateway_dataplane_traffic_response_size_bytesHistogram响应体大小分布
指标名类型说明
nantian_gateway_dataplane_traffic_upstream_connect_duration_secondsHistogram上游连接建立耗时
nantian_gateway_dataplane_traffic_upstream_failures_totalCounterVec上游连接失败次数
nantian_gateway_dataplane_traffic_retry_events_totalCounterVec重试事件次数
nantian_gateway_dataplane_traffic_pool_reuse_ratioGauge连接池复用率
指标名类型说明
nantian_gateway_dataplane_runtime_listener_reloads_totalCounter监听器重载次数
nantian_gateway_dataplane_runtime_circuit_breaker_openGauge熔断器打开状态
nantian_gateway_dataplane_runtime_overload_rejections_totalCounter过载拒绝次数
nantian_gateway_dataplane_runtime_rate_limit_rejections_totalCounter限流拒绝次数
nantian_gateway_dataplane_runtime_endpoint_healthGauge端点健康状态

控制面和数据面需要配置独立的抓取 job。项目提供了两种配置方式:

配置文件位于 deploy/observability/prometheus/native/

  • prometheus-controlplane-scrape.yaml:控制面指标抓取配置
  • prometheus-dataplane-scrape.yaml:数据面指标抓取配置
  • prometheus-dataplane-rules.yaml:数据面 Recording Rules

每个抓取配置文件包含两种服务发现模式的示例:

  • endpoints:基于 Endpoints 的服务发现
  • endpointslice:基于 EndpointSlice 的服务发现

选择一种模式,将对应的 scrape_configs 块复制到你的 prometheus.yml 中。不要同时使用两种模式,否则会重复抓取同一个 Pod。

配置文件位于 deploy/observability/prometheus/operator/

  • servicemonitor-controlplane.yaml:控制面 ServiceMonitor
  • podmonitor-controlplane.yaml:控制面 PodMonitor
  • servicemonitor-dataplane.yaml:数据面 ServiceMonitor
  • podmonitor-dataplane.yaml:数据面 PodMonitor
  • prometheusrule-dataplane.yaml:数据面 PrometheusRule
  • secret-dataplane-admin-token.example.yaml:数据面 Admin Token Secret 示例
  • networkpolicy-prometheus-scrape.yaml:允许 Prometheus 抓取流量的 NetworkPolicy

同样,每个平面只选择 ServiceMonitor 或 PodMonitor 中的一种。

数据面 Recording Rules 预计算了常用的聚合指标,减少 Grafana 查询的计算开销:

规则名说明
nantian_gateway_dataplane_ready_replicas就绪的数据面副本数
nantian_gateway_dataplane_targets数据面抓取目标数
nantian_gateway_dataplane_not_ready_replicas未就绪的数据面副本数
nantian_gateway_dataplane_container_cpu_cores数据面容器 CPU 使用(核)
nantian_gateway_dataplane_container_cpu_request_cores数据面容器 CPU 请求值
nantian_gateway_dataplane_container_cpu_throttle_ratioCPU 限流比例
nantian_gateway_dataplane_container_memory_working_set_bytes内存工作集大小
nantian_gateway_dataplane_container_memory_limit_bytes内存限制
nantian_gateway_dataplane_container_memory_request_bytes内存请求值
这些 Recording Rules 依赖 cAdvisor 的 container_* 指标和 kube-state-metrics 的 kube_pod_container_resource_* 指标,确保这些数据源已正确配置。