文档文档

Intel PowerStat 输入插件

此插件收集 Intel 平台上的电源统计信息,提供对节能和工作负载迁移的洞察。这些对于监控和分析系统根据平台繁忙程度、CPU 温度、实际 CPU 利用率和电源统计信息采取预防性或纠正性措施非常有用。

引入于: Telegraf v1.17.0 标签: hardware, system 操作系统支持: linux

要求

内核模块

插件主要基于 Linux 内核模块,这些模块通过 sysfsdevfs 接口暴露特定的指标。以下是预期的依赖项:

  • 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_id
  • cpu family
  • model
  • flags

插件需要以下处理器属性:

  • 处理器 vendor_id 必须是 GenuineIntelcpu family 必须是 6,因为插件使用的数据是 Intel 特有的。
  • 应存在以下处理器标志:
    • 需要存在 msr 以便插件从处理器模型特定寄存器读取平台数据并收集以下指标:
      • cpu_c0_state_residency
      • cpu_c1_state_residency
      • cpu_c3_state_residency
      • cpu_c6_state_residency
      • cpu_c7_state_residency
      • cpu_busy_frequency
      • cpu_temperature
      • cpu_base_frequency
      • max_turbo_frequency
      • uncore_frequency(对于内核 < 5.18)
    • 需要存在 aperfmperf 以收集以下指标:
      • cpu_c0_state_residency
      • cpu_c1_state_residency
      • cpu_busy_frequency
    • 需要存在 dts 以收集:
      • cpu_temperature
  • 支持的 CPU 模型。要查看您的 model 支持哪些指标。存在以下指标:
    • cpu_c1_state_residency
    • cpu_c3_state_residency
    • cpu_c6_state_residency
    • cpu_c7_state_residency
    • cpu_temperature
    • cpu_base_frequency
    • uncore_frequency

支持的 CPU 模型

模型编号处理器名称cpu_c1_state_residency
cpu_c6_state_residency
cpu_temperature
cpu_base_frequency
cpu_c3_state_residencycpu_c7_state_residencyuncore_frequency
0x1EIntel Nehalem
0x1FIntel Nehalem-G
0x1AIntel Nehalem-EP
0x2EIntel Nehalem-EX
0x25Intel Westmere
0x2CIntel Westmere-EP
0x2FIntel Westmere-EX
0x2AIntel Sandybridge
0x2DIntel Sandybridge-X
0x3AIntel Ivybridge
0x3EIntel Ivybridge-X
0x3CIntel Haswell
0x3FIntel Haswell-X
0x45Intel Haswell-L
0x46Intel Haswell-G
0x3DIntel Broadwell
0x47Intel Broadwell-G
0x4FIntel Broadwell-X
0x56Intel Broadwell-D
0x4EIntel Skylake-L
0x5EIntel Skylake
0x55Intel Skylake-X
0x8EIntel KabyLake-L
0x9EIntel KabyLake
0xA5Intel CometLake
0xA6Intel CometLake-L
0x66Intel CannonLake-L
0x6AIntel IceLake-X
0x6CIntel IceLake-D
0x7DIntel IceLake
0x7EIntel IceLake-L
0x9DIntel IceLake-NNPI
0xA7Intel RocketLake
0x8CIntel TigerLake-L
0x8DIntel TigerLake
0x8FIntel Sapphire Rapids X
0xCFIntel Emerald Rapids X
0xADIntel Granite Rapids X
0xAEIntel Granite Rapids D
0x8AIntel Lakefield
0x97Intel AlderLake
0x9AIntel AlderLake-L
0xB7Intel RaptorLake
0xBAIntel RaptorLake-P
0xBFIntel RaptorLake-S
0xACIntel MeteorLake
0xAAIntel MeteorLake-L
0xC6Intel ArrowLake
0xBDIntel LunarLake
0x37Intel Atom® Bay Trail
0x4DIntel Atom® Avaton
0x4AIntel Atom® Merrifield
0x5AIntel Atom® Moorefield
0x4CIntel Atom® Airmont
0x5CIntel Atom® Apollo Lake
0x5FIntel Atom® Denverton
0x7AIntel Atom® Goldmont
0x86Intel Atom® Jacobsville
0x96Intel Atom® Elkhart Lake
0x9CIntel Atom® Jasper Lake
0xBEIntel AlderLake-N
0xAFIntel Sierra Forest
0xB6Intel Grand Ridge
0x57Intel Xeon® PHI Knights Landing
0x85Intel 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"
  1. included_cpusexcluded_cpus 的配置可能会影响收集 package_metrics 的能力。其中一些(max_turbo_frequencycpu_base_frequencyuncore_frequency)需要从每个包中读取一个处理器的信息。如果 included_cpusexcluded_cpus 排除了该包中的所有处理器,则无法读取该包的上述指标。
  2. 特定架构的 event_definitions JSON 文件可以在 perfmon 找到。一个用于下载适合当前环境的事件定义(event_download.py)的脚本可以在 pmu-tools 中找到。对于此插件支持的与 perf 相关的指标,需要一个包含 core 事件的事件定义 JSON 文件,例如 sapphirerapids_core.jsonGenuineIntel-6-8F-core.json

指标对系统配置的依赖关系

这些依赖关系的详细信息已在上面讨论过。

配置选项类型依赖
current_power_consumptionpackage_metricsrapl 模块
current_dram_power_consumptionpackage_metricsrapl 模块
thermal_design_powerpackage_metricsrapl 模块
max_turbo_frequencypackage_metricsmsr 模块
uncore_frequencypackage_metricsintel-uncore-frequency 模块*
cpu_base_frequencypackage_metricsmsr 模块
cpu_frequencycpu_metricscpufreq 模块
cpu_c0_state_residencycpu_metricsmsr 模块
cpu_c1_state_residencycpu_metricsmsr 模块
cpu_c3_state_residencycpu_metricsmsr 模块
cpu_c6_state_residencycpu_metricsmsr 模块
cpu_c7_state_residencycpu_metricsmsr 模块
cpu_temperaturecpu_metricsmsr 模块
cpu_busy_frequencycpu_metricsmsr 模块
cpu_c0_substate_c01cpu_metricsperf 接口
cpu_c0_substate_c02cpu_metricsperf 接口
cpu_c0_substate_c0_waitcpu_metricsperf 接口

*对于由配置选项 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_idpackage_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 频率的类型(currentinitial)。

      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_minuncore_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

此页面是否有帮助?

感谢您的反馈!


InfluxDB 3.8 新特性

InfluxDB 3.8 和 InfluxDB 3 Explorer 1.6 的主要增强功能。

查看博客文章

InfluxDB 3.8 现已适用于 Core 和 Enterprise 版本,同时发布了 InfluxDB 3 Explorer UI 的 1.6 版本。本次发布着重于操作成熟度,以及如何更轻松地部署、管理和可靠地运行 InfluxDB。

更多信息,请查看

InfluxDB Docker 的 latest 标签将指向 InfluxDB 3 Core

在 **2026 年 2 月 3 日**,InfluxDB Docker 镜像的 latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。

如果使用 Docker 来安装和运行 InfluxDB,latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。例如,如果使用 Docker 运行 InfluxDB v2,请将 latest 版本标签替换为 Docker pull 命令中的特定版本标签 — 例如

docker pull influxdb:2