oliver006 / redis_exporter

Prometheus Exporter for ValKey & Redis Metrics. Supports ValKey and Redis 2.x, 3.x, 4.x, 5.x, 6.x, and 7.x
https://github.com/oliver006/redis_exporter
MIT License
3.04k stars 860 forks source link

Couldn't connect to redis instance (redis://localhost:6379) #814

Closed linkypi closed 1 year ago

linkypi commented 1 year ago

Describe the problem I don't know why redis exporter show this log, especially the localhost:6379,I have not config this host. I config the multiple redis hosts with redis_passwd.json with k8s config map.

time="2023-06-29T08:06:49Z" level=info msg="Redis Metrics Exporter v1.51.0    build date:     sha1: c3efa55016c226a43a66b0a8b44cdb0c149048c4    Go: go1.20.5    GOOS: linux    GOARCH: amd64"
time="2023-06-29T08:06:49Z" level=info msg="Loaded 2 entries from /opt/redis_passwd.json"
time="2023-06-29T08:06:49Z" level=info msg="Providing metrics at :9121/metrics"
time="2023-06-29T08:13:37Z" level=error msg="Couldn't connect to redis instance (redis://localhost:6379)"

my k8s resource file:

apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-passwd-cm
  namespace: monitoring
data:
  redis_passwd.json: |
    {
      "redis://presit-redis-master-0.presit-redis-headless.presit.svc.cluster.local:6379":"xxxx",
      "redis://sit-redis-master-0.sit-redis-headless.sit.svc.cluster.local:6379":"xxxxx"
    }

---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: redis-exporter
  name: redis-exporter
  namespace: monitoring
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis-exporter
  template:
    metadata:
      labels:
        app: redis-exporter
    spec:
      containers:
      - name: redis-exporter
        image: oliver006/redis_exporter:latest
        env:
        - name: TZ
          value: "Asia/Shanghai"
        args:
        - "-redis.password-file=/opt/redis_passwd.json"
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            memory: 256Mi
            cpu: 300m
        ports:
        - name: http-metrics
          containerPort: 9121
          protocol: TCP
        livenessProbe:
          tcpSocket:
            port: 9121
          initialDelaySeconds: 10
          timeoutSeconds: 5
          periodSeconds: 10
        readinessProbe:
          tcpSocket:
            port: 9121
          initialDelaySeconds: 5
          timeoutSeconds: 5
          periodSeconds: 20
        volumeMounts:
        - name: redis-passwd
          mountPath: "/opt"
      volumes:
      - name: redis-passwd
        configMap:
          name: redis-passwd-cm
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: redis-exporter
  name: redis-exporter
  namespace: monitoring
spec:
  ports:
  - name: http-metirc
    protocol: TCP
    port: 9121
    targetPort: 9121
  selector:
    app: redis-exporter

image

What version of redis_exporter are you running? Please run redis_exporter --version if you're not sure what version you're running.

redis-exporter version is v1.51.0. image : oliver006/redis_exporter:latest

Running the exporter What's the full command you're using to run the exporter? (please remove passwords and other sensitive data)

redis_exporter -redis.password-file=/opt/redis_passwd.json

Expected behavior What metrics are missing? What metrics are wrong? Is something missing that was present in an earlier version? Did you upgrade from 0.3x.x to 1.0 and are scraping multiple hosts? Have a look here how the configuration changed.

Screenshots If applicable, add screenshots to help explain your problem.

image

Additional context Add any other context about the problem here.

oliver006 commented 1 year ago

From https://github.com/oliver006/redis_exporter#prometheus-configuration-to-scrape-multiple-redis-hosts

Run the exporter with the command line flag --redis.addr= so it won't try to access the local instance every time the /metrics endpoint is scraped.