Prometheus exporter Target 추가하기 - Redis 편

DevOps Engineer·2023년 9월 13일
0

이 작업을 하게 된 이유

redis 의 Connect가 끊어지는 현상이 생기면서 Application이 정상적으로 동작하지않고 에러를 뱉고있었음 그에 대한 모니터링이 가능하며 Alert설정이 필요한 상황

개발환경

온프레미스 쿠버네티스 클러스터 / 온프레미스에 설치한 Redis

Redis-Exporter 설치과정

명령어 참고 확인 사이트
https://github.com/oliver006/redis_exporter

cd /opt/prometheus
sudo wget https://github.com/oliver006/redis_exporter/releases/download/v1.24.0/redis_exporter-v1.24.0.linux-amd64.tar.gz
sudo tar -zxvf redis_exporter-v1.24.0.linux-amd64.tar.gz
sudo mv redis_exporter-v1.24.0.linux-amd64/ redis_exporter


#service 등록
sudo vi /usr/lib/systemd/system/redis_exporter.service
#우분투 최신버전이 아닐 경우
sudo vi /etc/systemd/system/redis_exporter.service

[Unit]
Description=Redis Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=root
Group=root
Type=simple
ExecStart=/opt/prometheus/redis_exporter/redis_exporter \
    -web.listen-address ":9121" \
    -redis.addr "redis://xxx.xxx.xxx.xxx:6379" \
    -redis.password "redis-password"
[Install]
WantedBy=multi-user.target


sudo systemctl daemon-reload
sudo systemctl start redis_exporter
sudo systemctl enable redis_exporter

Redis-servicemonitor 헬름 설치

#reids-servicemonitor-values.yaml
## String to partially override fullname template (will maintain the release name)
##
nameOverride: ""

## String to fully override fullname template
##
fullnameOverride: ""

# where the mysql installed namespace
namespaceSelector: monitoring
# endports
endpoints:
  - xxx.xxx.xxx.xxx #서버IP
  - yyy.yyy.yyy.yyy
  - zzz.zzz.zzz.zzz
# on what port are the metrics exposed by etcd
metricsPortName: metrics
metricsPort: 9121
# Are we talking http or https?
scheme: http
## Custom Labels to be added to ServiceMonitor
# 经过测试,servicemonitor标签添加prometheus operator的release标签即可正常监控
additionalServiceMonitorLabels:
  release: prometheus-operator
# Custom Labels to be added to Prometheus Rules CRD
additionalRulesLabels:
  release: prometheus-operator

prometheusRule:
  enabled: false
helm repo add ygqygq2 https://ygqygq2.github.io/charts/
helm install redis-servicemonitor -f redis-servicemonitor-values.yaml ygqygq2/redis-servicemonitor --version 1.0.0 -n monitoring

#Chart Custom 후 local에서 사용할 경우

helm lint
#chart 테스트
helm install redis-servicemonitor -f redis-servicemonitor-values.yaml /path/in/chart(차트있는 경로) -n monitoring

위 template
https://artifacthub.io/packages/helm/ygqygq2/redis-servicemonitor?modal=template&template=prometheusrule.yaml

설치 후
Target 확인하기

profile
madame의 Techblog

0개의 댓글