Prometheus Operator 通过additional 添加target

前言

Proms Operator 添加自定义监控可以通过如下两种方式实现,本文是 additional 方式。

  • additional 方式
  • serviceMonitor方式

官网

安装参考这个专栏里以前的博文。

##
https://github.com/prometheus-operator/kube-prometheus#quickstart

按照官网的部署,这个方式部署起来的prometheus还有很多的缺陷,不能直接用于生产环境使用,具体问题点如下:

  • 数据没有持久化存储(grafana、prometheus)
  • svc都是用的clusterIP 不方便运维管理
  • 默认的告警方式不方便
  • 加监控target也不方便

官网

##
https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/additional-scrape-config.md

 vim prometheus-prometheus.yaml 

末尾添加:

  additionalScrapeConfigs:
    name: additional-scrape-configs
    key: prometheus-additional.yaml

vim prometheus-additional.yaml

- job_name: "base-linux"
  static_configs:
  - targets: ["192.168.0.36:9090","192.168.0.11:9090"]

- job_name: "kafka-explorer"
  static_configs:
  - targets: ["192.168.0.11:9000"]

添加secret

kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml --dry-run=client -oyaml > additional-scrape-configs.yaml

Next, apply the generated kubernetes manifest

##
kubectl apply -f additional-scrape-configs.yaml -n monitoring

查看

如何删除 target ?

kubectl delete secret additional-configs -n monitoring

kubectl delete secret additional-scrape-configs -n monitoring

如何更新target?

## 重新生成
kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml --dry-run=client -oyaml > additional-scrape-configs.yaml


## 应用
kubectl apply -f additional-scrape-configs.yaml -n monitoring

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

叱咤少帅(少帅)

如果文章对你有帮助就打赏下吧!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值