Intel PowerStat 输入插件
此插件收集 Intel 平台上的电源统计信息,提供对节能和工作负载迁移的洞察。这些对于监控和分析系统根据平台繁忙程度、CPU 温度、实际 CPU 利用率和电源统计信息采取预防性或纠正性措施非常有用。
引入于: Telegraf v1.17.0 标签: hardware, system 操作系统支持: linux
要求
内核模块
插件主要基于 Linux 内核模块,这些模块通过 sysfs 或 devfs 接口暴露特定的指标。以下是预期的依赖项:
intel-rapl内核模块,通过sysfs(/sys/devices/virtual/powercap/intel-rapl)暴露 Intel Runtime Power Limiting 指标,msr内核模块,通过devfs(/dev/cpu/cpu%d/msr)提供对处理器模型特定寄存器的访问,cpufreq内核模块,通过sysfs(/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq)暴露每个 CPU 的频率,intel-uncore-frequency内核模块,通过sysfs(/sys/devices/system/cpu/intel_uncore_frequency)暴露 Intel uncore 频率指标。
请确保所需的内核模块已加载并正在运行。模块可能需要使用 modprobe 手动启用。根据内核版本,请运行以下命令:
# rapl modules:
## kernel < 4.0
sudo modprobe intel_rapl
## kernel >= 4.0
sudo modprobe rapl
sudo modprobe intel_rapl_common
sudo modprobe intel_rapl_msr
# msr module:
sudo modprobe msr
# cpufreq module:
### integrated in kernel
# intel-uncore-frequency module:
## only for kernel >= 5.6.0
sudo modprobe intel-uncore-frequency内核的 perf 接口
对于与 perf 相关的指标,当 Telegraf 未以 root 用户身份运行时,应将以下能力添加到 Telegraf 可执行文件中:
sudo setcap cap_sys_admin+ep <path_to_telegraf_binary>或者,需要将 /proc/sys/kernel/perf_event_paranoid 设置为小于 1 的值。
根据环境和配置(监控的 CPU 数量和启用的指标数量),可能需要增加允许打开的文件描述符的数量限制。例如,可以使用 ulimit -n 命令来完成。
Root 权限
启用了 Intel PowerStat 插件的 Telegraf 可能需要 root 权限才能读取所有指标(取决于操作系统类型或配置)。
或者,可以将以下能力添加到 Telegraf 可执行文件中:
#without perf-related metrics:
sudo setcap cap_sys_rawio,cap_dac_read_search+ep <path_to_telegraf_binary>
#with perf-related metrics:
sudo setcap cap_sys_rawio,cap_dac_read_search,cap_sys_admin+ep <path_to_telegraf_binary>支持的硬件
特定指标需要存在某些处理器功能,否则 Intel PowerStat 插件将无法读取它们。用户可以通过读取 /proc/cpuinfo 文件来检测支持的处理器功能。插件假设系统中所有 CPU 核心的关键属性都相同。
以下 processor 属性将在本节中更详细地进行检查:
vendor_idcpu familymodelflags
插件需要以下处理器属性:
- 处理器
vendor_id必须是GenuineIntel,cpu family必须是6,因为插件使用的数据是 Intel 特有的。 - 应存在以下处理器标志:
- 需要存在
msr以便插件从处理器模型特定寄存器读取平台数据并收集以下指标:cpu_c0_state_residencycpu_c1_state_residencycpu_c3_state_residencycpu_c6_state_residencycpu_c7_state_residencycpu_busy_frequencycpu_temperaturecpu_base_frequencymax_turbo_frequencyuncore_frequency(对于内核 < 5.18)
- 需要存在
aperfmperf以收集以下指标:cpu_c0_state_residencycpu_c1_state_residencycpu_busy_frequency
- 需要存在
dts以收集:cpu_temperature
- 需要存在
- 支持的 CPU 模型。要查看您的
model支持哪些指标。存在以下指标:cpu_c1_state_residencycpu_c3_state_residencycpu_c6_state_residencycpu_c7_state_residencycpu_temperaturecpu_base_frequencyuncore_frequency
支持的 CPU 模型
| 模型编号 | 处理器名称 | cpu_c1_state_residencycpu_c6_state_residencycpu_temperaturecpu_base_frequency | cpu_c3_state_residency | cpu_c7_state_residency | uncore_frequency |
|---|---|---|---|---|---|
| 0x1E | Intel Nehalem | ✓ | ✓ | ||
| 0x1F | Intel Nehalem-G | ✓ | ✓ | ||
| 0x1A | Intel Nehalem-EP | ✓ | ✓ | ||
| 0x2E | Intel Nehalem-EX | ✓ | ✓ | ||
| 0x25 | Intel Westmere | ✓ | ✓ | ||
| 0x2C | Intel Westmere-EP | ✓ | ✓ | ||
| 0x2F | Intel Westmere-EX | ✓ | ✓ | ||
| 0x2A | Intel Sandybridge | ✓ | ✓ | ✓ | |
| 0x2D | Intel Sandybridge-X | ✓ | ✓ | ✓ | |
| 0x3A | Intel Ivybridge | ✓ | ✓ | ✓ | |
| 0x3E | Intel Ivybridge-X | ✓ | ✓ | ✓ | |
| 0x3C | Intel Haswell | ✓ | ✓ | ✓ | |
| 0x3F | Intel Haswell-X | ✓ | ✓ | ✓ | |
| 0x45 | Intel Haswell-L | ✓ | ✓ | ✓ | |
| 0x46 | Intel Haswell-G | ✓ | ✓ | ✓ | |
| 0x3D | Intel Broadwell | ✓ | ✓ | ✓ | |
| 0x47 | Intel Broadwell-G | ✓ | ✓ | ✓ | ✓ |
| 0x4F | Intel Broadwell-X | ✓ | ✓ | ✓ | |
| 0x56 | Intel Broadwell-D | ✓ | ✓ | ✓ | |
| 0x4E | Intel Skylake-L | ✓ | ✓ | ✓ | |
| 0x5E | Intel Skylake | ✓ | ✓ | ✓ | |
| 0x55 | Intel Skylake-X | ✓ | ✓ | ||
| 0x8E | Intel KabyLake-L | ✓ | ✓ | ✓ | |
| 0x9E | Intel KabyLake | ✓ | ✓ | ✓ | |
| 0xA5 | Intel CometLake | ✓ | ✓ | ✓ | |
| 0xA6 | Intel CometLake-L | ✓ | ✓ | ✓ | |
| 0x66 | Intel CannonLake-L | ✓ | ✓ | ||
| 0x6A | Intel IceLake-X | ✓ | ✓ | ||
| 0x6C | Intel IceLake-D | ✓ | ✓ | ||
| 0x7D | Intel IceLake | ✓ | |||
| 0x7E | Intel IceLake-L | ✓ | ✓ | ||
| 0x9D | Intel IceLake-NNPI | ✓ | ✓ | ||
| 0xA7 | Intel RocketLake | ✓ | ✓ | ||
| 0x8C | Intel TigerLake-L | ✓ | ✓ | ||
| 0x8D | Intel TigerLake | ✓ | ✓ | ||
| 0x8F | Intel Sapphire Rapids X | ✓ | ✓ | ||
| 0xCF | Intel Emerald Rapids X | ✓ | ✓ | ||
| 0xAD | Intel Granite Rapids X | ✓ | |||
| 0xAE | Intel Granite Rapids D | ✓ | |||
| 0x8A | Intel Lakefield | ✓ | ✓ | ||
| 0x97 | Intel AlderLake | ✓ | ✓ | ✓ | |
| 0x9A | Intel AlderLake-L | ✓ | ✓ | ✓ | |
| 0xB7 | Intel RaptorLake | ✓ | ✓ | ✓ | |
| 0xBA | Intel RaptorLake-P | ✓ | ✓ | ✓ | |
| 0xBF | Intel RaptorLake-S | ✓ | ✓ | ✓ | |
| 0xAC | Intel MeteorLake | ✓ | ✓ | ✓ | |
| 0xAA | Intel MeteorLake-L | ✓ | ✓ | ✓ | |
| 0xC6 | Intel ArrowLake | ✓ | ✓ | ||
| 0xBD | Intel LunarLake | ✓ | ✓ | ||
| 0x37 | Intel Atom® Bay Trail | ✓ | |||
| 0x4D | Intel Atom® Avaton | ✓ | |||
| 0x4A | Intel Atom® Merrifield | ✓ | |||
| 0x5A | Intel Atom® Moorefield | ✓ | |||
| 0x4C | Intel Atom® Airmont | ✓ | ✓ | ||
| 0x5C | Intel Atom® Apollo Lake | ✓ | ✓ | ✓ | |
| 0x5F | Intel Atom® Denverton | ✓ | |||
| 0x7A | Intel Atom® Goldmont | ✓ | ✓ | ✓ | |
| 0x86 | Intel Atom® Jacobsville | ✓ | |||
| 0x96 | Intel Atom® Elkhart Lake | ✓ | ✓ | ||
| 0x9C | Intel Atom® Jasper Lake | ✓ | ✓ | ||
| 0xBE | Intel AlderLake-N | ✓ | ✓ | ||
| 0xAF | Intel Sierra Forest | ✓ | |||
| 0xB6 | Intel Grand Ridge | ✓ | |||
| 0x57 | Intel Xeon® PHI Knights Landing | ✓ | |||
| 0x85 | Intel Xeon® PHI Knights Mill | ✓ |
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
配置
# Intel PowerStat plugin enables monitoring of platform metrics (power, TDP)
# and per-CPU metrics like temperature, power and utilization. Please see the
# plugin readme for details on software and hardware compatibility.
# This plugin ONLY supports Linux.
[[inputs.intel_powerstat]]
## The user can choose which package metrics are monitored by the plugin with
## the package_metrics setting:
## - The default, will collect "current_power_consumption",
## "current_dram_power_consumption" and "thermal_design_power".
## - Leaving this setting empty means no package metrics will be collected.
## - Finally, a user can specify individual metrics to capture from the
## supported options list.
## Supported options:
## "current_power_consumption", "current_dram_power_consumption",
## "thermal_design_power", "max_turbo_frequency", "uncore_frequency",
## "cpu_base_frequency"
# package_metrics = ["current_power_consumption", "current_dram_power_consumption", "thermal_design_power"]
## The user can choose which per-CPU metrics are monitored by the plugin in
## cpu_metrics array.
## Empty or missing array means no per-CPU specific metrics will be collected
## by the plugin.
## Supported options:
## "cpu_frequency", "cpu_c0_state_residency", "cpu_c1_state_residency",
## "cpu_c3_state_residency", "cpu_c6_state_residency", "cpu_c7_state_residency",
## "cpu_temperature", "cpu_busy_frequency", "cpu_c0_substate_c01",
## "cpu_c0_substate_c02", "cpu_c0_substate_c0_wait"
# cpu_metrics = []
## CPUs metrics to include from those configured in cpu_metrics array
## Can't be combined with excluded_cpus. Empty means all CPUs are gathered.
## e.g. ["0-3", "4,5,6"] or ["1-3,4"]
# included_cpus = []
## CPUs metrics to exclude from those configured in cpu_metrics array
## Can't be combined with included_cpus. Empty means all CPUs are gathered.
## e.g. ["0-3", "4,5,6"] or ["1-3,4"]
# excluded_cpus = []
## Filesystem location of JSON file that contains PMU event definitions.
## Mandatory only for perf-related metrics (cpu_c0_substate_c01, cpu_c0_substate_c02, cpu_c0_substate_c0_wait).
# event_definitions = ""
## The user can set the timeout duration for MSR reading.
## Enabling this timeout can be useful in situations where, on heavily loaded systems,
## the code waits too long for a kernel response to MSR read requests.
## 0 disables the timeout (default).
# msr_read_timeout = "0ms"included_cpus或excluded_cpus的配置可能会影响收集package_metrics的能力。其中一些(max_turbo_frequency、cpu_base_frequency和uncore_frequency)需要从每个包中读取一个处理器的信息。如果included_cpus或excluded_cpus排除了该包中的所有处理器,则无法读取该包的上述指标。- 特定架构的
event_definitionsJSON 文件可以在 perfmon 找到。一个用于下载适合当前环境的事件定义(event_download.py)的脚本可以在 pmu-tools 中找到。对于此插件支持的与 perf 相关的指标,需要一个包含core事件的事件定义 JSON 文件,例如sapphirerapids_core.json或GenuineIntel-6-8F-core.json。
指标对系统配置的依赖关系
这些依赖关系的详细信息已在上面讨论过。
| 配置选项 | 类型 | 依赖 |
|---|---|---|
current_power_consumption | package_metrics | rapl 模块 |
current_dram_power_consumption | package_metrics | rapl 模块 |
thermal_design_power | package_metrics | rapl 模块 |
max_turbo_frequency | package_metrics | msr 模块 |
uncore_frequency | package_metrics | intel-uncore-frequency 模块* |
cpu_base_frequency | package_metrics | msr 模块 |
cpu_frequency | cpu_metrics | cpufreq 模块 |
cpu_c0_state_residency | cpu_metrics | msr 模块 |
cpu_c1_state_residency | cpu_metrics | msr 模块 |
cpu_c3_state_residency | cpu_metrics | msr 模块 |
cpu_c6_state_residency | cpu_metrics | msr 模块 |
cpu_c7_state_residency | cpu_metrics | msr 模块 |
cpu_temperature | cpu_metrics | msr 模块 |
cpu_busy_frequency | cpu_metrics | msr 模块 |
cpu_c0_substate_c01 | cpu_metrics | perf 接口 |
cpu_c0_substate_c02 | cpu_metrics | perf 接口 |
cpu_c0_substate_c0_wait | cpu_metrics | perf 接口 |
*对于由配置选项 uncore_frequency 启用的所有指标,从内核版本 5.18 开始,只需要 intel-uncore-frequency 模块。对于旧的内核版本,指标 uncore_frequency_mhz_cur 需要启用 msr 模块。
示例:不带每 CPU 遥测的配置
此配置允许获取默认的处理器包特定指标,不收集每 CPU 指标。
[[inputs.intel_powerstat]]
cpu_metrics = []示例:不带每 CPU 遥测的配置 - 等效情况
此配置允许获取默认的处理器包特定指标,不收集每 CPU 指标。
[[inputs.intel_powerstat]]示例:CPU 温度和 CPU 频率配置
此配置允许获取默认的处理器包特定指标,以及每 CPU 指标的子集(CPU 温度和 CPU 频率),这些指标仅为 cpu_id = 0 收集。
[[inputs.intel_powerstat]]
cpu_metrics = ["cpu_frequency", "cpu_temperature"]
included_cpus = ["0"]示例:不带默认包指标的 CPU 温度和 CPU 频率配置
此配置允许仅获取每 CPU 指标的子集(CPU 温度和 CPU 频率),这些指标将为所有 cpus 收集,但排除 cpu_id = ["1-3"]。
[[inputs.intel_powerstat]]
package_metrics = []
cpu_metrics = ["cpu_frequency", "cpu_temperature"]
excluded_cpus = ["1-3"]示例:包含所有可用指标的配置
此配置允许获取所有处理器包特定指标和所有每 CPU 指标。
[[inputs.intel_powerstat]]
package_metrics = ["current_power_consumption", "current_dram_power_consumption", "thermal_design_power", "max_turbo_frequency", "uncore_frequency", "cpu_base_frequency"]
cpu_metrics = ["cpu_frequency", "cpu_c0_state_residency", "cpu_c1_state_residency", "cpu_c3_state_residency", "cpu_c6_state_residency", "cpu_c7_state_residency", "cpu_temperature", "cpu_busy_frequency", "cpu_c0_substate_c01", "cpu_c0_substate_c02", "cpu_c0_substate_c0_wait"]
event_definitions = "/home/telegraf/.cache/pmu-events/GenuineIntel-6-8F-core.json"Metrics
Intel PowerStat 插件收集的所有指标都以固定的间隔收集。报告处理器 C 状态驻留或功耗的指标是在经过的间隔内计算的。
Intel PowerStat 插件支持以下测量:
powerstat_core插件为
powerstat_core测量返回的标签如下:标签 描述 package_id平台包/插槽的 ID。 core_id物理处理器核心的 ID。 cpu_id逻辑处理器核心的 ID。 Measurement
powerstat_core指标是按 CPU(cpu_id是键)收集的,而core_id和package_id标签是额外的拓扑信息。powerstat_core测量可用的指标:指标名称 (字段) 描述 单位 cpu_frequency_mhzCPU 核心当前的运行频率。 MHz cpu_busy_frequency_mhzCPU 核心繁忙频率,计算为已调整到 CPU 核心繁忙周期的频率。 MHz cpu_temperature_celsiusCPU 核心的当前温度。 摄氏度 cpu_c0_state_residency_percentCPU 核心在 C0 核心驻留状态下花费的时间百分比。 % cpu_c1_state_residency_percentCPU 核心在 C1 核心驻留状态下花费的时间百分比。 % cpu_c3_state_residency_percentCPU 核心在 C3 核心驻留状态下花费的时间百分比。 % cpu_c6_state_residency_percentCPU 核心在 C6 核心驻留状态下花费的时间百分比。 % cpu_c7_state_residency_percentCPU 核心在 C7 核心驻留状态下花费的时间百分比。 % cpu_c0_substate_c01_percentCPU 核心在 C0.1 子状态下花费的时间百分比(相对于 C0 状态的总时间)。 % cpu_c0_substate_c02_percentCPU 核心在 C0.2 子状态下花费的时间百分比(相对于 C0 状态的总时间)。 % cpu_c0_substate_c0_wait_percentCPU 核心在 C0_Wait 子状态下花费的时间百分比(相对于 C0 状态的总时间)。 %
powerstat_package插件为
powerstat_package测量返回的标签如下:标签 描述 package_id平台包/插槽的 ID。 active_coresmax_turbo_frequency_mhz指标的特定标签。可达到 Turbo 频率的最大激活核心数。hybridmax_turbo_frequency_mhz指标的特定标签。仅适用于混合处理器。对于混合架构的主核心,将设置为primary,对于辅助核心,将设置为secondary。die所有 uncore_frequency指标的特定标签。Die 的 ID。type所有 uncore_frequency指标的特定标签。Uncore 频率的类型(current或initial)。Measurement
powerstat_package指标是按处理器包收集的(package_id标签指示了指标所属的包)。powerstat_package测量可用的指标:指标名称 (字段) 描述 单位 thermal_design_power_watts处理器包可用的最大热设计功耗 (TDP)。 瓦特 current_power_consumption_watts处理器包的当前功耗。 瓦特 current_dram_power_consumption_watts处理器包 DRAM 子系统的当前功耗。 瓦特 max_turbo_frequency_mhz对于激活的核心数可达到的最大 Turbo 频率。 MHz uncore_frequency_limit_mhz_min处理器包中 Die 的最小 Uncore 频率限制。 MHz uncore_frequency_limit_mhz_max处理器包中 Die 的最大 Uncore 频率限制。 MHz uncore_frequency_mhz_cur处理器包中 Die 的当前 Uncore 频率。仅在标签为 current时可用。此值可从内核 >= 5.18 的intel-uncore-frequency模块获取。对于旧的内核版本,需要通过 MSR 访问。如果未加载msr,则只能收集uncore_frequency_limit_mhz_min和uncore_frequency_limit_mhz_max指标。MHz cpu_base_frequency_mhz处理器包的 CPU 基础频率(最大非 Turbo 频率)。 MHz
已知问题
从 Linux 内核版本 v5.4.77 开始,由于 此内核更改,出于安全原因,/sys/devices/virtual/powercap/intel-rapl//*/energy_uj 等资源只能由 root 用户访问。因此,此插件需要 root 权限才能正确收集 rapl 指标。
如果这些严格的安全限制不适用,可以通过手动更改 /sys/devices/virtual/powercap/intel-rapl/ 目录中文件的读取权限来解决,例如,使用带有自定义参数的 chmod 命令。例如,可以通过以下方式授予所有用户对 intel-rapl 目录中所有文件的读取和执行权限:
sudo chmod -R a+rx /sys/devices/virtual/powercap/intel-rapl/示例输出
powerstat_package,host=ubuntu,package_id=0 thermal_design_power_watts=160 1606494744000000000
powerstat_package,host=ubuntu,package_id=0 current_power_consumption_watts=35 1606494744000000000
powerstat_package,host=ubuntu,package_id=0 cpu_base_frequency_mhz=2400i 1669118424000000000
powerstat_package,host=ubuntu,package_id=0 current_dram_power_consumption_watts=13.94 1606494744000000000
powerstat_package,host=ubuntu,package_id=0,active_cores=0 max_turbo_frequency_mhz=3000i 1606494744000000000
powerstat_package,host=ubuntu,package_id=0,active_cores=1 max_turbo_frequency_mhz=2800i 1606494744000000000
powerstat_package,die=0,host=ubuntu,package_id=0,type=initial uncore_frequency_limit_mhz_min=800,uncore_frequency_limit_mhz_max=2400 1606494744000000000
powerstat_package,die=0,host=ubuntu,package_id=0,type=current uncore_frequency_mhz_cur=800i,uncore_frequency_limit_mhz_min=800,uncore_frequency_limit_mhz_max=2400 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_frequency_mhz=1200.29 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_temperature_celsius=34i 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_c0_state_residency_percent=0.8 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_c1_state_residency_percent=6.68 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_c3_state_residency_percent=0 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_c6_state_residency_percent=92.52 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_c7_state_residency_percent=0 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_busy_frequency_mhz=1213.24 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_c0_substate_c01_percent=0 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_c0_substate_c02_percent=5.68 1606494744000000000
powerstat_core,core_id=0,cpu_id=0,host=ubuntu,package_id=0 cpu_c0_substate_c0_wait_percent=43.74 1606494744000000000此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。