percona / mongodb_exporter

A Prometheus exporter for MongoDB including sharding, replication and storage engines
Apache License 2.0
1.14k stars 421 forks source link

Possible IPV6 Compatibility Issue #867

Closed kaykhan closed 3 weeks ago

kaykhan commented 3 weeks ago

Describe the bug

I have attached percona/mongodb_exporter as a sidecar to percona/mongodb_server. However i noticed the metrics were not coming through.

Checking the logs of the persona/mongodb_exporter i can see.

time="2024-06-25T10:21:32Z" level=error msg="Cannot connect to MongoDB: invalid dsn: error parsing uri: invalid host \"2a05:d01c:516:b402:3fbf::1:27017\": address 2a05:d01c:516:b402:3fbf::1:27017: too many colons in address" level=info ts=2024-06-25T10:21:32.860Z caller=tls_config.go:274 msg="Listening on" address=[::]:9216 level=info ts=2024-06-25T10:21:32.861Z caller=tls_config.go:277 msg="TLS is disabled." http2=false address=[::]:9216 time="2024-06-25T10:21:47Z" level=error msg="Cannot connect to MongoDB: invalid dsn: error parsing uri: invalid host \"2a05:d01c:516:b402:3fbf::1:27017\": address 2a05:d01c:516:b402:3fbf::1:27017: too many colons in address"

My Kubernetes Cluster is provisioned as IPV6 Only.

To Reproduce

      sidecars:
          - image: percona/mongodb_exporter:0.40
            name: metrics 
            env:
            - name: EXPORTER_USER
              valueFrom:
                secretKeyRef:
                  name: psmdb-db-internal-secrets
                  key: MONGODB_CLUSTER_MONITOR_USER
            - name: EXPORTER_PASS
              valueFrom:
                secretKeyRef:
                  name: psmdb-db-internal-secrets
                  key: MONGODB_CLUSTER_MONITOR_PASSWORD
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: MONGODB_URI
              value: "mongodb://$(EXPORTER_USER):$(EXPORTER_PASS)@$(POD_IP):27017"
            args: ["--discovering-mode", "--compatible-mode", "--collect-all", "--mongodb.uri=$(MONGODB_URI)"]

Expected behavior A clear and concise description of what you expected to happen.

Logs

kubectl -n mongodb logs -f pod/psmdb-db-internal-rs0-0 -c metrics

time="2024-06-25T10:21:32Z" level=error msg="Cannot connect to MongoDB: invalid dsn: error parsing uri: invalid host \"2a05:d01c:516:b402:3fbf::1:27017\": address 2a05:d01c:516:b402:3fbf::1:27017: too many colons in address" level=info ts=2024-06-25T10:21:32.860Z caller=tls_config.go:274 msg="Listening on" address=[::]:9216 level=info ts=2024-06-25T10:21:32.861Z caller=tls_config.go:277 msg="TLS is disabled." http2=false address=[::]:9216 time="2024-06-25T10:21:47Z" level=error msg="Cannot connect to MongoDB: invalid dsn: error parsing uri: invalid host \"2a05:d01c:516:b402:3fbf::1:27017\": address 2a05:d01c:516:b402:3fbf::1:27017: too many colons in address" time="2024-06-25T10:22:02Z" level=error msg="Cannot connect to MongoDB: invalid dsn: error parsing uri: invalid host \"2a05:d01c:516:b402:3fbf::1:27017\": address 2a05:d01c:516:b402:3fbf::1:27017: too many colons in address"

Environment

Additional context Add any other context about the problem here.

kaykhan commented 3 weeks ago

I managed to resolve this by changing the MONGODB_URI value to "mongodb://$(EXPORTER_USER):$(EXPORTER_PASS)@[$(POD_IP)]:27017"