部署node_运维监控之Prometheus部署node_exporter

简介

node_exporter是在*NIX类系统上,提供到导出系统指标的服务。

e2ca1d10c11cd7eb43b7e16898c9844f.png

部署

可以运行下面的命令下载并执行,进行测试。

VERSION="1.0.1"wget  -t 100  -c  https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.linux-amd64.tar.gztar zxvf node_exporter-${VERSION}.linux-amd64.tar.gzcd node_exporter-${VERSION}.linux-amd64./node_expoter

可以直接运行下面的脚本进行安装,适合systemd服务管理的Linux系统,安装程系统的服务,并设置了开机启动

#!/bin/bashVERSION="1.0.1"wget  -t 100  -c  https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.linux-amd64.tar.gzif [ ! -e node_exporter-${VERSION}.linux-amd64.tar.gz ]then    echo "安装包下载失败"    exit 1fitar xvfz node_exporter-${VERSION}.linux-amd64.tar.gz -C /opt/cd /optln -s node_exporter-${VERSION}.linux-amd64  node_exportercat > /etc/systemd/system/node_exporter.service <
e4411d3a4f3403f5904044ad6e18cc57.png

docker部署

如果有docker环境的主机可以直接通过镜像部署

docker run -d   --net="host"   --pid="host"   -v "/:/host:ro,rslave"   quay.io/prometheus/node-exporter:latest   --path.rootfs=/host

查看指标

默认是使用http协议,直接使用curl就可以获取到指标数据:

curl http://localhost:9100/metrics

prometheus配置

配置prometheus job 进行指标收集;如果是比较固定的资产,我们可以使用静态配置即可。

# my global configglobal:  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.  # scrape_timeout is set to the global default (10s).# Alertmanager configurationalerting:  alertmanagers:  - static_configs:    - targets:      # - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.rule_files:  # - "first_rules.yml"  # - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:# Here it's Prometheus itself.scrape_configs:  # The job name is added as a label `job=` to any timeseries scraped from this config.  - job_name: 'prometheus'    # metrics_path defaults to '/metrics'    # scheme defaults to 'http'.    static_configs:    - targets: ['localhost:9090']  - job_name: 'node_exporter'    static_configs:    # 这里配置的就是node_exporter的地址    - targets: ['localhost:9100', "192.168.142.53:9100","192.168.10.6:9100"]

配置好以后,reload一下prometheus就可以加载

kill -HUP [promethues_pid]

指标展示

指标可以通过prometheus的WebUI进行查看

http://[promethe server ip]:9090

如果需要画图,可以直接使用grafana,有人已经配置好了图形可以通过grafana官方下的dashboard找到,配置好prometheus数据源,直接导入grafana就可以直接展示了。

69010f721fbabe5ab99793f1852ebdfb.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值