You need to enable JavaScript to run this app.
导航

DNS 组件监控

最近更新时间2024.02.28 20:04:51

首次发布时间2023.11.02 12:02:42

DNS 是 Kubernetes 集群中服务发现的基础,集群 DNS 服务发现的性能和稳定性与业务质量密切相关。本文为您介绍如何配置和查看 DNS 组件的监控信息。

背景信息

在大规模场景下时,大量的 DNS 请求会对集群中的 DNS 组件造成较大的压力,导致 DNS 的时延增加,从而影响业务性能。因此,您需要使用集群的可观测能力,及时了解到集群中 DNS 组件的工作状态,并在必要时给出告警和进行处理。

容器服务支持 CoreDNS 组件和 NodeLocal DNSCache 组件。支持标准的集群 DNS 服务发现和节点 DNS 缓存代理功能。涉及的组件包括:

  • core-dns 组件:CoreDNS 组件,为集群内部提供服务发现及域名解析服务。
  • node-local-dns 组件:NodeLocal DNSCache 缓存方案组件,为节点提供 DNS 缓存代理功能,提升整个集群的 DNS 服务发现性能和稳定性。

说明

更多的组件介绍和组件安装方式,请参见 组件管理

前提条件

操作步骤

  1. 登录 容器服务控制台
  2. 在左侧导航栏中选择 集群
  3. 在集群列表页面,单击目标集群。
  4. 在集群管理页面的左侧导航栏中,选择 监控中心 > 监控看板
  5. 在配置页面右上角,单击 指标采集配置
  6. 选择 数据面组件 页签,在组件列表 是否采集 列,单击开关,开启 core-dns 和 node-local-dns 组件的采集规则。
    alt
  7. (可选)单击组件列表 操作 栏中的 编辑指标,支持选择或丢弃组件的具体指标,并配置面向该组件的采集间隔。
    • 在 采集间隔 下拉菜单中,选择该组件指标的采集间隔。不同组件支持的采集间隔不同。
    • 在指标列表中,勾选指标,则采集该指标。取消勾选,则丢弃该指标。单击 指标类型 表头,允许基于指标类型对指标项进行筛选。
      alt

      说明

      • 减小指标采集间隔,会增加单位时间内上报的指标数量,可以提升监控精度。但会增加托管 Prometheus 标准版工作区的费用。增加指标采集间隔,会减少单位时间内上报的指标数量,可以减少托管 Prometheus 标准版工作区的费用,但会降低监控精度。请根据实际需要配置。
      • 云产品的指标类型分为 基础指标 和 其他指标,不同类型指标的计费方式不同,详情请参见 托管 Prometheus 计费方式

查看大盘

core-dns 监控

您可以查看所有或指定 core-dns 实例的监控信息,包括:DNS 请求、DNS 错误率、DNS 转发、DNS 缓存命中率等。支持设置查询的时间段,并指定刷新方式(手动刷新、自动刷新)。

  1. 登录 容器服务控制台
  2. 在左侧导航栏中选择 集群
  3. 在集群列表页面,单击目标集群。
  4. 在集群管理页面的左侧导航栏中,选择 监控中心 > 监控看板
  5. 在左侧看板列表中选择 网络服务监控 > core-dns 监控,即可查看监控大盘。
    alt

node-local-dns 监控

您可以查看所有或指定 node-local-dns 实例的监控信息,包括:DNS 请求、DNS 错误率、DNS 转发、DNS 缓存命中率等。支持设置查询的时间段,并指定刷新方式(手动刷新、自动刷新)。

  1. 登录 容器服务控制台
  2. 在左侧导航栏中选择 集群
  3. 在集群列表页面,单击目标集群。
  4. 在集群管理页面的左侧导航栏中,选择 监控中心 > 监控看板
  5. 在左侧看板列表中选择 网络服务监控 > node-local-dns 监控,即可查看监控大盘。
    alt

指标清单

DNS 组件监控大盘的指标清单如下表所示。

大盘分类大盘名称PromQL 语句
core-dns 监控DNS 请求sum(increase(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range])) or vector(0)
DNS 错误率100*sum(increase(coredns_dns_responses_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns",rcode=~"SERVFAIL|REFUSED"}[$__range]))/sum(increase(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range])) or vector(0)
DNS 转发sum(increase(coredns_forward_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range])) or vector(0)
DNS 缓存命中率100*sum(increase(coredns_cache_hits_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range]))/sum(increase(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range])) or vector(0)
DNS 请求(按协议)sum(rate(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m])) by (proto)
DNS 请求(按类型)sum(rate(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m])) by (type)
DNS 转发sum(rate(coredns_forward_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m])) or vector(0)
DNS 错误率100*sum(rate(coredns_dns_responses_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns",rcode=~"SERVFAIL|REFUSED"}[5m]))/sum(rate(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m])) or vector(0)
缓存命中/未命中sum(rate(coredns_cache_hits_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m]))
sum(rate(coredns_cache_misses_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m]))
请求响应延时(P90)1000*histogram_quantile(0.9, sum(rate(coredns_dns_request_duration_seconds_bucket{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m]))by (le))
转发请求响应延时(P90)1000*histogram_quantile(0.9, sum(rate(coredns_forward_request_duration_seconds_bucket{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m]))by (le))
node-local-dns 监控DNS 请求sum(increase(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range])) or vector(0)
DNS 错误率100*sum(increase(coredns_dns_responses_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns",rcode=~"SERVFAIL|REFUSED"}[$__range]))/sum(increase(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range])) or vector(0)
DNS 转发sum(increase(coredns_forward_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range])) or vector(0)
DNS 缓存命中率100*sum(increase(coredns_cache_hits_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range]))/sum(increase(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[$__range])) or vector(0)
DNS 请求(按协议)sum(rate(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m])) by (proto)
DNS 请求(按类型)sum(rate(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m])) by (type)
DNS 转发sum(rate(coredns_forward_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m])) or vector(0)
DNS 错误率100*sum(rate(coredns_dns_responses_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns",rcode=~"SERVFAIL|REFUSED"}[5m]))/sum(rate(coredns_dns_requests_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m])) or vector(0)
缓存命中/未命中sum(rate(coredns_cache_hits_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m]))
sum(rate(coredns_cache_misses_total{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m]))
请求响应延时(P90)1000*histogram_quantile(0.9, sum(rate(coredns_dns_request_duration_seconds_bucket{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m]))by (le))
转发请求响应延时(P90)1000*histogram_quantile(0.9, sum(rate(coredns_forward_request_duration_seconds_bucket{cluster=~"$ClusterId",pod=~"$Pod",job="core-dns"}[5m]))by (le))

说明

如果您需要在托管 Prometheus 中的 Explore 功能或告警中心使用上述 PromQL 语句查看具体的指标或配置告警,请修改或删除语句中关于集群、节点、容器组的变量。例如:将 cluster=~"$Cluster"参数中的$Cluster变量修改为具体的集群 ID ,或直接删除该参数。

查看指标

您可以使用托管 Prometheus 的 Explore 功能来快速查询和展示指标数据。详情请参见 指标查询

配置告警

您可以在托管 Prometheus 的告警中心配置集群相关告警。详情请参见 创建告警规则