<p>I have an issue with <a href="https://github.com/percona/mongodb_exporter" rel="nofollow noreferrer">mongodb_exporter</a> (prometheus metrics exporter for mongodb). I think it's because of a configuration problem in my side but after 2 days of searching I'm empty of solution :)</p>
<p>I run mongodb on K8S and mongodb_exporter as a sidecar pod.
exporter starts OK (I think, because no error), display some metrics but my problem is that's only &quot;go&quot; metrics (see below), I have just one &quot;mongodb&quot; metric!! =&gt; mongodb_up 1. Even if i put options &quot;--collect-all&quot; or &quot;--collector.collstats&quot;.
I do not have any &quot;useful&quot; metric on my &quot;config&quot; database such as collections size, etc....</p>
<p>Connection to the database is OK because if I change username/password/db port I ran to connection problem.
My user have correct rights I think (changing real password to &quot;password&quot; in my text) :</p>
<pre><code>Successfully added user: {
        &quot;user&quot; : &quot;exporter&quot;,
        &quot;roles&quot; : [
                {
                        &quot;role&quot; : &quot;clusterMonitor&quot;,
                        &quot;db&quot; : &quot;admin&quot;
                },
                {
                        &quot;role&quot; : &quot;read&quot;,
                        &quot;db&quot; : &quot;local&quot;
                }
        ]
}

</code></pre>
<p><strong>Here is my pod configuration :</strong></p>
<pre><code>        - name: metrics
          image: docker.io/bitnami/mongodb-exporter:latest
          command:
            - /bin/bash
            - '-ec'
          args:
            - &gt;
              /bin/mongodb_exporter --web.listen-address &quot;:9216&quot;
              --mongodb.uri=mongodb://exporter:password@localhost:27017/config? --log.level=&quot;debug&quot;  --collect-all
          ports:
            - name: metrics
              containerPort: 9216
              protocol: TCP
          env:
          resources:
            limits:
              cpu: 50m
              memory: 250Mi
            requests:
              cpu: 25m
              memory: 50Mi
          livenessProbe:
            httpGet:
              path: /
              port: metrics
              scheme: HTTP
            initialDelaySeconds: 15
            timeoutSeconds: 5
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /
              port: metrics
              scheme: HTTP
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3

</code></pre>
<p><strong>Logs</strong></p>
<ul>
<li>Exporter start log (with debug activated) :</li>
</ul>
<pre><code>time=&quot;2023-02-03T09:02:25Z&quot; level=debug msg=&quot;Compatible mode: false&quot;
time=&quot;2023-02-03T09:02:25Z&quot; level=debug msg=&quot;Connection URI: mongodb://exporter:password@localhost:27017/config?&quot;
level=info ts=2023-02-03T09:02:25.224Z caller=tls_config.go:195 msg=&quot;TLS is disabled.&quot; http2=false
</code></pre>
<ul>
<li>Displayed metrics :</li>
</ul>
<pre><code># HELP collector_scrape_time_ms Time taken for scrape by collector
# TYPE collector_scrape_time_ms gauge
collector_scrape_time_ms{collector=&quot;general&quot;,exporter=&quot;mongodb&quot;} 0
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile=&quot;0&quot;} 0
go_gc_duration_seconds{quantile=&quot;0.25&quot;} 0
go_gc_duration_seconds{quantile=&quot;0.5&quot;} 0
go_gc_duration_seconds{quantile=&quot;0.75&quot;} 0
go_gc_duration_seconds{quantile=&quot;1&quot;} 0
go_gc_duration_seconds_sum 0
go_gc_duration_seconds_count 0
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 17
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version=&quot;go1.17.13&quot;} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 3.655088e+06
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 3.655088e+06
[....]
# HELP mongodb_up Whether MongoDB is up.
# TYPE mongodb_up gauge
mongodb_up 1
[...]
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 7.35940608e+08
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
</code></pre>
<p><strong>Environment</strong>
K8S
MongoDB version : 4.2.0
Thanks in advance for any help :)</p>

Doul
<p>Yes, found the solution, with the help of JMLX42 on github. The key was to take an another image. Change from <code>docker.io/bitnami/mongodb-exporter:latest</code> to <code>percona/mongodb_exporter:0.37.0</code> (and adapt the configuration) :</p>
<pre><code>    - name: metrics
      image: percona/mongodb_exporter:0.37.0
      args:
        - '--mongodb.uri=mongodb://exporter:password@localhost:27017/config'
        - '--collect-all'
      ports:
        - name: metrics
          containerPort: 9216
          protocol: TCP
      resources:
        requests:
          memory: &quot;50Mi&quot;
          cpu: &quot;25m&quot;
        limits:
          memory: &quot;250Mi&quot;
          cpu: &quot;50m&quot;
      livenessProbe:
        failureThreshold: 3
        initialDelaySeconds: 15
        periodSeconds: 5
        successThreshold: 1
        timeoutSeconds: 5
        httpGet:
          path: /
          port: metrics
      readinessProbe:
        failureThreshold: 3
        initialDelaySeconds: 5
        periodSeconds: 5
        successThreshold: 1
        timeoutSeconds: 1
        httpGet:
          path: /
          port: metrics
</code></pre>
<p>Note : strange thing is that with <code>--collect-all</code> it does not collect collection data. I have to specify collection list  with <code>--mongodb.collstats-colls</code>.</p>
<p>For example : <code>--mongodb.collstats-colls=config.App,config.ApplicationOverride,config.Caller,config.CommonRules,config.HabilitationOverride,config.IconSvg,config.UpdateStatusEntity,config.feature</code></p>
