跳到主要内容

OmniPGW 监控与指标指南

Prometheus 集成与操作监控

由 Omnitouch 网络服务提供


目录

  1. 概述
  2. 指标端点
  3. 可用指标
  4. Prometheus 配置
  5. Grafana 仪表板
  6. 警报
  7. 性能监控
  8. 故障排除指标

概述

OmniPGW 提供两种互补的监控方法:

1. 实时 Web UI(在此简要介绍,详细信息见各自的接口文档)

  • 实时会话查看器
  • PFCP 对等状态
  • Diameter 对等连接
  • 单个会话检查

2. Prometheus 指标(本文件的主要焦点)

  • 历史趋势和分析
  • 警报和通知
  • 性能指标
  • 容量规划

本文件专注于 Prometheus 指标。有关 Web UI 的详细信息,请参见:

Prometheus 指标概述

OmniPGW 暴露 与 Prometheus 兼容的指标,以全面监控系统健康、性能和容量。这使得运营团队能够:

  • 监控系统健康 - 跟踪活动会话、分配和错误
  • 容量规划 - 了解资源利用趋势
  • 性能分析 - 测量消息处理延迟
  • 警报 - 主动通知问题
  • 调试 - 确定问题的根本原因

监控架构


指标端点

配置

config/runtime.exs 中启用指标:

config :pgw_c,
metrics: %{
enabled: true,
ip_address: "0.0.0.0", # 绑定到所有接口
port: 9090, # HTTP 端口
registry_poll_period_ms: 5_000 # 轮询间隔
}

访问指标

HTTP 端点:

http://<omnipgw_ip>:<port>/metrics

示例:

curl http://10.0.0.20:9090/metrics

输出格式

指标以 Prometheus 文本格式 暴露:

# HELP teid_registry_count The number of TEID registered to sessions
# TYPE teid_registry_count gauge
teid_registry_count 150

# HELP address_registry_count The number of addresses registered to sessions
# TYPE address_registry_count gauge
address_registry_count 150

# HELP s5s8_inbound_messages_total The total number of messages received from S5/S8 peers
# TYPE s5s8_inbound_messages_total counter
s5s8_inbound_messages_total{message_type="create_session_request"} 1523
s5s8_inbound_messages_total{message_type="delete_session_request"} 1487

可用指标

OmniPGW 暴露以下指标类别:

会话指标

活动会话计数:

指标名称类型描述
teid_registry_countGauge活动 S5/S8 会话(TEID 计数)
seid_registry_countGauge活动 PFCP 会话(SEID 计数)
session_id_registry_countGauge活动 Gx 会话(Diameter Session-ID 计数)
address_registry_countGauge分配的 UE IP 地址
charging_id_registry_countGauge活动计费 ID(请参见 数据 CDR 格式 以获取 CDR 计费记录)

用法:

# 当前活动会话
teid_registry_count

# 会话创建速率(每秒)
rate(teid_registry_count[5m])

# 最近一小时的峰值会话
max_over_time(teid_registry_count[1h])

消息计数器

S5/S8 (GTP-C) 消息:

指标名称类型标签描述
s5s8_inbound_messages_totalCountermessage_type总入站 S5/S8 消息
s5s8_outbound_messages_totalCountermessage_type总出站 S5/S8 消息
s5s8_inbound_errors_totalCountermessage_typeS5/S8 处理错误

消息类型:

  • create_session_request
  • create_session_response
  • delete_session_request
  • delete_session_response
  • create_bearer_request
  • delete_bearer_request

Sxb (PFCP) 消息:

指标名称类型标签描述
sxb_inbound_messages_totalCountermessage_type总入站 PFCP 消息
sxb_outbound_messages_totalCountermessage_type总出站 PFCP 消息
sxb_inbound_errors_totalCountermessage_typePFCP 处理错误

消息类型:

  • association_setup_request
  • association_setup_response
  • heartbeat_request
  • heartbeat_response
  • session_establishment_request
  • session_establishment_response
  • session_modification_request
  • session_deletion_request

Gx (Diameter) 消息:

指标名称类型标签描述
gx_inbound_messages_totalCountermessage_type总入站 Diameter 消息
gx_outbound_messages_totalCountermessage_type总出站 Diameter 消息
gx_inbound_errors_totalCountermessage_typeDiameter 处理错误

