侧边栏壁纸
博主头像
背锅小王子博主等级

我从事运维工作有十年之久,主要从事云原生相关的工作,对k8s、devops、servicemesh、可观察性等较为熟悉!

  • 累计撰写 59 篇文章
  • 累计创建 64 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

prometheus应用实践(六)监控外部应用

背锅小王子
2022-08-01 / 0 评论 / 0 点赞 / 230 阅读 / 235 字
温馨提示:
本文最后更新于 2022-11-14,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

1、情况说明

通过prometheus来监控部署在k8s以外的应用程序,可以通过静态配置文件的方式,创建一个secret文件,然后挂载到prometheus中即可

2、创建静态配置

创建一个静态配置文件:prometheus-additional.yaml

- job_name: 'harbor'
  static_configs:
    - targets:
      - harbor.bgxwz.com:9100

将prometheus-additional.yaml创建成一个secret文件

kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml -n monitoring

3、挂载静态secret文件

修改prometheus-prometheus.yaml文件,在spec中添加如下内容:

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

然后更新prometheus

kubectl apply -f prometheus-prometheus.yaml

4、再添加监控对象

修改prometheus-additional.yaml

- job_name: 'harbor'
  static_configs:
    - targets:
      - harbor.bgxwz.com:9100
      
- job_name: 'gitlab'
  static_configs:
    - targets:
      - gitlab.bgxwz.com:9100

然后重新创建secret文件,并部署

kubectl delete secret additional-scrape-configs -n monitoring

kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml -n monitoring
0

评论区