K8s集群CoreDNS监控告警最佳实践

本文分享自华为云社区《K8s集群CoreDNS监控告警最佳实践》,作者:可以交个朋友。

一 背景

coreDNS作为K8s集群中的关键组成部分。主要负责k8s集群中的服务发现,域名解析等功能。如果在使用过程中出现域名解析失败,域名解析超时等情况,需要引起注意。

二 方案简介

可以通过CCE集群插件kube-prometheus-stack进行coreDNS服务的指标监控,并提供开箱即用的仪表盘视图。时刻观察coreDNS的各项运行指标是否处于健康状态。

【加一下怎么到这个图的,选监控-仪表盘】

CCE普罗监控数据统一吐到华为云AOM2.0服务,可以在AOM2.0服务中根据展示各种普罗指标数据,并根据业务实际诉求,实现基于指标的的告警通知。
【CCE普罗对接哪个AOM实例】
【加一个AOM2.0图,可以看到AOM实例指标数据】

三 coreDNS关键指标

确保Prometheus已经成功抓取coreDNS相关指标

  • coreDNS请求速率: sum(rate(coredns_dns_requests_total{}[5m])) by (proto,instance)

  • coreDNS请求速率(记录类型分组): sum(rate(coredns_dns_requests_total{}[5m])) by (type,instance)

  • coreDNS请求速率(DO标志位): sum(rate(coredns_dns_do_requests_total{}[5m])) by (instance)

  • coreDNS UDP请求数据包大小:

    P99: histogram_quantile(0.99,sum(rate(coredns_dns_request_size_bytes_bucket{proto="udp"}[5m])) by(le,proto,instance))

    P90:
    histogram_quantile(0.90,sum(rate(coredns_dns_request_size_bytes_bucket{proto="udp"}[5m])) by(le,proto,instance))

    P50:
    histogram_quantile(0.50,sum(rate(coredns_dns_request_size_bytes_bucket{proto="udp"}[5m])) by(le,proto,instance))

  • coreDNS TCP请求数据包大小:

    P99: histogram_quantile(0.99,sum(rate(coredns_dns_request_size_bytes_bucket{proto="tcp"}[5m])) by(le,proto,instance))

    P90:
    histogram_quantile(0.90,sum(rate(coredns_dns_request_size_bytes_bucket{proto="tcp"}[5m])) by(le,proto,instance))

    P50:
    histogram_quantile(0.50,sum(rate(coredns_dns_request_size_bytes_bucket{proto="tcp"}[5m])) by(le,proto,instance))

  • coreDNS响应速率(根据响应状态码分组): sum(rate(coredns_dns_responses_total{}[5m])) by(rcode,instance)

  • coreDNS响应时延:

    P99: histogram_quantile(0.99,sum(rate(coredns_dns_request_duration_seconds_bucket{}[5m])) by(le,job,instance))

    P90:
    histogram_quantile(0.90,sum(rate(coredns_dns_request_duration_seconds_bucket{}[5m])) by(le,job,instance))

    P50:
    histogram_quantile(0.50,sum(rate(coredns_dns_request_duration_seconds_bucket{}[5m])) by(le,job,instance))

  • coreDNS UDP响应数据包大小:

    P99: histogram_quantile(0.99,sum(rate(coredns_dns_response_size_bytes_bucket{proto="udp"}[5m])) by(le,proto,instance))

    P90:
    histogram_quantile(0.90,sum(rate(coredns_dns_response_size_bytes_bucket{proto="udp"}[5m])) by(le,proto,instance))

    P50:
    histogram_quantile(0.50,sum(rate(coredns_dns_response_size_bytes_bucket{proto="udp"}[5m])) by(le,proto,instance))

  • coreDNS TCP响应数据包大小

    P99: histogram_quantile(0.99,sum(rate(coredns_dns_response_size_bytes_bucket{proto="tcp"}[5m])) by(le,proto,instance))

    P90:
    histogram_quantile(0.90,sum(rate(coredns_dns_response_size_bytes_bucket{proto="tcp"}[5m])) by(le,proto,instance))

    P50:
    histogram_quantile(0.50,sum(rate(coredns_dns_response_size_bytes_bucket{proto="tcp"}[5m])) by(le,proto,instance))

  • coreDNS缓存的DNS记录数: sum (coredns_cache_entries{}) by(type,instance)

  • coreDNS缓存命中率:
    sum (rate(coredns_cache_hits_total{}[5m])) by (type,instance)

  • coreDNS缓存丢失率:
    sum (rate(coredns_cache_misses_total{}[5m])) by (type,instance)

其中主要关注:p99coreDNS响应时延、coreDNS请求速率、coreDNS缓存命中率指标,其中p99coreDNS响应时延基于域名解析超时时间一般为2s,可以初步设置高级阈值为1s,后续再根据实际监控数据根据指标进一步设置一个更加精细阈值。

四: 如何根据coreDNS指标进行告警

前往AOM告警管理tab页

【怎么导入这个图】

配置告警规则

选择指标告警规则,配置方式可使用PromQL语句

配置告警通知规则

触发指标告警规则,邮箱收到告警

点击关注,第一时间了解华为云新鲜技术~

相关推荐
腾飞开源5 小时前
01_K8s干货笔记之认识K8s
运维·笔记·云原生·容器·kubernetes·k8s·容器化部署
小匠石钧知3 天前
02_在多个RockyLinux10虚拟机上安装k8s集群
云原生·容器·kubernetes·k8s
ShirleyWang0129 天前
让headlamp控制台能访问
linux·服务器·python·k8s·k3s
spider_xcxc9 天前
K8s 部署学习笔记
docker·容器·kubernetes·云计算·k8s
ShirleyWang0129 天前
Day02 K3s NGF(Nginx Gateway Fabric)单 Worker 环境网关更新与故障处置 SOP
linux·服务器·python·k8s·k3s
ShirleyWang0129 天前
DAY01 K3s 私有化部署排障复盘与 SOP
linux·服务器·k8s·k3s·企业部署
XUHUOJUN13 天前
AKS 不是安装在 Windows Server 上,而是运行在 Windows Server 之上的 Azure 平台能力
windows·架构·k8s·azure local·azure stack
Geek-Chow13 天前
Connecting kubectl to a Private EKS Cluster Over an Internal Domain
kubernetes·k8s·aws
spider_xcxc15 天前
Docker Compose 容器通信详解:同一个 Compose 文件才能互通吗?
docker·容器·k8s·容器化·容器网络
欢醉20 天前
k8s调用服务异常cannot allocate memory
kubernetes·k8s