与 Prometheus 集成
Prometheus 按给定时间间隔从配置的目标收集指标,评估规则表达式,显示结果,并可在观察到特定条件时触发警报。
我们的集成允许您配置 Ops Manager,将有关部署的指标数据发送到 Prometheus 实例。
先决条件
Prometheus 集成可在使用 MongoDB 助手 的12 自动化托管0 集群中使用。 。15 。7646 或更高版本。 MongoDB 助手12 。0 。15 。7646 与 Ops Manager6 一起发布。0 。7 。
有一个正常工作的 Prometheus 实例。要设置工作实例,请参阅其 安装指南。
(可选)使用 Grafana 以可视化您的 Prometheus 指标。
步骤
将 Ops Manager 与 Prometheus 集成 :
选择首选的服务发现方法。
探索方法 | 说明 | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
此方法需要 Prometheus v2 。28 及更高版本。它会生成 scrape_config 配置文件 的一部分 通过 HTTP 端点发现目标。 | |||||||||||||||||||||||||||||||||||||||
此方法允许 Prometheus 读取YAML或JSON文档,以配置要抓取的目标。 您负责通过向Discovery API发出请求并将其结果存储在 如需发出请求,请替换以下选项卡中的占位符文本,或用其他语言创建自己的脚本。
如果您需要安装
要了解有关“发现 API”的更多信息,请参阅返回 Prometheus 的最新目标。 |
在 Prometheus 上查看集群指标。
将生成的代码片段复制到 scrape_configs 配置文件 的 部分 并替换占位符文本。
有关这两种方法的配置文件示例,请参阅示例配置。
重新启动 Prometheus 实例。
在 Prometheus 实例中,单击顶部导航栏中的
Status
,然后单击Targets
以查看部署的指标。
示例配置
以下显示了 配置文件 的示例 当您使用HTTP Service 发现 或 文件服务发现 方法时。
这两种方法的配置文件都包含以下字段:
字段 | 说明 |
---|---|
scrape_interval | 时间,表示抓取目标的频率。该设置支持最短 10 秒。 |
job_name | 分配给抓取指标的人类可读标签。 |
metrics_path | 指示从何处获取目标指标的 HTTP 资源路径。 |
scheme | 为请求配置的 Prometheus 协议模式,可以是 http 或https 。 如果配置https ,则必须指定tlsPemPath 。 |
basic_auth | 在每次抓取请求中使用的授权标头。 |
HTTP 服务发现
HTTP 服务发现方法还包含具有以下子字段的 http_sd_configs
字段:
字段 | 说明 |
---|---|
url | Prometheus 从中获取目标的 URL。 |
refresh_interval | 指示何时重新查询端点的时间。 |
basic_auth | 用于向 API 服务器进行身份验证的凭据。 |
global: scrape_interval: 15s scrape_configs: - job_name: "CM-Testing-mongo-metrics" scrape_interval: 10s metrics_path: /metrics scheme : https basic_auth: username: prom_user_61e6e34e93eac1632d39f457 password: V7hTyLfkjwiWQbv http_sd_configs: - url: https://cloud.mongodb.com/prometheus/v1.0/groups/61e6e34e93eac1632d39f457/discovery refresh_interval: 60s basic_auth: username: prom_user_61e6e34e93eac1632d39f457 password: V7hTyLfkjwiWQbv
文件服务发现
“文件服务发现”方法还包含带有以下子字段的 file_sd_configs
字段:
字段 | 说明 |
---|---|
files | 包含要从中提取指标抓取目标的文件的列表。 |
global: scrape_interval: 15s scrape_configs: - job_name: "CM-Testing-mongo-metrics" scrape_interval: 10s metrics_path: /metrics scheme : https basic_auth: username: prom_user_61e6e34e93eac1632d39f457 password: V7hTyLfkjwiWQbv file_sd_configs: - files: - /usr/local/etc/targets.json
适用于 Prometheus 的性能指标
当您使用 Prometheus 与MongoDB Atlas cluster 集成:
MongoDB 指标标签
每个 MongoDB 指标都包含以下标签:
标签 | 说明 |
---|---|
group_id | 标识项目的唯一十六进制数字字符串。 |
org_id | 标识组织的唯一十六进制数字字符串。 |
cl_role | 人类可读标签,用于定义集群角色。 |
cl_name | 用于标识集群的人类可读标签。 |
rs_nm | 用于标识副本集的人类可读标签。 |
rs_state | 表示副本集状态的数字。 |
process_port | 进程运行的端口。 |
MongoDB 信息指标
mongodb_info
是一个始终具有 1
值的仪表盘。该指标包含所有 MongoDB 指标标签以及以下标签:
标签 | 说明 |
---|---|
mongodb_version | 表示主要版本、次要版本和补丁的字符串。 |
replica_state_name | 字符串,用于表示副本集成员状态。 |
process_type | 指示正在运行的进程的字符串。其值可以是 mongod 、mongos 或 config 。 |
硬件指标
注意
您还可以在 Prometheus 表达式浏览器中查看每个硬件指标的说明。
名称 | 操作系统 | 类型 | 说明 |
---|---|---|---|
hardware_system_cpu_nice | Unix、Darwin | 计数器 | 在低优先级用户模式下花费的时间。 |
hardware_system_cpu_io_wait | Unix | 计数器 | 等待 I/O 完成的时间。 |
hardware_system_cpu_irq | Unix | 计数器 | 服务中断花费的时间。 |
hardware_system_cpu_soft_irq | Unix | 计数器 | 服务软中断所花费的时间。 |
hardware_system_cpu_steal | Unix | 计数器 | 在虚拟环境中运行时在其他操作系统中花费的时间。 |
hardware_system_cpu_guest | Unix | 计数器 | 在 Linux 内核的控制下为客户机操作系统运行虚拟 CPU 所花费的时间。 |
hardware_system_cpu_guest_nice | Unix | 计数器 | 调整优先级后运行客户机所花费的时间。 |
hardware_system_cpu_kernel_milliseconds | 所有 | 计数器 | 在系统模式下花费的时间。 |
hardware_system_cpu_user_milliseconds | 所有 | 计数器 | 在用户模式下花费的时间。 |
hardware_disk_metrics_weighted_time_io | Unix | 计数器 | 用于 I/O 的加权时间。 |
hardware_disk_metrics_physical_write_count | Unix | 计数器 | 已处理的物理写入 I/O 数量。 |
hardware_disk_metrics_physical_read_count | Unix | 计数器 | 已处理的物理读 I/O 数量。 |
hardware_disk_metrics_total_time | Unix | 计数器 | 此区块设备处于活动状态的总时间。 |
hardware_disk_metrics_idle_time | Windows | 计数器 | 在空闲任务中花费的时间。 |
hardware_disk_metrics_disk_space_free_bytes | 所有 | 仪表盘 | 已挂载文件系统中的可用磁盘空间。 |
hardware_disk_metrics_disk_space_used_bytes | 所有 | 仪表盘 | 挂载的文件系统中使用的磁盘空间。 |
hardware_disk_metrics_read_count | 所有 | 计数器 | 已处理的读取 I/O 数量。 |
hardware_disk_metrics_read_time_milliseconds | 所有 | 计数器 | 读取请求的总等待时间。 |
hardware_disk_metrics_write_count | 所有 | 计数器 | 已处理的写 I/O 数量。 |
hardware_disk_metrics_write_time_milliseconds | 所有 | 计数器 | 写入请求的总等待时间。 |
hardware_process_cpu_children_user | Unix | 计数器 | 在用户模式下为此进程安排的等待子级的时间量。 |
hardware_process_cpu_children_kernel | Unix | 计数器 | 在内核模式下为此进程安排的等待子级的时间量。 |
hardware_process_cpu_kernel_milliseconds | 所有 | 计数器 | 在内核模式下为此进程安排的时间量。 |
hardware_process_cpu_user_milliseconds | 所有 | 计数器 | 在使用模式下为此进程安排的时间量。 |
hardware_system_vm_page_swap_in | Unix | 计数器 | 系统已交换到磁盘的页面数量。 |
hardware_system_vm_page_swap_out | Unix | 计数器 | 系统已交换到磁盘的页面数量。 |
hardware_system_memory_mem_total | Unix | 仪表盘 | 总可用 RAM(物理 RAM 减去几个保留位和内核二进制代码)。 |
hardware_system_memory_mem_free | Unix | 仪表盘 | LowFree + HighFree 之和。 |
hardware_system_memory_mem_available | Unix | 仪表盘 | 在不进行交换的情况下,估计有多少内存可用于启动新应用程序。 |
hardware_system_memory_buffers | Unix | 仪表盘 | 原始磁盘区块的临时存储,不应变得非常大。 |
hardware_system_memory_cached | Unix | 仪表盘 | 从磁盘读取文件的内存缓存。其中不包括 SwapCached 。 |
hardware_system_memory_swap_total | Unix | 仪表盘 | 可用的交换空间总量。 |
hardware_system_memory_swap_free | Unix | 仪表盘 | 未使用交换空间总量。 |
hardware_system_memory_shared_mem | Unix | 仪表盘 | 内容驻留在虚拟内存中的文件系统消耗的内存量。 |
hardware_system_memory_swap_free_kilobytes | 所有 | 仪表盘 | 未使用交换空间总量。 |
hardware_system_memory_swap_total_kilobytes | 所有 | 仪表盘 | 可用的交换空间总量。 |
hardware_platform_num_logical_cpus | 所有 | 仪表盘 | 当前进程可用的逻辑 CPU 数。 |
hardware_system_network_eth0_bytes_in_bytes | 所有 | 计数器 | 接口接收的数据字节数。 |
hardware_system_network_eth0_bytes_out_bytes | 所有 | 计数器 | 接口传输的数据字节数。 |
hardware_system_network_lo_bytes_in_bytes | 所有 | 计数器 | 接口接收的数据字节数。 |
hardware_system_network_lo_bytes_out_bytes | 所有 | 计数器 | 接口传输的数据字节数。 |
硬件指标标签
每个硬件指标都包含以下标签:
标签 | 说明 |
---|---|
group_id | 标识项目的唯一十六进制数字字符串。 |
org_id | 标识组织的唯一十六进制数字字符串。 |
process_port | 进程运行的端口。 |
disk_name | 标识磁盘的人类可读标签。 |