본문 바로가기
Redis

Redis Exporter 설치 및 Grafana Dashboard

by study4me 2025. 11. 30.
반응형

참고

버전

  • redis exporter v1.76.0 (2025.06.08 release) ==> 7까지 지원한다고 공식 문서에 나옴...
  • redis 8.0.0 (2025.05.02 release)

환경

  • Reids: VM
  • Prometheus: Kubernetes - kube-prometheus-stack 사용

1. 사전 준비

1.1 Redis User 권한 설정

https://github.com/oliver006/redis_exporter?tab=readme-ov-file#authenticating-with-redis

# redis-exporter 사용자에게 권한 부여(users.acl 방법 권장)

## ver1 users.acl로 사용자에게 권한 부여
vi users.acl
user redis-exporter on >비밀번호 -@all +@connection +memory -readonly +strlen +config|get +xinfo +pfcount -quit +zcard +type +xlen -readwrite -command +client -wait +scard +llen +hlen +get +eval +slowlog +cluster|info +cluster|slots +cluster|nodes -hello -echo +info +latency +scan -reset -auth -asking

## ver2 명령어로 부여하는 방법
ACL SETUSER <<<USERNAME>>> -@all +@connection +memory -readonly +strlen +config|get +xinfo +pfcount -quit +zcard +type +xlen -readwrite -command +client -wait +scard +llen +hlen +get +eval +slowlog +cluster|info +cluster|slots +cluster|nodes -hello -echo +info +latency +scan -reset -auth -asking ><<<PASSWORD>>>

2. Redis_Exporter 구축 방법

2.1 redis_exporter 사용자 생성

useradd --system --no-create-home --shell /sbin/nologin redis_exporter
id redis_exporter

2.2 설치

# 설치 파일 다운로드
curl -LO https://github.com/oliver006/redis_exporter/releases/download/v1.76.0/redis_exporter-v1.76.0.linux-amd64.tar.gz
tar -zxvf redis_exporter-v1.76.0.linux-amd64.tar.gz
redis_exporter-v1.76.0.linux-amd64/redis_exporter --version

# 실행파일 셋팅
mv redis_exporter-v1.76.0.linux-amd64/redis_exporter /usr/local/bin/
chown redis_exporter:redis_exporter /usr/local/bin/redis_exporter
chmod 755 /usr/local/bin/redis_exporter


# 필요 시 redis_exporter_password.json 생성
## redis://User:Password@Host:Port
## 참고로 json에서 localhost로하고, Redis Exporter에서는 127.0.0.1로하면 감지를 못하는 것 같았다.
## Redis Exporter 실행 명령어에 옵션으로 준 값들과 json 파일에 명시한 Key 정보가 일치해야 비밀번호(Value)로 활용하는 듯하다.
password_file_path=/경로지정하기
cat <<EOF | sudo tee $password_file_path/redis_exporter_password.json
{
  "redis://redis_exporter@127.0.0.1:6379": "redis_exporter-password"
}
EOF
cat $password_file_path/redis_exporter_password.json

# Systemd 등록
password_file_path=/경로지정하기

cat <<EOF | sudo tee /etc/systemd/system/redis-exporter.service
[Unit]
Description=Redis Exporter
Wants=network-online.target
After=network-online.target
Documentation=https://github.com/oliver006/redis_exporter

[Service]
User=redis_exporter
Group=redis_exporter
Type=simple
ExecStart=/bin/bash -c '/usr/local/bin/redis_exporter -redis.addr redis://127.0.0.1:6379 -redis.user redis-exporter -redis.password 비밀번호'
# ExecStart=/bin/bash -c '/usr/local/bin/redis_exporter -redis.addr redis://127.0.0.1:6379 -redis.user redis-exporter -redis.password-file $password_file_path/redis_exporter_password.json'
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF
cat /etc/systemd/system/redis-exporter.service
# Systemd 작성 시 고려할 부분
## [Service] User, Group 부분 --> 프로세스 기동 User, Group 설정. redis_exporter 바이너리 파일의 파일 권한 고려
## [Service] ExecStart 부분 --> redis_exporter 옵션 중 Password를 직접 입력하는 방삭과 파일로 던져주는 방식이 존재함.

# 데몬 재로드
systemctl daemon-reload

# 실행
systemctl enable redis-exporter
systemctl start redis-exporter
systemctl status redis-exporter

2.3 수집 설정

수집 설정할 때 label을 적절히 설정하자.

Dashboard 구성할 때 유용하게 쓰일 것이다.

# Prometheus Config 수정
vi kube-prometheus-stack/values.yaml
#---------------------------------------------------------
(생략)
additionalScrapeConfigs:
  - job_name: redis_exporter
    static_configs:
    - targets: ['10.0.0.10:9121']
      labels:
        vm: redis-a-01
        redis_group: redis-a
    - targets: ['10.0.0.11:9121']
      labels:
        vm: redis-a-02
        redis_group: redis-a
    - targets: ['10.0.0.12:9121']
      labels:
        vm: redis-a-03
        redis_group: redis-a
#---------------------------------------------------------

2.3 Dashboard

# oliver006: (763)
 - https://grafana.com/grafana/dashboards/763-redis-dashboard-for-prometheus-redis-exporter-1-x/

 

[신규 추가] Redis Cluster Up/Down

위 Dashboard에서는 Redis의 상태 체크가 없다.

아래 링크를 참고해서 Redis Cluster의 상태를 표시하는 지표를 사용하여 패널을 추가해주자. 

https://grafana.com/docs/grafana-cloud/knowledge-graph/enable-prom-metrics-collection/data-stores/redis/

redis_up{redis_group=~"$group"}

 

[수정] 각 Panel에서 Legend > Values에서 Last, Min, Max, Mean 값들을 추가해줄 수 있음.

위 Dashboard에서는 그래프로 나와있어서 Min, Mas, Mean 값을 직관적으로 알기 쉽지 않다.

따라서 각 패널을 수정하여 각 값을 표로 볼 수 있도록 수정해주자.

반응형