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语句

配置告警通知规则

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

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

相关推荐
Garfield20051 天前
Kubeflow 运行容器时 ENTRYPOINT 被覆盖导致环境变量未生效问题分析与解决
k8s·dockerfile·kubeflow·entrypoint
南方以南_4 天前
CKA07--Argo CD
运维·kubernetes·k8s
Matana1114 天前
CentOS7 + VMware 搭建 K3s 集群遇到的网络问题全记录与解决方案
k8s
nvd116 天前
GKE 部署 - 从`kubectl` 到 Helm Chart 的演进
k8s
虚伪的空想家7 天前
记录次etcd故障,fatal error: bus error
服务器·数据库·k8s·etcd
岚天start8 天前
KubeSphere在线安装单节点K8S集群
docker·容器·kubernetes·k8s·kubesphere·kubekey
小坏讲微服务10 天前
五分钟使用 Docker-compose搭建 Redis 8.0 中间件
运维·redis·docker·中间件·容器·kubernetes·k8s
退役小学生呀14 天前
二十二、DevOps:基于Tekton的云原生平台落地(三)
linux·云原生·容器·kubernetes·k8s·devops·tekton
cc202292814 天前
ingress概念和实际运用
容器·kubernetes·k8s
The god of big data15 天前
Metrics Server 完整配置安装手册
云原生·云计算·k8s