安装包:https://github.com/prometheus/node_exporter/releases
Node-exporter 可以采集机器(物理机、虚拟机、云主机)的监控指标数据,能够采集到的指标包括cpu、内存、磁盘、网络、文件数等信息。
- ###下载node_exporter包
- [root@node ~]#wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
- [root@node ~]# tar xvf node_exporter-1.3.1.linux-amd64.tar.gz -C /home/
- [root@node ~]# mv /home/node_exporter-1.3.1.linux-amd64 /home/node_exporter
-
- ###创建node_exporter启动文件
- [root@node ~]# vi /usr/lib/systemd/system/node_exporter.service
- [Unit]
- Description=prometheus node_exporter
-
- [Service]
- Type=simple
- ExecStart=/home/node_exporter/node_exporter
- ExecReload=/bin/kill -HUP $MAINPID
- KillMode=process
- Restart=on-failure
- RestartSec=42s
- MemoryLimit=300M //内存最大占用300M
- CPUQuota=100% //最多占用一个CPU线程
-
- [Install]
- WantedBy=multi-user.target
-
- "/usr/lib/systemd/system/node_exporter.service" [New] 15L, 266C written
-
- ####重新加载启动文件目录,并设置开机自启
- [root@node ~]# systemctl daemon-reload
- [root@node ~]# systemctl start node_exporter
- [root@node ~]# systemctl enable node_exporter
注意:被控节点防火墙需要放通9100端口
- [root@test node_exporter]# vi /home/prometheus/prometheus.yml
- - job_name: "node"
- static_configs:
- - targets: ["172.27.30.92:9100","172.27.30.85:9100"]
- [root@test node_exporter]# curl -X POST http://172.27.30.94:9090/-/reload
登录Prometheus,在Targets下可查看已监听到的主机
安装包:https://github.com/justwatchcom/elasticsearch_exporter/releases
elasticsearch_exporter可用于 ElasticSearch 的各种指标的 Prometheus 导出器,由 Go 语言编写。导出器在每次抓取时从 ElasticSearch 集群中获取信息,因此抓取间隔太短会给 ES 主节点带来负载。
- ###下载elasticsearch包
- [root@node ~]#wget https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.3.0/elasticsearch_exporter-1.3.0.linux-386.tar.gz
- [root@node ~]# tar xvf elasticsearch_exporter-1.3.0.linux-386.tar.gz -C /usr/local/
- [root@node ~]# cd /usr/local/elasticsearch_exporter-1.3.0.linux-386/
- [root@node local]# mv elasticsearch_exporter-1.3.0.linux-386 elasticsearch_exporter
- ###创建elasticsearch_exporter启动文件
- [root@node ~]# vi /usr/lib/systemd/system/elasticsearch_exporter.service
- [[Unit]
- Description=prometheus elasticsearch
-
- [Service]
- Type=simple
- ExecStart=/usr/local/elasticsearch_exporter/elasticsearch_exporter --es.uri http://10.0.134.51:9200
- ExecReload=/bin/kill -HUP $MAINPID
- KillMode=process
- Restart=on-failure
- RestartSec=42s
- MemoryLimit=300M
- CPUQuota=100%
-
- [Install]
- WantedBy=multi-user.target
-
- ####重新加载启动文件目录,并设置开机自启
- [root@node ~]# systemctl daemon-reload
- [root@node ~]# systemctl start elasticsearch_exporter
- [root@node ~]# systemctl enable elasticsearch_exporter
注意:被控节点防火墙需要放通9144端口,
"--es.uri http://elasticsearch集群或本机的IP:9200"必填
- [root@test node_exporter]# vi /home/prometheus/prometheus.yml
- - job_name: "elasticsearch"
- static_configs:
- - targets: ["172.27.30.92:9100","172.27.30.85:9100"]
-
- [root@test node_exporter]# curl -XPORT http://172.27.30.94:9090/-/reload
登录Prometheus,在Targets下可查看已监听到的主机
安装包:https://github.com/oliver006/redis_exporter/releases
- ###下载redis包
- [root@node ~]# wget https://github.com/oliver006/redis_exporter/releases/download/v1.43.0/redis_exporter-v1.43.0.linux-amd64.tar.gz
- [root@node ~]# tar xvf redis_exporter-v1.43.0.linux-amd64.tar.gz -C /usr/local/
- [root@node ~]# cd /usr/local/redis_exporter-v1.43.0.linux-amd64/
- [root@node local]# mv redis_exporter-v1.43.0.linux-amd64 redis_exporter
- ###创建redis启动文件
- [root@node ~]# vi /usr/lib/systemd/system/redis_exporter.service
- [Unit]
- Description=prometheus redis_exporter
-
- [Service]
- Type=simple
- ExecStart=/usr/local/redis_exporter/redis_exporter -redis.addr 127.0.0.1:9001 127.0.0.1:9000
- ExecReload=/bin/kill -HUP $MAINPID
- KillMode=process
- Restart=on-failure
- RestartSec=42s
-
- [Install]
- WantedBy=multi-user.target
-
- ####重新加载启动文件目录,并设置开机自启
- [root@node ~]# systemctl daemon-reload
- [root@node ~]# systemctl start redis_exporter
- [root@node ~]# systemctl enable redis_exporter
注意:被控节点防火墙需要放通9121端口,
手动运行:
- [root@node ~]#/usr/local/redis_exporter/redis_exporter -redis.addr 10.9.68.46:6381 -web.listen-address :3389
- #-redis.addr: 指定redis服务的ip地址和端口号
- #-web.listen-address: 指定当前redis-exporter启动使用的端口信息
- #-redis.password: redis服务若是有密码的话,可用此参数指定redis的密码
- [root@test node_exporter]# vi /home/prometheus/prometheus.yml
- - job_name: "rides"
- static_configs:
- - targets: ["172.27.30.92:9121","172.27.30.85:9121"]
-
- [root@test node_exporter]# curl -XPORT http://172.27.30.94:9090/-/reload
登录Prometheus,在Targets下可查看已监听到的主机
http://172.27.30.94:9090/targets
安装包:https://github.com/kbudde/rabbitmq_exporter/releases
注意:安装包分两大版本,RC版本使用传统方式安装grafana Dashboards抓取参数不全
rabbitmq_exporter_1.0.0-RCxx 版本安装包使用9419端口
rabbitmq_exporter-x.xx.x版本使用9090端口
- ###下载rabbitmq_exporter包
- [root@node ~]# wget https://github.com/kbudde/rabbitmq_exporter/releases/download/0.29.0./rabbitmq_exporter-0.29.0.linux-amd64.tar.gz
- [root@node ~]# mkdir /usr/local/rabbitmq_exporter
- [root@node ~]# tar xvf rabbitmq_exporter-0.29.0.linux-amd64.tar.gz -C /usr/local/rabbitmq_exporter/
- [root@node ~]# cd /usr/local/rabbitmq_exporter
-
- ###创建rabbitmq_exporter启动文件
- [root@node ~]# vi /usr/lib/systemd/system/rabbitmq_exporter.service
- [Unit]
- Description=prometheus rabbitmq_exporter
-
- [Service]
- Type=simple
- DefaultEnvironment='RABBIT_USER=rabbitmq RABBIT_PASSWORD=yQqZVRDG OUTPUT_FORMAT=JSON PUBLISH_PORT=9090 RABBIT_URL=http://localhost:15672'
- ExecStart=/usr/local/rabbitmq_exporter/rabbitmq_exporter
- ExecReload=/bin/kill -HUP $MAINPID
- KillMode=process
- Restart=on-failure
- RestartSec=42s
- MemoryLimit=300M
- CPUQuota=100%
-
- [Install]
- WantedBy=multi-user.target
-
- ####重新加载启动文件目录,并设置开机自启
- [root@node ~]# systemctl daemon-reload
- [root@node ~]# systemctl start rabbitmq_exporter
- [root@node ~]# systemctl enable rabbitmq_exporter
注意:被控节点防火墙需要放通9419端口
- [root@test node_exporter]# vi /home/prometheus/prometheus.yml
- - job_name: "rebbitmq"
- static_configs:
- - targets: ["172.27.30.92:9419","172.27.30.85:9419"]
- [root@test node_exporter]# curl -X POST http://172.27.30.94:9090/-/reload
登录Prometheus,在Targets下可查看已监听到的主机
http://172.27.30.94:9090/targets
安装包:https://github.com/danielqsj/kafka_exporter
kafka集群监控,本示例使用docker-compose安装kafka_exporter,也可参考官方手册使用本地安装包部署安装
- [root@node3 ~]# vi /home/ssitg/core-service/docker-compose.yml
- version: '3.7'
- kafka:
- image: danielqsj/kafka-exporter:latest
- volumes:
- - /etc/localtime:/etc/localtime
- command: --kafka.server=172.27.30.94:19099 --kafka.server=172.27.30.92:19098 --kafka.server=172.27.30.84:19097
- network_mode: "host"
- ports:
- - "9308:9308"
-
- [root@node3 ~]# cd /home/ssitg/core-service/
- [root@node3 core-service]# docker-compose up kafka
注意:被控节点防火墙需要放通9308端口
- [root@test node_exporter]# vi /home/prometheus/prometheus.yml
- - job_name: "kafka"
- static_configs:
- - targets: ["172.27.30.94:9308","172.27.30.92:9308","172.27.30.84:9308"]
- [root@test node_exporter]# curl -X POST http://172.27.30.94:9090/-/reload
登录Prometheus,在Targets下可查看已监听到的主机
http://172.27.30.94:9090/targets
应用名称 | Dashboard ID | 备注 |
Redis | 11835 |
|
Node | 12884 |
|
Elasticsearch | 14191 |
|
4371 |
| |
kafka | 7589 |
|
blackbox | 13230 | 域名证书到期监控 |
Dashboard settings——JSON Model,查看gnetId号