Monitoring

Monitoring of Redis standalone and cluster setup using Prometheus

The redis-operator uses redis-exporter to expose metrics of redis setup in Prometheus format. This exporter captures metrics for both redis standalone and cluster setup.

The monitoring architecture is illustrated in the diagram:

redis_operator_architecture

For the helm chart installation of redis setup, we can simply enable the redis exporter by creating a custom values file for helm chart. The content of the values file will look like this:

redisExporter:
  enabled: true
  image: quay.io/opstree/redis-exporter:1.0
  imagePullPolicy: Always

When we have defined the redis-exporter related config in values file, we can apply or upgrade the redis setup. We need to pass the created file as an argument to the helm command.

Enabling monitoring for standalone setup:

$ helm upgrade redis ot-helm/redis -f monitoring-values.yaml \
  --install --namespace ot-operators

Enabling monitoring for cluster setup:

$ helm upgrade redis-cluster ot-helm/redis-cluster -f monitoring-values.yaml \
  --set redisCluster.clusterSize=3 --install --namespace ot-operators

ServiceMonitor

Once the exporter is configured, we may have to update Prometheus to monitor this endpoint. For Prometheus Operator, we have to create a CRD based object called ServiceMonitor. We can apply the CRD definition as well using the helm command.

serviceMonitor:
  enabled: false
  interval: 30s
  scrapeTimeout: 10s
  namespace: monitoring

For kubectl related configuration, we may have to create ServiceMonitor definition in a YAML manifest and apply it using kubectl command.

ServiceMonitor for Redis cluster setup:

---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: redis-cluster
  labels:
    redis-operator: "true"
    env: production
spec:
  selector:
    matchLabels:
      redis_setup_type: cluster
  endpoints:
  - port: redis-exporter
    interval: 30s
    scrapeTimeout: 10s
  namespaceSelector:
    matchNames:
    - monitoring

ServiceMonitor for Redis standalone setup:

---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: redis-standalone
  labels:
    redis-operator: "true"
    env: production
spec:
  selector:
    matchLabels:
      redis_setup_type: standalone
  endpoints:
  - port: redis-exporter
    interval: 30s
    scrapeTimeout: 10s
  namespaceSelector:
    matchNames:
    - monitoring

Grafana Dashboards

There is detailed dashboard created for Redis cluster monitoring setup. Refer to that dashboard once the metrics are available inside Prometheus setup.

Redis Operator Cluster Dashboard for Prometheus

redis_grafana_dashboard


Last modified November 3, 2022: Revamped documentation for better knowledge base (#370) (f3565c1)