消息类型:

  • cca (Credit-Control-Answer)
  • ccr_initial
  • ccr_termination

延迟指标

消息处理时长:

指标名称类型标签描述
s5s8_inbound_handling_durationHistogramrequest_message_typeS5/S8 消息处理时间
sxb_inbound_handling_durationHistogramrequest_message_typePFCP 消息处理时间
gx_inbound_handling_durationHistogramrequest_message_typeDiameter 消息处理时间

桶(微秒):

  • 典型值:100µs, 500µs, 1ms, 5ms, 10ms, 50ms, 100ms, 500ms, 1s, 5s

用法:

# 95th 百分位 S5/S8 延迟
histogram_quantile(0.95,
rate(s5s8_inbound_handling_duration_bucket[5m])
)

# 平均 PFCP 延迟
rate(sxb_inbound_handling_duration_sum[5m]) /
rate(sxb_inbound_handling_duration_count[5m])

系统指标

Erlang VM 指标:

指标名称类型描述
vm_memory_totalGauge总 VM 内存(字节)
vm_memory_processesGauge进程使用的内存
vm_memory_systemGauge系统使用的内存
vm_system_process_countGauge总 Erlang 进程
vm_system_port_countGauge总开放端口

Prometheus 配置

抓取配置

将 OmniPGW 添加到 Prometheus 的 prometheus.yml

# prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s

scrape_configs:
- job_name: 'omnipgw'
static_configs:
- targets: ['10.0.0.20:9090']
labels:
instance: 'omnipgw-01'
environment: 'production'
site: 'datacenter-1'

多个 OmniPGW 实例

scrape_configs:
- job_name: 'omnipgw'
static_configs:
- targets:
- '10.0.0.20:9090'
- '10.0.0.21:9090'
- '10.0.0.22:9090'
labels:
environment: 'production'

服务发现

Kubernetes:

scrape_configs:
- job_name: 'omnipgw'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app]
action: keep
regex: omnipgw
- source_labels: [__meta_kubernetes_pod_ip]
target_label: __address__
replacement: '${1}:9090'

验证

测试抓取:

# 检查 Prometheus 目标
curl http://prometheus:9090/api/v1/targets

# 查询一个指标
curl 'http://prometheus:9090/api/v1/query?query=teid_registry_count'

Grafana 仪表板

仪表板设置

1. 添加 Prometheus 数据源:

配置 → 数据源 → 添加数据源 → Prometheus
URL: http://prometheus:9090

2. 导入仪表板:

创建一个新仪表板或从 JSON 导入。

关键面板

面板 1:活动会话

# 查询
teid_registry_count

# 面板类型:Gauge
# 阈值:
# 绿色:< 5000
# 黄色:5000-8000
# 红色:> 8000

面板 2:会话速率

# 查询
rate(s5s8_inbound_messages_total{message_type="create_session_request"}[5m])

# 面板类型:图表
# 单位:请求/秒

面板 3:IP 池利用率

# 查询(对于 /24 子网,254 个 IP)
(address_registry_count / 254) * 100

# 面板类型:Gauge
# 单位:百分比 (0-100)
# 阈值:
# 绿色:< 70%
# 黄色:70-85%
# 红色:> 85%

面板 4:消息延迟(95th 百分位)

# 查询
histogram_quantile(0.95,
rate(s5s8_inbound_handling_duration_bucket{request_message_type="create_session_request"}[5m])
)

# ��板类型:图表
# 单位:毫秒

面板 5:错误率

# 查询
rate(s5s8_inbound_errors_total[5m])

# 面板类型:图表
# 单位:错误/秒
# 警报阈值:> 0.1

面板 6:PFCP 关联状态

# 查询
pfcp_peer_associated

# 面板类型:状态
# 映射:
# 1 = "UP" (绿色)
# 0 = "DOWN" (红色)

完整仪表板示例

