redis_exporter with Google Memorystore for Redis

10/7/2021

I have a prometheus instance installed on my gke cluster (operator-prometheus), I would like to scrape metrics from my gcp managed redis instance.

I have the following deployment definition for redis_exporter:

apiVersion: apps/v1
kind: Deployment
metadata:
 name: redis-exporter
spec:
 selector:
   matchLabels:
     app: redis-exporter
 replicas: 1
 template:
   metadata:
     labels:
       app: redis-exporter
     annotations:
       prometheus.io/port: "9121"
       prometheus.io/scrape: "true"
   spec:
     containers:
     - name: redis-exporter
       image: oliver006/redis_exporter:latest
       ports:
         - containerPort: 9121
       env:
       - name: REDIS_ADDR
         value: 'redis://10.xxx.151.xxx:6379'
       resources:
         limits:
           memory: "256Mi"
           cpu: "256m"

My service definition:

apiVersion: v1
kind: Service
metadata:
  name: redis-external-exporter
  namespace: monitoring
  annotations:
    prometheus.io/scrape: 'true'
    prometheus.io/port: "9121"
spec:
  ports:
  - name: redis-ext
    port: 9121
    protocol: TCP
    targetPort: 9121
  selector:
    app: redis-exporter

And finally, my ServiceMonitor definition

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: redis-external-exporter
  labels:
    app: redis-external-exporter
    prometheus-instance: clusterwide
spec:
  jobLabel: app
  selector:
    matchLabels:
      app: redis-ext
  endpoints:
  - interval: 30s
    port: redis-ext
    honorLabels: true
    path: /metrics
  namespaceSelector:
    matchNames:
    - monitoring

Am I missing something? If I browse to port 9121 I'm able to see the metrics, it seems its just a problem of connect all the pieces together.

Kindly asking for your help!

-- Zuri Rodriguez
kubernetes
prometheus
redis

0 Answers