You need to enable JavaScript to run this app.
文档中心
托管 Prometheus

托管 Prometheus

复制全文
下载 pdf
告警规则
常见告警规则建议
复制全文
下载 pdf
常见告警规则建议
本文为您介绍常见告警及规则建议。​
常见告警​
Kubernetes 常见告警​
​
告警分类​
监控对象​
指标来源​
监控目的​
典型 PromQL​
Pod / 容器​
Pod / Container​
kube-state-metrics​
当容器在最近 5 分钟内持续处于 CrashLoopBackOff 状态时触发,用于识别反复启动失败或持续崩溃。​
​
max_over_time(kube_pod_container_status_waiting_reason{reason="CrashLoopBackOff"}[5m]) >= 1​
​
Pod / 容器​
Pod​
kube-state-metrics​
​
当 Pod 持续处于 Pending 或 Unknown 状态且不属于 Job 场景时触发,用于识别未成功就绪。​
​
sum by (namespace, pod, cluster) (​
max by (namespace, pod, job, cluster) (​
kube_pod_status_phase{phase=~"Pending|Unknown"}​
) * on (namespace, pod, cluster) group_left() topk by (namespace, pod, cluster) (​
1, max by (namespace, pod, owner_kind, cluster) (kube_pod_owner{owner_kind!="Job"})​
)​
) > 0​
​
Pod / 容器​
Container​
kube-state-metrics​
当容器长时间处于 Waiting 状态且原因非 CrashLoopBackOff 时触发,用于识别镜像拉取、创建或依赖初始化异常。​
​
kube_pod_container_status_waiting_reason{reason!="CrashLoopBackOff"} > 0​
​
Workload 发布​
Deployment​
kube-state-metrics​
当 Deployment 期望副本数大于当前可用副本数,且 10 分钟内更新副本数无变化时触发,用于识别发布卡住或副本长时间不可用。​
​
(​
kube_deployment_spec_replicas > kube_deployment_status_replicas_available​
) and (​
changes(kube_deployment_status_replicas_updated[10m]) == 0​
)​
​
Workload 发布​
Deployment​
kube-state-metrics​
当 Deployment 的 Progressing 条件为 false 时触发,用于识别滚动更新流程未正常推进。​
​
kube_deployment_status_condition{condition="Progressing", status="false"} != 0​
​
Workload 发布​
StatefulSet​
kube-state-metrics​
当 StatefulSet 新旧 Revision 不一致、更新副本未补齐,且 5 分钟内未推进时触发,用于识别有状态服务更新卡顿。​
​
(​
max by (namespace, statefulset, job, cluster) (​
kube_statefulset_status_current_revision unless kube_statefulset_status_update_revision​
) * on (namespace, statefulset, job, cluster)​
(kube_statefulset_replicas != kube_statefulset_status_replicas_updated)​
) and on (namespace, statefulset, job, cluster) (​
changes(kube_statefulset_status_replicas_updated[5m]) == 0​
)​
​
Workload 发布​
DaemonSet​
kube-state-metrics​
当 DaemonSet 的已调度、已更新、可用副本或错误调度状态异常,且 5 分钟内未推进时触发,用于识别 DaemonSet 未按预期覆盖节点。​
​
(​
(kube_daemonset_status_current_number_scheduled != kube_daemonset_status_desired_number_scheduled)​
or (kube_daemonset_status_number_misscheduled != 0)​
or (kube_daemonset_status_updated_number_scheduled != kube_daemonset_status_desired_number_scheduled)​
or (kube_daemonset_status_number_available != kube_daemonset_status_desired_number_scheduled)​
) and (​
changes(kube_daemonset_status_updated_number_scheduled[5m]) == 0​
)​
​
弹性伸缩​
HPA​
kube-state-metrics​
当 HPA 的期望副本数与当前副本数不一致,且当前副本数仍处于最小副本数与最大副本数之间并持续 15 分钟无变化时触发,用于识别扩缩容未生效。​
​
​
(kube_horizontalpodautoscaler_status_desired_replicas != kube_horizontalpodautoscaler_status_current_replicas)​
and (kube_horizontalpodautoscaler_status_current_replicas > kube_horizontalpodautoscaler_spec_min_replicas)​
and (kube_horizontalpodautoscaler_status_current_replicas < kube_horizontalpodautoscaler_spec_max_replicas)​
and changes(kube_horizontalpodautoscaler_status_current_replicas[15m]) == 0​
​
弹性伸缩​
HPA​
kube-state-metrics​
当 HPA 当前副本数等于最大副本数,且最大副本数与最小副本数配置不相等时触发,用于识别弹性策略已达到上限。​
​
​
(​
kube_horizontalpodautoscaler_status_current_replicas == kube_horizontalpodautoscaler_spec_max_replicas​
) and on (namespace, horizontalpodautoscaler, cluster) (​
kube_horizontalpodautoscaler_spec_max_replicas != kube_horizontalpodautoscaler_spec_min_replicas​
)​
​
调度 / 可维护性​
PDB​
kube-state-metrics​
当 PDB 期望健康副本数大于当前健康副本数时触发,用于识别可安全驱逐的冗余不足。​
​
(​
kube_poddisruptionbudget_status_desired_healthy - kube_poddisruptionbudget_status_current_healthy​
) > 0​
​
节点资源​
Node​
node-exporter​
当节点非 idle 和非 iowait 的 CPU 使用率平均值超过 90% 时触发,用于识别节点 CPU 持续高负载。​
​
sum without(mode) (avg without (cpu) (rate(node_cpu_seconds_total{mode!~"idle|iowait"}[2m]))) * 100 > 90​
​
节点资源​
Node​
node-exporter​
当节点内存使用率超过 90% 时触发,用于识别节点可用内存即将耗尽。​
​
​
100 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100) > 90​
​
节点资源​
Node Filesystem​
node-exporter​
当文件系统剩余可用空间使用率低于 15%,且按最近 6 小时趋势预测 24 小时内将耗尽,同时文件系统非只读时触发,用于提前预警磁盘空间不足。​
​
(​
node_filesystem_avail_bytes{mountpoint!=""} / node_filesystem_size_bytes{mountpoint!=""} * 100 < 15​
and​
predict_linear(node_filesystem_avail_bytes{mountpoint!=""}[6h], 24*60*60) < 0​
and​
node_filesystem_readonly{mountpoint!=""} == 0​
)​
​
节点资源​
Node Filesystem​
node-exporter​
当文件系统剩余可用空间使用率低于 5%,且文件系统非只读时触发,用于识别磁盘空间已接近耗尽。​
​
(​
node_filesystem_avail_bytes{mountpoint!=""} / node_filesystem_size_bytes{mountpoint!=""} * 100 < 5​
and​
node_filesystem_readonly{mountpoint!=""} == 0​
)​
​
节点资源​
Node Filesystem​
node-exporter​
当文件系统 inode 剩余比例低于 40%,且按最近 6 小时趋势预测 24 小时内将耗尽,同时文件系统非只读时触发,用于提前预警 inode 不足。​
​
(​
node_filesystem_files_free{mountpoint!=""} / node_filesystem_files{mountpoint!=""} * 100 < 40​
and​
predict_linear(node_filesystem_files_free{mountpoint!=""}[6h], 24*60*60) < 0​
and​
node_filesystem_readonly{mountpoint!=""} == 0​
)​
​
节点资源​
Node Disk​
node-exporter​
当块设备加权 I/O 时间速率持续超过阈值时触发,用于识别磁盘 I/O 队列拥堵或存储层饱和。​
​
rate(node_disk_io_time_weighted_seconds_total[5m]) > 10​
​
节点网络​
Node Network​
node-exporter​
当网络接收错误包占接收总包的比例超过 1% 时触发,用于识别节点网络接收链路异常。​
​
rate(node_network_receive_errs_total[2m]) / rate(node_network_receive_packets_total[2m]) > 0.01​
​
节点网络​
Node Network​
node-exporter​
当网络发送错误包占发送总包的比例超过 1% 时触发,用于识别节点网络发送链路异常。​
​
rate(node_network_transmit_errs_total[2m]) / rate(node_network_transmit_packets_total[2m]) > 0.01​
​
控制面​
Kubernetes Components​
kube-apiserver / kubernetes_build_info​
当同一集群内统计出的 Kubernetes 组件主次版本数量大于 1 时触发,用于识别控制面组件版本不一致。​
​
count by (cluster) (​
count by (git_version, cluster) (​
label_replace(kubernetes_build_info{job!~"kube-dns|coredns"},"git_version","$1","git_version","(v[0-9]*.[0-9]*).*")​
)​
) > 1​
​
控制面​
API Server Client​
kube-apiserver / rest_client_requests_total​
当客户端访问 API Server 的 5xx 错误请求占比超过 1% 时触发,用于识别控制面访问异常或依赖故障。​
​
(sum(rate(rest_client_requests_total{code=~"5.."}[5m])) by (cluster, instance, job, namespace)​
/​
sum(rate(rest_client_requests_total[5m])) by (cluster, instance, job, namespace)) > 0.01​
​
​
etcd 常见告警​
​
方向​
常见告警​
指标来源​
说明​
典型 PromQL​
可用性​
EtcdNoLeader​
etcd 原生指标​
用于识别 etcd 当前是否失去 Leader,属于最基础的控制面可用性信号。​
​
etcd_server_has_leader == 0​
​
性能​
EtcdHighFsyncDurations​
etcd 原生指标​
用于识别 WAL fsync 延迟升高,通常反映磁盘写入抖动或存储性能下降。​
​
histogram_quantile(0.99, sum(rate(etcd_disk_wal_fsync_duration_seconds_bucket[5m])) by (le)) > 0.5​
​
容量​
EtcdBackendQuotaLowSpace​
etcd 原生指标​
用于识别 backend 空间逼近配额上限,避免影响控制面稳定性。​
​
(etcd_mvcc_db_total_size_in_bytes / etcd_server_quota_backend_bytes) > 0.95​
​
写入异常​
EtcdProposalFailures / EtcdProposalsPendingHigh​
etcd 原生指标​
用于识别 proposal 失败或 pending 积压,辅助发现写入异常、共识处理变慢或内部阻塞。​
​
rate(etcd_server_proposals_failed_total[5m]) > 0 or etcd_server_proposals_pending > 0​
​
​
规则建议​
​
建议项​
推荐实践​
告警分级​
建议按 P0 / P1 / P2 分层配置告警,便于区分趋势性问题与紧急故障。​
条件持续时间​
建议为大部分告警规则设 for 条件持续时间,以降低瞬时抖动造成的误报。​
命名空间过滤​
建议排除测试环境、临时任务与短生命周期对象,以减少噪声。​
标签规范​
建议统一补充 cluster、namespace、pod 等标签,以提升路由与故障排查效率。​
指标可用性确认​
建议在配置告警规则前,先在 VMP Explore 页面确认对应指标是否已存在。若未查询到,再从采集源侧评估并补充采集,避免编写无法落地的告警规则。​
​
​
最近更新时间:2026.09.04 14:32:34
这个页面对您有帮助吗?
有用
有用
无用
无用