{
"dashboard": {
"title": "OmniPGW - 操作仪表板",
"panels": [
{
"title": "活动会话",
"targets": [
{
"expr": "teid_registry_count",
"legendFormat": "活动会话"
}
],
"type": "graph"
},
{
"title": "会话创建速率",
"targets": [
{
"expr": "rate(s5s8_inbound_messages_total{message_type=\"create_session_request\"}[5m])",
"legendFormat": "会话/秒"
}
],
"type": "graph"
},
{
"title": "IP 池利用率",
"targets": [
{
"expr": "(address_registry_count / 254) * 100",
"legendFormat": "池使用率 %"
}
],
"type": "gauge"
},
{
"title": "消息延迟 (p95)",
"targets": [
{
"expr": "histogram_quantile(0.95, rate(s5s8_inbound_handling_duration_bucket[5m]))",
"legendFormat": "S5/S8 p95"
},
{
"expr": "histogram_quantile(0.95, rate(sxb_inbound_handling_duration_bucket[5m]))",
"legendFormat": "PFCP p95"
}
],
"type": "graph"
}
]
}
}

警报

警报规则

创建 omnipgw_alerts.yml

groups:
- name: omnipgw
interval: 30s
rules:
# 会话计数警报
- alert: OmniPGW_HighSessionCount
expr: teid_registry_count > 8000
for: 5m
labels:
severity: warning
annotations:
summary: "OmniPGW 高会话计数"
description: "{{ $value }} 活动会话(阈值:8000)"

- alert: OmniPGW_SessionCountCritical
expr: teid_registry_count > 9500
for: 2m
labels:
severity: critical
annotations:
summary: "OmniPGW 会话计数危急"
description: "{{ $value }} 活动会话接近容量"

# IP 池警报
- alert: OmniPGW_IPPoolUtilizationHigh
expr: (address_registry_count / 254) * 100 > 80
for: 10m
labels:
severity: warning
annotations:
summary: "OmniPGW IP 池利用率高"
description: "IP 池 {{ $value }}% 已利用"

- alert: OmniPGW_IPPoolExhausted
expr: address_registry_count >= 254
for: 1m
labels:
severity: critical
annotations:
summary: "OmniPGW IP 池耗尽"
description: "没有可分配的 IP"

# 错误率警报
- alert: OmniPGW_HighErrorRate
expr: rate(s5s8_inbound_errors_total[5m]) > 0.1
for: 5m
labels:
severity: warning
annotations:
summary: "OmniPGW 高错误率"
description: "{{ $value }} 错误/秒在 S5/S8 接口"

- alert: OmniPGW_GxErrorRate
expr: rate(gx_inbound_errors_total[5m]) > 0.05
for: 5m
labels:
severity: warning
annotations:
summary: "OmniPGW Gx 错误"
description: "{{ $value }} Diameter 错误/秒"

# PFCP 警报
- alert: OmniPGW_PFCPAssociationDown
expr: pfcp_peer_associated == 0
for: 1m
labels:
severity: critical
annotations:
summary: "PFCP 对等 {{ $labels.peer }} 已关闭"
description: "PFCP 关联丢失"

- alert: OmniPGW_PFCPHeartbeatFailures
expr: pfcp_consecutive_heartbeat_failures > 2
for: 30s
labels:
severity: warning
annotations:
summary: "PFCP 心跳失败"
description: "{{ $value }} 连续失败针对 {{ $labels.peer }}"

# 延迟警报
- alert: OmniPGW_HighLatency
expr: |
histogram_quantile(0.95,
rate(s5s8_inbound_handling_duration_bucket[5m])
) > 100000
for: 5m
labels:
severity: warning
annotations:
summary: "OmniPGW 高消息延迟"
description: "p95 延迟 {{ $value }}µs (> 100ms)"

# 系统警报
- alert: OmniPGW_HighMemoryUsage
expr: vm_memory_total > 2000000000
for: 10m
labels:
severity: warning
annotations:
summary: "OmniPGW 高内存使用"
description: "VM 使用 {{ $value | humanize }}B 内存"

- alert: OmniPGW_HighProcessCount
expr: vm_system_process_count > 100000
for: 10m
labels:
severity: warning
annotations:
summary: "OmniPGW 高进程计数"
description: "{{ $value }} Erlang 进程(潜在泄漏)"

AlertManager 配置

# alertmanager.yml
global:
resolve_timeout: 5m

