Prometheus常用exporter部署
作者:互联网
node-exporter部署
https://prometheus.io/
解压部署
tar -zxf node_exporter-1.1.2.linux-amd64.tar.gz
mv node_exporter-1.1.2.linux-amd64 /usr/local/node_exporter
配置service启动文件
cat > /usr/lib/systemd/system/node-exporter.service << 'EOF'
[Unit]
Description=This is prometheus node exporter
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/node_exporter/node_exporter
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
启动exporter
systemctl daemon-reload
systemctl restart node-exporter
systemctl enable node-exporter
redis-exporter
下载地址
https://github.com/oliver006/redis_exporter/releases
解压部署
tar -zxf redis_exporter-v1.20.0.linux-amd64.tar.gz
mv redis_exporter-v1.20.0.linux-amd64 /usr/local/redis_exporter
配置service启动文件
cat > /usr/lib/systemd/system/redis-exporter.service << 'EOF'
[Unit]
Description=This is prometheus redis exporter
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/redis_exporter/redis_exporter -redis.addr 3.1.101.35:6379 -redis-only-metrics -web.listen-address 0.0.0.0:9121 -redis.password g1tredis2o2l
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
启动redis-exporter
systemctl daemon-reload
systemctl restart redis-exporter
systemctl enable redis-exporter
grafana模版ID: 2751,763
elasticsearch_exporter部署
下载地址: https://github.com/justwatchcom/elasticsearch_exporter/releases
解压部署
tar -zxf elasticsearch_exporter-1.1.0.linux-amd64.tar.gz
mv elasticsearch_exporter-1.1.0.linux-amd64 /usr/local/elasticsearch_exporter
配置service启动文件
cat > /usr/lib/systemd/system/es-exporter.service << 'EOF'
[Unit]
Description=This is prometheus elasticsearch exporter
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/elasticsearch_exporter/elasticsearch_exporter \
--es.all --es.indices --es.cluster_settings \
--es.indices_settings --es.shards --es.snapshots \
--es.timeout=10s --web.listen-address=0.0.0.0:9115 \
--web.telemetry-path=/metrics \
--es.uri http://3.1.101.33:9200
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
启动exporter
systemctl daemon-reload
systemctl restart es-exporter
systemctl enable es-exporter
grafana模版ID: 2322
cAdvisor部署
Docker镜像
docker pull google/cadvisor:v0.33.0
镜像导出命令
docker save google/cadvisor:v0.33.0 -o docker-cadvisor-v0.33.0.tar
镜像导入命令
docker load -i docker-cadvisor-v0.33.0.tar
docker-compose编排
version: "3"
services:
cadvisor:
container_name: cadvisor
image: google/cadvisor:v0.33.0
user: root
ports:
- 9080:8080
restart: always
volumes:
- /:/rootfs
- /var/run:/var/run
- /var/lib/docker/:/var/lib/docker
- /dev/disk/:/dev/disk
docker run -d \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:ro \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--volume=/dev/disk/:/dev/disk:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest
四个-v挂载操作不能省,如果不挂载,将无法连接到docker deamon
标签:exporter,cadvisor,部署,redis,--,Prometheus,systemctl,docker 来源: https://blog.csdn.net/wangshui898/article/details/115395942