赞
踩
redis_exporter是一个用于收集Redis指标的开源软件,它是Prometheus生态系统中的一个组件。类似于node_exporter和windows_exporter,redis_exporter负责在Redis主机上运行,并公开各种与Redis数据库相关的指标供Prometheus收集。
redis_exporter可以提供各种关于Redis数据库的指标,如内存使用情况、命令执行情况、连接数、持久化策略等。它还可以提供更详细的指标,如key数量、CPU使用率、慢查询等。这些指标可以帮助系统管理员了解Redis数据库的性能和健康状况,并及时采取措施来优化和修复问题。
类似于其他exporter,redis_exporter通过HTTP或者HTTPS暴露一个或多个端点,Prometheus会定期从这些端点拉取指标数据,并进行存储、分析和可视化。借助Prometheus的查询语言,用户可以根据这些指标来构建监控规则和警报条件,以便及时发现和解决Redis数据库的问题。
vim /redis_exporter.sh
- #!/bin/bash
- # -*- coding: utf-8 -*-
- # Author: make.han
- # Email: CIASM@CIASM
- # Date: 2024/01/12
-
- OPT_CATALOGUE=/opt
- REDIS_EXPORTER_PREFIX=/opt/redis_exporter
- REDIS_EXPORTER_URL=https://github.com/oliver006/redis_exporter/releases/download/v1.56.0/redis_exporter-v1.56.0.linux-amd64.tar.gz
- REDIS_EXPORTER_GZ=redis_exporter-v1.56.0.linux-amd64.tar.gz
- REDIS_EXPORTER_DIRECTORY=redis_exporter-v1.56.0.linux-amd64
- REDIS_EXPORTER_NEW=redis_exporter
- REDIS_EXPORTER_PORT=9121
-
- install_redis_exporter (){
- if [ ! -d ${REDIS_EXPORTER_PREFIX} ];then
-
- # selinux stop
- setenforce 0
- sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
-
- if [ $? -eq 0 ];then
-
- echo "download redis_exporter"
- curl -o $OPT_CATALOGUE/$REDIS_EXPORTER_GZ $REDIS_EXPORTER_URL
-
- echo "decompression redis_exporter"
- tar -xf $OPT_CATALOGUE/$REDIS_EXPORTER_GZ -C $OPT_CATALOGUE
-
- echo "rechristen redis_exporter"
- mv $OPT_CATALOGUE/$REDIS_EXPORTER_DIRECTORY $REDIS_EXPORTER_PREFIX
-
- echo "firewall redis_exporter port"
- firewall-cmd --zone=public --add-port=$REDIS_EXPORTER_PORT/tcp --permanent && firewall-cmd --reload
-
- echo "add redis_exporter.service"
- sleep 2
- cat >>/usr/lib/systemd/system/redis_exporter.service<<EOF
- [Unit]
- Description=redis_exporter
- Documentation=https://github.com/prometheus/redis_exporter
- After=local-fs.target network-online.target network.target
- Wants=local-fs.target network-online.target network.target
-
- [Service]
- User=root
- Group=root
- Type=simple
- [Service]
- User=root
- Group=root
- Type=simple
- ExecStart=/opt/redis_exporter/redis_exporter \
- --web.listen-address=:$REDIS_EXPORTER_PORT \
- -redis.addr=127.0.0.1:6379
- #-redis.password=YOU_Redis_password
- Restart=on-failure
-
- [Install]
- WantedBy=multi-user.target
- EOF
-
- echo "start redis_exporter"
- systemctl daemon-reload
- systemctl enable --now redis_exporter
-
- echo "delete redis_exporter"
- rm -rf $OPT_CATALOGUE/$REDIS_EXPORTER_GZ
-
- echo -e "\033[32mThe redis_exporter Install Sussess...\033[0m"
- else
- echo -e "\033[33mThe redis_exporter Install Failed...\033[0m"
- exit 1
- fi
- else
- echo -e "\033[31mThe redis_exporter Install already...\033[0m"
- fi
- }
-
- main (){
- install_redis_exporter
- }
-
- main
sh /redis_exporter.sh
- scrape_configs:
- - job_name: 'web'
- scrape_interval: 5s
- static_configs:
- - targets:
- - localhost:9090
-
- - job_name: 'Redis-monitoring'
- scrape_interval: 5s
- static_configs:
- - targets:
- - 192.168.11.253:9121
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。