部署node_Prometheus监控系列之——node_exporter安装部署

上一篇介绍的Prometheus的安装,比较简单。node_exporter安装也比较简单,但是我们要考虑这个 客户端是非常多的,为例后期模板和数据查看更具体做出以下规划:

  1. 使用ansible-playbook 推送安装
  2. Prometheus使用consul做客户端发现
  3. 根据项目、环境、应用类型、部署方式作为标签推送到consul
  4. 启动方式使用supervisor管理

下面就请跟着作者一起做

ansible-playbook目录:

e62f8adf0ea011c1d12a73d29c8aeb01.png

cat defaults/main.yaml

这一部分也可以放在group_vars下面统一管理

supervisord: /etc/supervisord.dexporter: /opt/node_exporternode_service: node_exporterconsul_register: http://172.20.20.224:8500/v1/catalog/register

cat handlers/main.yaml

---- name: restart supervisord service: name=supervisord state=restarted

cat tasks/main.yaml

推送consul信息 也可使用ansible自带的consul模块,我这里使用的是文本加api的方式

---- name: create {{ node_service }} conf template: src=consul_linux_metric.json.j2 dest=/opt/linux_metric.json register: status- name: register {{ node_service }} shell: curl -X PUT -T {{ status.dest }} {{ consul_register }} && rm -f /opt/linux_metric.json when: status.changed == true- name: mkdir {{ exporter }} file: path={{ exporter }} state=directory mode=755- name: copy {{ node_service }} copy: src={{ node_service }} dest={{ exporter }}/{{ node_service }} mode=755 - name: create node_exporter supervisord config template: src=supervisor_node_exporter.conf.j2 dest={{ supervisord }}/supervisor_node_exporter.conf notify: restart supervisord when: ansible_distribution_major_version == "7"- name: create node_exporter supervisord config template: src=supervisord2.conf.j2 dest=/etc/supervisord.conf notify: restart supervisord when: ansible_distribution_major_version == "6"

cat templates/consul_linux_metric.json.j2

{ "Datacenter": "ssic-1
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值