kube-promethesu调整coredns监控

2024-06-06 09:36

本文主要是介绍kube-promethesu调整coredns监控,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

K8s集群版本是二进制部署的1.20.4,kube-prometheus对应选择的版本是kube-prometheus-0.8.0

Coredns是在安装集群的时候部署的,采用的也是该版本的官方文档,kube-prometheus中也有coredns的监控配置信息,但是在prometheus的监控页面并没有发现coredns的servicemonitor.。所以我们需要一步步的去排查该问题。

先看下coredns的servicemonitor 

vim kubernetes-serviceMonitorCoreDNS.yaml

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:labels:app.kubernetes.io/name: corednsname: corednsnamespace: monitoring
spec:endpoints:- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/tokeninterval: 15sport: metricsjobLabel: app.kubernetes.io/namenamespaceSelector:matchNames:- kube-systemselector:matchLabels:app.kubernetes.io/name: kube-dns

再来看下coredns的service配置

---
apiVersion: v1
kind: Service
metadata:name: kube-dnsnamespace: kube-systemannotations:prometheus.io/port: "9153"prometheus.io/scrape: "true"labels:k8s-app: kube-dnskubernetes.io/cluster-service: "true"addonmanager.kubernetes.io/mode: Reconcilekubernetes.io/name: "CoreDNS"
spec:selector:k8s-app: kube-dnsclusterIP: 10.0.0.2ports:- name: dnsport: 53protocol: UDP- name: dns-tcpport: 53protocol: TCP- name: metricsport: 9153protocol: TCP

从上面两段可以看到,servicemonitor去匹配的service是

labels:

app.kubernetes.io/name: coredns

而我们创建的coredns的service的labels

labels:

    k8s-app: kube-dns

    kubernetes.io/cluster-service: "true"

    addonmanager.kubernetes.io/mode: Reconcile

    kubernetes.io/name: "CoreDNS"

两边没有对应上,所以该servicemonitor无法匹配到对应的service,所以监控不到我们的coredns.

因coredns对服务的影响比较大,我们选择去修改servicemonitor

修改labels后重新apply

Kubectl apply -f kubernetes-serviceMonitorCoreDNS.yaml

coredns就加载出来了

配置coredns的监控信息

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:labels:app.kubernetes.io/name: kube-prometheusapp.kubernetes.io/part-of: kube-prometheusprometheus: k8srole: alert-rulesname: kubernetes-monitoring-coredns-rulesnamespace: monitoringspec:groups:- name: corednsrules:- alert: CoreDNSDownannotations:message: CoreDNS has disappeared from Prometheus target discovery.runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednsdownexpr: |absent(up{job="kube-dns"} == 1)for: 15mlabels:severity: critical- alert: CoreDNS的dns请求持续时间延迟高annotations:message: CoreDNS has 99th percentile latency of {{ $value }} seconds for server{{ $labels.server }} zone {{ $labels.zone }} .runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednslatencyhighexpr: |histogram_quantile(0.99, sum(rate(coredns_dns_request_duration_seconds_bucket{job="kube-dns"}[5m])) by(server, zone, le)) > 4for: 10mlabels:severity: critical- alert: CoreDNS响应错误高annotations:message: CoreDNS is returning SERVFAIL for {{ $value | humanizePercentage }} of   requests.runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednserorshighexpr: |sum(rate(coredns_dns_responses_total{job="kube-dns",rcode="SERVFAIL"}[5m]))/sum(rate(coredns_dns_responses_total{job="kube-dns"}[5m])) > 0.03for: 10mlabels:severity: critical- alert: CoreDNS响应错误高annotations:message: CoreDNS is returning SERVFAIL for {{ $value | humanizePercentage }} of   requests.runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednserorshighexpr: |sum(rate(coredns_dns_responses_total{job="kube-dns",rcode="SERVFAIL"}[5m]))/sum(rate(coredns_dns_responses_total{job="kube-dns"}[5m])) > 0.01for: 10mlabels:severity: warning- alert: CoreDNS转发请求持续时间延迟高annotations:message: CoreDNS has 99th percentile latency of {{ $value }} seconds forwarding requests to {{ $labels.to }}.runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednsforwardlatencyhighexpr: |histogram_quantile(0.99, sum(rate(coredns_forward_request_duration_seconds_bucket{job="kube-dns"}[5m])) by(to, le)) > 4for: 10mlabels:severity: critical- alert: CoreDNSForwardErrorsHighannotations:message: CoreDNS is returning SERVFAIL for {{ $value | humanizePercentage }} of forward requests to {{ $labels.to }}.runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednsforwarderrorshighexpr: |sum(rate(coredns_forward_responses_total{job="kube-dns",rcode="SERVFAIL"}[5m]))/sum(rate(coredns_forward_responses_total{job="kube-dns"}[5m])) > 0.03for: 10mlabels:severity: critical- alert: CoreDNSForwardErrorsHighannotations:message: CoreDNS is returning SERVFAIL for {{ $value | humanizePercentage }} of forward requests to {{ $labels.to }}.runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednsforwarderrorshighexpr: |sum(rate(coredns_forward_responses_total{job="kube-dns",rcode="SERVFAIL"}[5m]))/sum(rate(coredns_forward_responses_total{job="kube-dns"}[5m])) > 0.01for: 10mlabels:severity: warning- alert: CoreDNSForwardHealthcheckFailureCountannotations:message: CoreDNS health checks have failed to upstream server {{ $labels.to }}.runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednsforwardhealthcheckfailurecountexpr: |sum(rate(coredns_forward_healthcheck_failures_total{job="kube-dns"}[5m])) by (to) > 0for: 10mlabels:severity: warning- alert: CoreDNSForwardHealthcheckBrokenCountannotations:message: CoreDNS health checks have failed for all upstream servers.runbook_url: https://github.com/povilasv/coredns-mixin/tree/master/runbook.md#alert-name-corednsforwardhealthcheckbrokencountexpr: |sum(rate(coredns_forward_healthcheck_broken_total{job="kube-dns"}[5m])) > 0for: 10mlabels:severity: warning- alert: CorednsPanicCountexpr: increase(coredns_panics_total[1m]) > 0for: 0mlabels:severity: criticalannotations:summary: CoreDNS Panic Count (instance {{ $labels.instance }})description: "Number of CoreDNS panics encountered\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"

