Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with MongoDB Exporter Connection to the MongoDB Instance #951

Open
asemarian opened this issue Nov 7, 2024 · 1 comment
Open

Issue with MongoDB Exporter Connection to the MongoDB Instance #951

asemarian opened this issue Nov 7, 2024 · 1 comment

Comments

@asemarian
Copy link

I'm using the Percona Operator for MongoDB to deploy a MongoDB cluster on Kubernetes. I'm trying to add a sidecar container running mongodb_exporter to collect metrics. Here is my current configuration for the sidecar:

sidecars:
  - args:
      - --mongodb.uri=mongodb://mongodb-cluster-a9901-mongodb-replicaset.mongodb-cluster.svc.cluster.local:27017
    env:
      - name: MONGODB_USER
        value: clusterAdmin
      - name: MONGODB_PASSWORD
        value: clusterAdminPassword
    image: percona/mongodb_exporter:0.42
    name: exporter
    ports:
      - containerPort: 9216
        name: metrics

Note that:

  • The MongoDB cluster is already up and running with other applications successfully connected to it.
  • I’m setting the --mongodb.uri argument to connect to the MongoDB instance.
  • I included the port in the URI, though I’m not sure if it’s necessary.
  • I'm using environment variables to pass MONGODB_USER and MONGODB_PASSWORD for the clusterAdmin role.

The problem is that the exporter cannot connect to the MongoDB instance. Here's the logs:

time="2024-10-31T13:58:07Z" level=error msg="Cannot connect to MongoDB: cannot connect to MongoDB: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: mongodb://mongodb-cluster-a9901-mongodb-replicaset.mongodb-cluster.svc.cluster.local:27017, Type: Unknown, Last error: dial tcp: lookup mongodb://mongodb-cluster-a9901-mongodb-replicaset.mongodb-cluster.svc.cluster.local on 10.43.0.10:53: no such host }, ] }"

I'd appreciate any insights you can offer into why the exporter is failing to connect.

Thank you.

@rock1013
Copy link

rock1013 commented Nov 15, 2024

We met the same issue. Our exporter is out of k8s. Now we rollback to 0.40.0. It works fine. I guess new version has detected the mongo replicaset cluster. Without the dns in k8s, exporter can find mongo's ip never.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants