乌市泽哥 发表于 2024-4-16 01:29:29

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

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

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

可以通过CCE集群插件kube-prometheus-stack进行coreDNS服务的指标监控,并提供开箱即用的仪表盘视图。时刻观察coreDNS的各项运行指标是否处于健康状态。
【加一下怎么到这个图的,选监控-仪表盘】
https://bbs-img.huaweicloud.com/blogs/img/20240123/1706012520904669107.png
CCE普罗监控数据统一吐到华为云AOM2.0服务,可以在AOM2.0服务中根据展示各种普罗指标数据,并根据业务实际诉求,实现基于指标的的告警通知。
【CCE普罗对接哪个AOM实例】
【加一个AOM2.0图,可以看到AOM实例指标数据】三 coreDNS关键指标

确保Prometheus已经成功抓取coreDNS相关指标
https://bbs-img.huaweicloud.com/blogs/img/20240123/1706012758544806345.png

[*]coreDNS请求速率: sum(rate(coredns_dns_requests_total{})) by (proto,instance)
[*]coreDNS请求速率(记录类型分组): sum(rate(coredns_dns_requests_total{})) by (type,instance)
[*]coreDNS请求速率(DO标志位): sum(rate(coredns_dns_do_requests_total{})) by (instance)
[*]coreDNS UDP请求数据包大小:
P99: histogram_quantile(0.99,sum(rate(coredns_dns_request_size_bytes_bucket{proto="udp"})) by(le,proto,instance))
P90:
histogram_quantile(0.90,sum(rate(coredns_dns_request_size_bytes_bucket{proto="udp"})) by(le,proto,instance))
P50:
histogram_quantile(0.50,sum(rate(coredns_dns_request_size_bytes_bucket{proto="udp"})) by(le,proto,instance))
[*]coreDNS TCP请求数据包大小:
P99: histogram_quantile(0.99,sum(rate(coredns_dns_request_size_bytes_bucket{proto="tcp"})) by(le,proto,instance))
P90:
histogram_quantile(0.90,sum(rate(coredns_dns_request_size_bytes_bucket{proto="tcp"})) by(le,proto,instance))
P50:
histogram_quantile(0.50,sum(rate(coredns_dns_request_size_bytes_bucket{proto="tcp"})) by(le,proto,instance))
[*]coreDNS响应速率(根据响应状态码分组): sum(rate(coredns_dns_responses_total{})) by(rcode,instance)
[*]coreDNS响应时延:
P99: histogram_quantile(0.99,sum(rate(coredns_dns_request_duration_seconds_bucket{})) by(le,job,instance))
P90:
histogram_quantile(0.90,sum(rate(coredns_dns_request_duration_seconds_bucket{})) by(le,job,instance))
P50:
histogram_quantile(0.50,sum(rate(coredns_dns_request_duration_seconds_bucket{})) by(le,job,instance))
[*]coreDNS UDP响应数据包大小:
P99: histogram_quantile(0.99,sum(rate(coredns_dns_response_size_bytes_bucket{proto="udp"})) by(le,proto,instance))
P90:
histogram_quantile(0.90,sum(rate(coredns_dns_response_size_bytes_bucket{proto="udp"})) by(le,proto,instance))
P50:
histogram_quantile(0.50,sum(rate(coredns_dns_response_size_bytes_bucket{proto="udp"})) by(le,proto,instance))
[*]coreDNS TCP响应数据包大小
P99: histogram_quantile(0.99,sum(rate(coredns_dns_response_size_bytes_bucket{proto="tcp"})) by(le,proto,instance))
P90:
histogram_quantile(0.90,sum(rate(coredns_dns_response_size_bytes_bucket{proto="tcp"})) by(le,proto,instance))
P50:
histogram_quantile(0.50,sum(rate(coredns_dns_response_size_bytes_bucket{proto="tcp"})) by(le,proto,instance))
[*]coreDNS缓存的DNS记录数: sum (coredns_cache_entries{}) by(type,instance)
[*]coreDNS缓存命中率:
sum (rate(coredns_cache_hits_total{})) by (type,instance)
[*]coreDNS缓存丢失率:
sum (rate(coredns_cache_misses_total{})) by (type,instance)
其中主要关注:p99coreDNS响应时延、coreDNS请求速率、coreDNS缓存命中率指标,其中p99coreDNS响应时延基于域名解析超时时间一般为2s,可以初步设置高级阈值为1s,后续再根据实际监控数据根据指标进一步设置一个更加精细阈值。
四: 如何根据coreDNS指标进行告警

前往AOM告警管理tab页
【怎么导入这个图】
配置告警规则
选择指标告警规则,配置方式可使用PromQL语句
https://bbs-img.huaweicloud.com/blogs/img/20240123/1706017706053440216.png
配置告警通知规则
https://bbs-img.huaweicloud.com/blogs/img/20240123/1706017822090168057.png
触发指标告警规则,邮箱收到告警
https://bbs-img.huaweicloud.com/blogs/img/20240123/1706018649356338829.png
 
点击关注,第一时间了解华为云新鲜技术~
 

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: K8s集群CoreDNS监控告警最佳实践