route:
receiver: 'ops-team'
group_by: ['alertname', 'instance']
group_wait: 10s
group_interval: 10s
repeat_interval: 12h

routes:
- match:
severity: critical
receiver: 'pagerduty'

- match:
severity: warning
receiver: 'slack'

receivers:
- name: 'ops-team'
email_configs:
- to: 'ops@example.com'

- name: 'slack'
slack_configs:
- api_url: 'https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK'
channel: '#omnipgw-alerts'
title: 'OmniPGW 警报:{{ .GroupLabels.alertname }}'
text: '{{ range .Alerts }}{{ .Annotations.description }}{{ end }}'

- name: 'pagerduty'
pagerduty_configs:
- service_key: 'YOUR_PAGERDUTY_KEY'

性能监控

关键性能指标 (KPI)

吞吐量查询

会话设置速率:

rate(s5s8_inbound_messages_total{message_type="create_session_request"}[5m])

会话拆除速率:

rate(s5s8_inbound_messages_total{message_type="delete_session_request"}[5m])

净会话增长:

rate(s5s8_inbound_messages_total{message_type="create_session_request"}[5m]) -
rate(s5s8_inbound_messages_total{message_type="delete_session_request"}[5m])

延迟分析

消息处理延迟(百分位):

# p50 (中位数)
histogram_quantile(0.50,
rate(s5s8_inbound_handling_duration_bucket[5m])
)

# p95
histogram_quantile(0.95,
rate(s5s8_inbound_handling_duration_bucket[5m])
)

# p99
histogram_quantile(0.99,
rate(s5s8_inbound_handling_duration_bucket[5m])
)

按消息类型划分的延迟:

histogram_quantile(0.95,
rate(s5s8_inbound_handling_duration_bucket[5m])
) by (request_message_type)

容量趋势

会话增长趋势(24小时):

teid_registry_count -
teid_registry_count offset 24h

剩余容量:

# 对于最大容量 10,000 会话
10000 - teid_registry_count

到达容量耗尽的时间:

# 到达容量耗尽的天数(基于 1 小时增长率)
(10000 - teid_registry_count) /
(rate(teid_registry_count[1h]) * 86400)

故障排除指标

识别问题

问题:高会话拒绝率

查询:

rate(s5s8_inbound_errors_total[5m]) by (message_type)

行动:

  • 检查错误日志
  • 验证 PCRF 连接(Gx 错误)
  • 检查 IP 池耗尽

问题:会话设置缓慢

查询:

histogram_quantile(0.95,
rate(s5s8_inbound_handling_duration_bucket{request_message_type="create_session_request"}[5m])
)

行动:

  • 检查 Gx 延迟(PCRF 响应时间)
  • 检查 PFCP 延迟(PGW-U 响应时间)
  • 查看系统资源使用情况

问题:怀疑内存泄漏

查询:

# 总内存趋势
rate(vm_memory_total[1h])

# 进程内存趋势
rate(vm_memory_processes[1h])

# 进程计数趋势
rate(vm_system_process_count[1h])

行动:

  • 检查过期会话
  • 查看注册计数
  • 如果确认泄漏,则重启

调试查询

查找峰值会话时间:

max_over_time(teid_registry_count[24h])

比较当前与历史:

teid_registry_count /
avg_over_time(teid_registry_count[7d])

识别异常:

abs(
teid_registry_count -
avg_over_time(teid_registry_count[1h])
) > 100

最佳实践

指标收集

  1. 抓取间隔: 15-30 秒(平衡粒度与负载)
  2. 保留: 15 天以上用于历史分析
  3. 标签: 使用一致的标签(实例、环境、站点)

仪表板设计

  1. 概览仪表板 - NOC 的高层 KPI
  2. 详细仪表板 - 每个接口的深入分析
  3. 故障排除仪表板 - 错误指标和日志

警报设计

  1. 避免警报疲劳 - 仅对可操作的问题发出警报
  2. 升级 - 警告 → 危急,逐步升级严重性
  3. 上下文 - 在警报描述中包含运行手册链接

相关文档

配置与设置

接口指标

专门监控


返回操作指南


OmniPGW 监控指南 - 由 Omnitouch 网络服务提供