
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
!Grafana Dashboard 20383 A Python script that exports MongoDB slow query metrics from system.profile collection for Prometheus monitoring. Read more
bashpip install -r requirements.txt python mongodb-profiler-exporter.py
jsdocker run -p 9179:9179 -it --rm --name mongodb-profiler-exporter andriik/mongodb-profiler-exporter docker run -it --rm --net host --name mongodb-profiler-exporter andriik/mongodb-profiler-exporter // host network
jshelm repo add mongodb-profiler-exporter https://andrii29.github.io/mongodb-profiler-exporter helm repo update helm search repo mongodb-profiler-exporter helm show values mongodb-profiler-exporter/mongodb-profiler-exporter helm install <release-name> -n <namespace-name> mongodb-profiler-exporter/mongodb-profiler-exporter
usage: mongodb-profiler-exporter.py [-h] [--mongodb-uri MONGODB_URI] [--wait-interval WAIT_INTERVAL] [--max-string-size MAX_STRING_SIZE] [--listen-ip LISTEN_IP] [--listen-port LISTEN_PORT] [--verbose] MongoDB Prometheus Exporter options: -h, --help show this help message and exit --mongodb-uri MONGODB_URI MongoDB URI (default: mongodb://127.0.0.1:27017/) --wait-interval WAIT_INTERVAL Wait interval between data parsing in seconds (default: 10) --max-string-size MAX_STRING_SIZE Maximum string size for Prometheus labels (default: 1000) --listen-ip LISTEN_IP IP address to listen on (default: 0.0.0.0) --listen-port LISTEN_PORT Port to listen (default: 9179) --verbose VERBOSE Enable Verbose Mode (default: False)
Environment Variables
You can use environment variables to configure the exporter. If an environment variable is set, it takes precedence over the corresponding command-line argument.
MONGODB_URI: MongoDB URI (default: mongodb://127.0.0.1:27017/)WAIT_INTERVAL: Wait interval between data parsing in seconds (default: 10)MAX_STRING_SIZE: Maximum string size for Prometheus labels (default: 1000)LISTEN_IP: IP address to listen on (default: 0.0.0.0)LISTEN_PORT: Port to listen (default: 9179)VERBOSE: Enable verbose mode (default: False)To set up authentication, follow these steps:
mongosh use admin db.createUser({ user: "mongodb-profiler-exporter", pwd: passwordPrompt(), roles: [ { role: "clusterMonitor", db: "admin" } ] }) python mongodb-profiler-exporter.py --mongodb-uri "mongodb://mongodb-profiler-exporter:<password>@127.0.0.1:27017/admin?authSource=admin&readPreference=primaryPreferred"
There are two ways to enable profiler in mongodb:
Per Dababase
use db_name db.getProfilingStatus() db.setProfilingLevel(1, { slowms: 100 })
Globally in mongod.conf
yamloperationProfiling: mode: slowOp slowOpThresholdMs: 100
The default size of the system.profile collection is set to 1MB, which can be insufficient for certain scenarios. To address this limitation, you can adjust the size of the collection by recreating it. Note that this process should not be replicated to replicas.
Below are example commands that can be used to increase the size of the system.profile collection to 50MB:
jsdb.setProfilingLevel(0) // Disable profiling temporarily db.system.profile.drop() // Drop the existing system.profile collection db.createCollection( "system.profile", { capped: true, size: 1024 * 1024 * 50 } ) db.setProfilingLevel(1, { slowms: 100 }) // Enable profiling again
Every MongoDB node has a separate system.profile collection, which does not replicate. Because of this, the MongoDB profiler exporter needs to be set up for every replica in every shard to get data from all instances, and the connection string should point to the local node, not the cluster.
4.4, 5.0, 6.0, 7.0, 8.0, 8.2
The exporter provides the following Prometheus metrics from MongoDB's system.profile collection:
Counter Metrics
| Metric Name | Type | Description |
|---|---|---|
slow_queries_count_total | Counter | Total number of slow queries |
slow_queries_duration_total | Counter | Total execution time of slow queries in milliseconds |
slow_queries_keys_examined_total | Counter | Total number of examined keys |
slow_queries_docs_examined_total | Counter | Total number of examined documents |
slow_queries_nreturned_total | Counter | Total number of returned documents |
Gauge Metrics
| Metric Name | Type | Description |
|---|---|---|
slow_queries_info | Gauge | Information about slow query (always set to 1) |
Labels Description
db: Database namens: Namespace (database.collection)query_hash: MongoDB's query hash identifierquery_shape: Normalized query shape with sensitive data removedquery_framework: Query framework used (e.g., "classic", "sbe")op: Operation type (e.g., "query", "update", "insert", "delete")plan_summary: Query execution plan summaryExample Metrics Output
# HELP slow_queries_count_total Total number of slow queries # TYPE slow_queries_count_total counter slow_queries_count_total{db="myapp",ns="myapp.users",query_hash="12345678"} 15 # HELP slow_queries_duration_total Total execution time of slow queries in milliseconds # TYPE slow_queries_duration_total counter slow_queries_duration_total{db="myapp",ns="myapp.users",query_hash="12345678"} 2500 # HELP slow_queries_info Information about slow query # TYPE slow_queries_info gauge slow_queries_info{db="myapp",ns="myapp.users",query_hash="12345678",query_shape="{find: ?, filter: {status: ?}}",query_framework="classic",op="query",plan_summary="IXSCAN { status: 1 }"} 1
You can find example dashboard at id https://grafana.com/grafana/dashboards/20387
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务