首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
30 篇文章
1
Prometheus配置企业微信告警
2
云原生监控配置自建alertmanager实现告警
3
K8S 中的 CPUThrottlingHigh 到底是个什么鬼?
4
Kubernetes集群安装kube-prometheus后无法执行kubectl top node
5
Prometheus Operator 使用 AlertmanagerConfig 进行报警配置
6
在 Grafana 中可视化 Alertmanager 报警
7
Prometheus Operator 常用指标
8
使用 Thanos 实现 Prometheus 的高可用
9
Kubenretes上运行Prometheus联邦集群
10
prometheus2.0 联邦的配置
11
Prometheus监控学习笔记之prometheus的远端存储
12
别再乱用 Prometheus 联邦了,分享一个 Prometheus 高可用新方案
13
使用prometheus监控多k8s集群
14
Kubernetes K8S之kube-prometheus概述与部署 Prometheus的关键特性架构图基本原理服务过程kube-prometheus下载与配置修
15
Prometheus BlackBox简单监控
16
如何使用Prometheus配置自定义告警规则
17
使用prometheus operator监控envoy
18
使用 Prometheus-Operator 监控 Calico
19
TKE 1.20.6搭建Kube-Prometheus(prometheus-oprator)
20
云原生监控通过blackbox_exporter监控网站
21
一文带你了解 Prometheus
22
使用 Thanos 和 Prometheus 打造一个高可用的 Kubernetes 监控系统
23
prometheus监控springboot应用
24
搭建prometheus+grafana监控SpringBoot应用入门
25
用prometheus监控java应用
26
Prometheus Operator 监控 Traefik V2.4
27
Prometheus指标优化
28
使用 Prometheus Operator 监控 Kubernetes
29
装X神器,让你的grafana看板变得炫酷起来
30
​prometheus中使用python手写webhook完成告警

Prometheus Operator 监控 Traefik V2.4

背景:

traefik搭建方式如下:

https://www.yuque.com/duiniwukenaihe/ehb02i/odflm7

Prometheus-oprator搭建方式如下:

https://www.yuque.com/duiniwukenaihe/ehb02i/tm6vl7

Prometheus的文档写了grafana添加了traefik的监控模板。但是现在仔细一看。traefik的监控图是空的,Prometheus的 target也没有对应traefik的监控。

现在配置下添加traefik服务发现以及验证一下grafana的图表。

1. Prometheus Operator 监控 Traefik V2.4

1.1. Traefik 配置文件设置 Prometheus

参照https://www.yuque.com/duiniwukenaihe/ehb02i/odflm7。配置中默认开启了默认的Prometheus监控。

image.png

https://doc.traefik.io/traefik/observability/metrics/prometheus/可参照traefik官方文档。

1.2、Traefik Service 设置标签

1.2.1 查看traefik service

代码语言:txt
复制
$  kubectl get svc -n kube-system
NAME                          TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                        AGE
cilium-agent                  ClusterIP   None             <none>        9095/TCP                       15d
etcd-k8s                      ClusterIP   None             <none>        2379/TCP                       8d
hubble-metrics                ClusterIP   None             <none>        9091/TCP                       15d
hubble-relay                  ClusterIP   172.254.38.50    <none>        80/TCP                         15d
hubble-ui                     ClusterIP   172.254.11.239   <none>        80/TCP                         15d
kube-controller-manager       ClusterIP   None             <none>        10257/TCP                      8d
kube-controller-manager-svc   ClusterIP   None             <none>        10252/TCP                      6d
kube-dns                      ClusterIP   172.254.0.10     <none>        53/UDP,53/TCP,9153/TCP         15d
kube-scheduler                ClusterIP   None             <none>        10259/TCP                      8d
kube-scheduler-svc            ClusterIP   None             <none>        10251/TCP                      6d
kubelet                       ClusterIP   None             <none>        10250/TCP,10255/TCP,4194/TCP   8d
traefik                       ClusterIP   172.254.12.88    <none>        80/TCP,443/TCP,8080/TCP        11d

1.2.2、编辑该 Service 设置 Label

代码语言:txt
复制
 kubectl edit service traefik -n kube-system

设置 Label “app: traefik”

image.png

参照的是traefik-deploy.yaml 中的app:traefik这个标签用了,当然了也可以自己定义下用下别的......

image.png

1.3、Prometheus Operator 配置监控规则

traefik-service-monitoring.yaml

代码语言:txt
复制
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name:  traefik
  namespace: monitoring
  labels:
     app: traefik
spec:
  jobLabel: traefik-metrics
  selector:
    matchLabels:
      app: traefik
  namespaceSelector:
    matchNames:
    - kube-system
  endpoints:
  - port: admin
    path: /metrics

创建该Service Monitor

代码语言:txt
复制
$ kubectl apply -f traefik-monitor.yaml

1.4、查看 Prometheus target规则是否生效

image.png

1.5 查看grafana中的traefik仪表盘是否有数据生成图表

image.png

嗯 这也算是添加target的一个例子。下次写下配置下自动发现规则?

下一篇
举报
领券