
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
https://github.com/percona/mongodb_exporter/
https://github.com/percona/mongodb_exporter/actions/workflows/go.yml/badge.svg?branch=main](https://github.com/percona/mongodb_exporter/actions/workflows/go.yml?query=branch%3Amain)  is moved to the release-0.1x branch. |
| If you ***ing migrating from the old version of the exporter - you can |
use flag --compatible-mode to expose metrics in the old metric names. This |
| will simplify migration to the new version for you. |
| Flag | Description | Example |
|---|---|---|
| -h, --help | Show context-sensitive help | |
| --compatible-mode | Exposes new metrics in the new and old format at the same time | |
| --discovering-mode | Enable autodiscover collections from databases which set in collstats-colls and indexstats-colls | |
| --mongodb.collstats-colls | List of comma separated databases.collections to get stats | --mongodb.collstats-colls=testdb.testcol1,testdb.testcol2 |
| --mongodb.direct-connect | Whether or not a direct connect should be made. Direct connections are not valid if multiple hosts are specified or an SRV URI is used | --mongodb.direct-connect=false |
| --mongodb.indexstats-colls | List of comma separated database.collections to get index stats | --mongodb.indexstats-colls=db1.col1,db1.col2 |
| --mongodb.uri | MongoDB connection URI ($MONGODB_URI) | --mongodb.uri=mongodb://user:pass@127.0.0.1:27017/admin?ssl=true |
| --mongodb.global-conn-pool | Use global connection pool instead of creating new connection for each http request. | |
| --web.listen-address | Address to listen on for web interface and telemetry | --web.listen-address=":9216" |
| --web.telemetry-path | Metrics expose path | --web.telemetry-path="/metrics" |
| --log.level | Only log messages with the given severity or above. Valid levels: [debug, info, warn, error] | --log.level="error" |
| --disable.diagnosticdata | Disable collecting metrics from getDiagnosticData | |
| --disable.replicasetstatus | Disable collecting metrics from replSetGetStatus | |
| --disable.dbstats | Disable collecting metrics from dbStats | |
| --version | Show version and exit |
The build process uses the dockerized version of goreleaser so you don't need to install Go.
Just run make release and the new binaries will be generated under the build directory.
├── build │ ├── config.yaml │ ├── mongodb_exporter_7c73946_checksums.txt │ ├── mongodb_exporter-7c73946.darwin-amd64.tar.gz │ ├── mongodb_exporter-7c73946.linux-amd64.tar.gz │ ├── mongodb_exporter_darwin_amd64 │ │ └── mongodb_exporter <--- MacOS binary │ └── mongodb_exporter_linux_amd64 │ └── mongodb_exporter <--- Linux binary
If you built the exporter using the method mentioned in the previous section, the generated binaries are in mongodb_exporter_linux_amd64/mongodb_exporter or mongodb_exporter_darwin_amd64/mongodb_exporter
Docker
A docker image is available on https://hub.docker.com/repository/docker/percona/mongodb_exporter.
Permissions
Connecting user should have sufficient rights to query needed stats:
{ "role":"clusterMonitor", "db":"admin" }, { "role":"read", "db":"local" }
More info about roles in MongoDB documentation.
Example
mongodb_exporter_linux_amd64/mongodb_exporter --mongodb.uri=mongodb://127.0.0.1:17001
Enabling collstats metrics gathering
--mongodb.collstats-colls receives a list of databases and collections to monitor using collstats.
Usage example: --mongodb.collstats-colls=database1.collection1,database2.collection2
mongodb_exporter_linux_amd64/mongodb_exporter --mongodb.uri=mongodb://127.0.0.1:17001 --mongodb.collstats-colls=db1.c1,db2.c2
Enabling compatibility mode.
When compatibility mode is enabled by the --compatible-mode, the exporter will expose all new metrics with the new naming and labeling schema and at the same time will expose metrics in the version 1 compatible way.
For example, if compatibility mode is enabled, the metric mongodb_ss_wt_log_log_bytes_written (new format)
# HELP mongodb_ss_wt_log_log_bytes_written serverStatus.wiredTiger.log. # TYPE mongodb_ss_wt_log_log_bytes_written untyped mongodb_ss_wt_log_log_bytes_written 2.6208e+06
will be also exposed as mongodb_mongod_wiredtiger_log_bytes_total with the unwritten label.
HELP mongodb_mongod_wiredtiger_log_bytes_total mongodb_mongod_wiredtiger_log_bytes_total # TYPE mongodb_mongod_wiredtiger_log_bytes_total untyped mongodb_mongod_wiredtiger_log_bytes_total{type="unwritten"} 2.6208e+06
Cluster role labels
The exporter sets some topology labels in all metrics. The labels are:
| Server type | Label |
|---|---|
| mongos | mongos |
| regular instance (primary or secondary) | shardsvr |
| arbiter | shardsvr |
| standalone | (empty string) |
getDiagnosticData() -> replSetGetStatus.myState.
Check the official documentation for details on replicaset status values.please see Contribution Guide
以下是 percona/mongodb_exporter 相关的常用 Docker 镜像,适用于 不同场景 等不同场景:
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务