Mongodb Percona Exporter issues

I have setup Percona MongoDB Exporter and when I attempt to scrape metrics for my MongoDB instance I am getting an error :

level=info ts=2022-07-14T03:00:10.407Z caller=tls_config.go:195 msg="TLS is disabled." http2=false
time="2022-07-14T03:00:40Z" level=error msg="Cannot connect to MongoDB: cannot connect to MongoDB: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: shard0-data-0.mongodb-sharded.cisco-mongodb-testapp-dedicated-any-mongodb-sharded.svc:27017, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp 101.0.136.114:27017: connect: connection refused }, ] }"

It says TLS is disabled even though I included it in the mongodb URI, and is not connecting. Mongodb server is one way tls encryption

My Deployment looks like this,

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb-exporter
  namespace: labs
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongodb-exporter
  template:
    metadata:
      labels:
        app: mongodb-exporter
    spec:
      containers:
      - name: mongodb-exporter
        image: percona/mongodb_exporter:0.30
        imagePullPolicy: "IfNotPresent"
        args:
        - "--mongodb.direct-connect=true"
        - "--mongodb.uri=mongodb://shard0-data-0.mongodb-sharded.{{.Namespace}}.svc:27017/?tls=true&tlsCAFile=/certs/service/cacerts.crt
        ports:
        - name: metrics
          containerPort: 9216
        resources:
          requests:
            memory: 128Mi
            cpu: 250m
1 Like

Hello @Daniel_Bernstein ,

is it a sharded cluster? Have you tried to connect to Mongo through mongos?

Also how does your TLS configuration look like in mongo itself?

1 Like