这篇关于kube-promethesu调整coredns监控的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1035732

相关文章

JVisualVM之Java性能监控与调优利器详解

《JVisualVM之Java性能监控与调优利器详解》本文将详细介绍JVisualVM的使用方法,并结合实际案例展示如何利用它进行性能调优,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全... 目录1. JVisualVM简介2. JVisualVM的安装与启动2.1 启动JVisualVM2

使用Python实现实时金价监控并自动提醒功能

《使用Python实现实时金价监控并自动提醒功能》在日常投资中,很多朋友喜欢在一些平台买点黄金,低买高卖赚点小差价,但黄金价格实时波动频繁,总是盯着手机太累了,于是我用Python写了一个实时金价监控... 目录工具能干啥?手把手教你用1、先装好这些"食材"2、代码实现讲解1. 用户输入参数2. 设置无头浏

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

AJAX请求上传下载进度监控实现方式

《AJAX请求上传下载进度监控实现方式》在日常Web开发中,AJAX(AsynchronousJavaScriptandXML)被广泛用于异步请求数据,而无需刷新整个页面,:本文主要介绍AJAX请... 目录1. 前言2. 基于XMLHttpRequest的进度监控2.1 基础版文件上传监控2.2 增强版多

Python批量调整Word文档中的字体、段落间距及格式

《Python批量调整Word文档中的字体、段落间距及格式》这篇文章主要为大家详细介绍了如何使用Python的docx库来批量处理Word文档,包括设置首行缩进、字体、字号、行间距、段落对齐方式等,需... 目录关键代码一级标题设置  正文设置完整代码运行结果最近关于批处理格式的问题我查了很多资料,但是都没

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

通过prometheus监控Tomcat运行状态的操作流程

《通过prometheus监控Tomcat运行状态的操作流程》文章介绍了如何安装和配置Tomcat,并使用Prometheus和TomcatExporter来监控Tomcat的运行状态,文章详细讲解了... 目录Tomcat安装配置以及prometheus监控Tomcat一. 安装并配置tomcat1、安装

C#实现系统信息监控与获取功能

《C#实现系统信息监控与获取功能》在C#开发的众多应用场景中,获取系统信息以及监控用户操作有着广泛的用途,比如在系统性能优化工具中,需要实时读取CPU、GPU资源信息,本文将详细介绍如何使用C#来实现... 目录前言一、C# 监控键盘1. 原理与实现思路2. 代码实现二、读取 CPU、GPU 资源信息1.

使用zabbix进行监控网络设备流量

《使用zabbix进行监控网络设备流量》这篇文章主要为大家详细介绍了如何使用zabbix进行监控网络设备流量,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录安装zabbix配置ENSP环境配置zabbix实行监控交换机测试一台liunx服务器,这里使用的为Ubuntu22.04(

springboot健康检查监控全过程

《springboot健康检查监控全过程》文章介绍了SpringBoot如何使用Actuator和Micrometer进行健康检查和监控,通过配置和自定义健康指示器,开发者可以实时监控应用组件的状态,... 目录1. 引言重要性2. 配置Spring Boot ActuatorSpring Boot Act