简体   繁体   中英

MongoDB Prometheus-Community exporter not able to fetch the metrics of MongoDB which is enabled by TLS

Using Prometheus-community Exporter for fetching metrics from MongoDB Which is TLS enabled. but metrics are not showing in the Prometheus and in logs of Exporter pod as:

kubectl logs expo-prometheus-mongodb-exporter-55865c7f86-kvg4r -n final-test

time="2022-03-15T11:25:27Z" level=info msg="Starting mongodb_exporter (version=, branch=, revision=)" source="mongodb_exporter.go:94" time="2022-03-15T11:25:27Z" level=info msg="Build context (go=go1.11.13, user=, date=19700101-00:00:00)" source="mongodb_exporter.go:95" time="2022-03-15T11:25:27Z" level=error msg="(CommandNotSupportedOnView) Namespace local.system.tenantMigration.oplogView is a view, not a collection. Collection stats will not be collected for this collection. This log message will be suppressed from now." source="collections_status.go:169" time="2022-03-15T11:25:27Z" level=error msg="(Unauthorized) not authorized on admin to execute command { aggregate: "system.version", pipeline: [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID("8224906c-49b8-4699-8b3a-972d5518caa0") }, $clusterTime: { clusterTime: Timestamp(1647343521, 1), signature: { hash: BinData(0, F43E74F913B4AECCA2BC772062CFA55B067693D8), keyId: 7073820031389270020 } }, $db: "admin", $readPreference: { mode: "nearest" } }. Index usage stats will not be collected for this collection. This log message will be suppressed from now." source="index_usage.go:104" time="2022-03-15T11:25:27Z" level=error msg="(Unauthorized) not authorized on admin to execute command { aggregate: "system.keys", pipeline: [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID("8224906c-49b8-4699-8b3a-972d5518caa0") }, $clusterTime: { clusterTime: Timestamp(1647343521, 1), signature: { hash: BinData(0, F43E74F913B4AECCA2BC772062CFA55B067693D8), keyId: 7073820031389270020 } }, $db: "admin", $readPreference: { mode: "nearest" } }. Index usage stats will not be collected for this collection. This log message will be suppressed from now." source="index_usage.go:104" time="2022-03-15T11:25:27Z" level=error msg="(Unauthorized) not authorized on admin to execute command { aggregate: "system.users", pipeline: [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID("8224906c-49b8-4699-8b3a-972d5518caa0") }, $clusterTime: { clusterTime: Timestamp(1647343521, 1), signature: { hash: BinData(0, F43E74F913B4AECCA2BC772062CFA55B067693D8), keyId: 7073820031389270020 } }, $db: "admin", $readPreference: { mode: "nearest" } }. Index usage stats will not be collected for this collection. This log message will be suppressed from now." source="index_usage.go:104" time="2022-03-15T11:25:27Z" level=error msg="(Unauthorized) not authorized on config to execute command { aggregate: "system.indexBuilds", pipeline: [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID("8224906c-49b8-4699-8b3a-972d5518caa0") }, $clusterTime: { clusterTime: Timestamp(1647343521, 1), signature: { hash: BinData(0, F43E74F913B4AECCA2BC772062CFA55B067693D8), keyId: 7073820031389270020 } }, $db: "config", $readPreference: { mode: "nearest" } }. Index usage stats will not be collected for this collection. This log message will be suppressed from now." source="index_usage.go:104" time="2022-03-15T11:25:27Z" level=error msg="(Unauthorized) not authorized on config to execute command { aggregate: "system.sessions", pipeline: [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID("8224906c-49b8-4699-8b3a-972d5518caa0") }, $clusterTime: { clusterTime: Timestamp(1647343521, 1), signature: { hash: BinData(0, F43E74F913B4AECCA2BC772062CFA55B067693D8), keyId: 7073820031389270020 } }, $db: "config", $readPreference: { mode: "nearest" } }. Index usage stats will not be collected for this collection. This log message will be suppressed from now." source="index_usage.go:104" time="2022-03-15T11:25:27Z" level=error msg="(Unauthorized) not authorized on local to execute command { aggregate: "replset.minvalid", pipeline: [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID("8224906c-49b8-4699-8b3a-972d5518caa0") }, $clusterTime: { clusterTime: Timestamp(1647343521, 1), signature: { hash: BinData(0, F43E74F913B4AECCA2BC772062CFA55B067693D8), keyId: 7073820031389270020 } }, $db: "local", $readPreference: { mode: "nearest" } }. Index usage stats will not be collected for this collection. This log message will be suppressed from now." source="index_usage.go:104" [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID("8224906c-49b8-4699-8b3a-972d5518caa0") }, $clusterTime: { clusterTime: Timestamp(1647343521, 1), signature: { hash: BinData(0, F43E74F913B4AECCA2BC772062CFA55B067693D8), keyId: 7073820031389270020 } }, $db: "local", $readPreference: { mode: "nearest" } }. Index usage stats will not be collected for this collection. This log message will be suppressed from now." source="index_usage.go:104" time="2022-03-15T11:25:27Z" level=info msg="Starting HTTP server for http://:9216/metrics..." source="server.go:140"

MongoDB is Enabled by TLS Connection string is: "mongodb://mongo:mongo123@mongodb-2.mongodb.final-test.svc.cluster.local:27017/admin?replicaSet=rs1&tls=true&tlsCertificateKeyFile=/tmp/tls-combined.pem&tlsCAFile=/tmp/ca.crt"

Any Suggestions would be helpful.

I have encountered this issue with a mongodb-exporter deployed through bitnami's helm chart where in order to get mongodb metrics besides mongodb_up was to provide "--collect-all" flag to exporter. If you are using the same chart then you need to provide it through extraFlags in the values.yaml

extraFlags: "--collect-all"

if the exporter is spinned-up via compose then you will need to have it under command such as (it will obviously be different considering that you will tls flags in there):

    command: 
      - "--mongodb.uri=mongodb://mongo:27017"
      - "--mongodb.collstats-colls=Test.Listings"
      - "--discovering-mode"
      - "--mongodb.direct-connect"  
      - "--collect-all"  

The image being used within our chart was "bitnami/mongodb-exporter:0.32.0-debian-10-r3".

However, the available dashboards make use of older metric names so my dashboards that I picked from under percona's repository even after modifying the datasources did not get populated.

One suggestion regarding when I was searching online was that is adding "--compatible-mode" as well but that has been reported to be not working with mongo:5 and up. I have yet to confirm with previous releases such as mongo:4.2

I am currently trying to convert the queries of the dashboards accordingly with the new metric names though it ain't pretty.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM