news 2026/9/14 6:20:13

Telegraf Intel PMT 输入插件完全指南:采集 Intel 平台监控遥测数据

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Telegraf Intel PMT 输入插件完全指南:采集 Intel 平台监控遥测数据

Telegraf Intel PMT 输入插件完全指南:采集 Intel 平台监控遥测数据

【免费下载链接】telegrafAgent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.项目地址: https://gitcode.com/GitHub_Trending/te/telegraf

导读

本文围绕 Telegraf 的intel_pmt输入插件展开,系统讲解如何通过 Linux 内核驱动枚举并读取 Intel 平台监控技术(Platform Monitoring Technology,PMT)硬件遥测空间,将晶振频率、DRAM 能耗、内存带宽、C-State 驻留、温度、频率直方图、PVP 节流计数器等底层样本转化为 Telegraf 指标。读完本文,你将掌握该插件的运行前置条件、配置参数、按数据类型(datatype)与样本名(sample)过滤指标的方法、全部可用指标的含义,以及从 sysfs 读取到变换公式求值的源码级工作原理。该插件仅支持 Linux(amd64),自 Telegraf v1.28.0 起可用。

插件概述:什么是 Intel PMT

Intel 平台监控技术(Intel PMT)是一套用于枚举和访问受支持设备硬件监控能力的架构。intel_pmt插件通过 Linux 内核驱动采集这类遥测指标,属于 Telegraf 的输入插件(input plugin)类型,标签分类为hardware, system,平台限制为linux

在 Linux 主线内核中,PMT 的支持由平台驱动(drivers/platform/x86/intel/pmt)提供,它会把 Intel PMT 遥测空间以 sysfs 条目的形式暴露在/sys/class/intel_pmt/下。每个被发现的遥测聚合器(telemetry aggregator)都以一个telem前缀的目录形式呈现,目录内包含一个guid文件,用于标识唯一的 PMT 空间。插件会:

  1. 发现:扫描/sys/class/intel_pmt下的遥测源;
  2. 解析:依据 XML 规范文件解析遥测数据布局;
  3. 变换:读取底层样本/计数器,并根据变换公式(transformation formulas)计算高层样本/计数器;
  4. 上报:将计算结果作为指标写入 Telegraf。

[!IMPORTANT] PMT 空间位于/sys/class/intel_pmt,其中的telem文件需要root 权限才能读取。如果 Telegraf 不以 root 身份运行,需要为 Telegraf 可执行文件添加以下 capability:

sudo setcap cap_dac_read_search+ep /usr/bin/telegraf

运行前置条件(Requirements)

在启用该插件前,请确认以下条件:

  • 拥有受支持的 Intel 设备;
  • Linux 内核版本 >= 5.11;
  • 内核 5.11–5.14 需要加载intel_pmt_telemetry模块;
  • 内核 5.14+ 需要加载intel_pmt模块。

支持暴露 PMT 的设备包括但不限于:

  • 第 4 代 Intel Xeon 可扩展处理器(Sapphire Rapids / SPR)
  • 第 6 代 Intel Xeon 可扩展处理器(Granite Rapids / GNR)

每个遥测聚合器目录(telem前缀)内的guid文件标识了唯一的 PMT 空间,该文件对应一组 XML 规范文件,可在 Intel-PMT 仓库中找到。XML 规范必须通过spec配置项指定为指向pmt.xml文件的绝对路径。

插件工作原理:从 sysfs 到指标

结合源码 plugins/inputs/intel_pmt/intel_pmt.go,插件的完整数据流如下:

1. 初始化(Init)

Init()依次执行三步(对应 intel_pmt.go):

  • checkPmtSpec():校验spec非空、文件可读且为绝对路径。由于pmt.xml中通过basedir引用了 Aggregator 与 Aggregator Interface XML 的相对位置,插件会把spec所在目录作为基准目录(pmtBasePath),见 intel_pmt.go;
  • explorePmtInSysfs():遍历默认路径/sys/class/intel_pmt(常量defaultPmtBasePath),只处理以telem前缀命名的目录;读取每个目录下的guidtelem文件,并通过解析device符号链接定位 PCI BDF(Bus:Device.Function)与numa_node,汇总为每个 GUID 对应的遥测文件信息,见 intel_pmt.go。若找不到任何遥测源,会返回错误“no telemetry sources found”,此时应检查平台是否支持 PMT 或权限是否足够;
  • parseXMLs():解析 XML 规范,详见下文。

2. XML 规范解析(parseXMLs)

pmt.xml是总入口,其结构为<pmt><mappings><mapping guid="..."><xmlset><basedir>...。插件先解析总映射文件,然后针对 sysfs 中实际发现的每个 GUID,依据映射读取两类 XML(见 xml_parser.go):

  • Aggregator XML:描述低层遥测样本(SampleGroup/sample),每个样本由lsb/msb位域、datatypeIDREFsampleID定义;
  • Aggregator Interface XML:描述高层聚合样本(T_AggregatorSample)与变换公式(TransFormation),变换输入通过sampleIDREF引用低层样本,transformREF引用公式。

解析后,插件为每个样本调用calculateMasks()依据msb/lsb预计算位掩码(computeMask,见 xml_parser.go),并把变换公式按TransformID建立索引。

3. 指标采集(Gather)

Gather()按 GUID 并发处理(每个 GUID 一个 goroutine,使用sync.WaitGroup同步),对每个遥测文件:

  • getSampleValues():每个 Sample Group 占 8 字节,以8 * group.SampleID作为起始偏移;getTelemSample()读取该 8 字节(小端序 uint64),应用掩码并右移Lsb位得到原始样本值,见 intel_pmt.go;
  • aggregateSamples():对每个聚合样本,把其变换输入的sampleIDREF对应的低层样本值代入公式,调用eval()求值(基于github.com/PaesslerAG/gval),然后生成字段与标签写入 Accumulator,见 intel_pmt.go。

求值前的公式预处理transformEquation()会移除$前缀符,并解码 XML 实体(如&lt;<),见 intel_pmt.go。由于gval不支持十六进制字面量,eval()还会用正则把公式中的0x...统一转换为十进制后再求值,见 intel_pmt.go。

配置详解

插件的完整示例配置位于 plugins/inputs/intel_pmt/sample.conf,基本配置如下:

# Intel Platform Monitoring Technology plugin exposes Intel PMT metrics available through the Intel PMT kernel space. # This plugin ONLY supports Linux. [[inputs.intel_pmt]] ## Filepath to PMT XML within local copies of XML files from PMT repository. ## The filepath should be absolute. spec = "/home/telegraf/Intel-PMT/xml/pmt.xml" ## Enable metrics by their datatype. ## See the Enabling Metrics section in README for more details. ## If empty, all metrics are enabled. ## When used, the alternative option samples_enabled should NOT be used. # datatypes_enabled = [] ## Enable metrics by their name. ## See the Enabling Metrics section in README for more details. ## If empty, all metrics are enabled. ## When used, the alternative option datatypes_enabled should NOT be used. # samples_enabled = []
配置项类型必填说明
specstringPMT XML 文件的绝对路径(本地 Intel-PMT 仓库 XML 副本中的pmt.xml),例如/home/telegraf/Intel-PMT/xml/pmt.xml。插件校验其非空、可读且为绝对路径(源码见 intel_pmt.go)
datatypes_enabled[]string按数据类型(datatype,即指标分组)启用指标;为空则启用全部指标。使用该选项时不应同时使用samples_enabled
samples_enabled[]string按样本名(metric name)启用指标;为空则启用全部指标。使用该选项时不应同时使用datatypes_enabled

此外,插件同样支持 Telegraf 输入插件的通用全局配置,例如指标修改、标签与字段处理、别名以及插件执行顺序等,详见 docs/CONFIGURATION.md。

启用指标(Enabling metrics)

默认情况下,插件采集所有可用指标。若需限制采集范围,提供了两种互斥的选择方式:

  • 按数据类型(datatype)启用:datatype 是指标的组/类,启用后会过滤出该类型下的全部相关指标;
  • 按名称(sample name)启用:按指标名精确匹配;对形如Cx_CHAx_前缀的按资源维度命名的指标,支持正则式匹配(即只填去前缀后的名称也能匹配到所有核心/CHA 实例)。

注意:同一时刻只能选择一种启用方式,二者不可混用。

从源码层面看(filtering.go):

  • datatype 过滤分别作用于 Aggregator XML(filterAggregatorByDatatype)与 Aggregator Interface XML(filterAggInterfaceByDatatype),按DatatypeIDRef匹配;当一个 Sample Group 内仅保留部分样本时,会重建 group 但保留原SampleID(偏移不变);
  • sample 过滤(filterAggregatorBySampleName/filterAggInterfaceBySampleName)通过正则(?P<class>(C|CHA))\d+_(?P<var>[A-Z0-9_]+)$拆分名称,支持“精确名”与“去前缀后的通用名”两种匹配,见 filtering.go;
  • 若配置的 datatype 或 sample 名称在 XML 中未找到,插件会输出 Warn 日志提示(见 xml_parser.go),便于排查拼写错误。

可用 datatype 与相关指标一览

下表完整列出各 datatype 及其对应的指标(摘自 插件 README):

DatatypeMetric nameDescription
txtal_strapXTAL_FREQClock rate of the crystal oscillator on this silicon
tdram_energyDRAM_ENERGY_LOWDRAM energy consumed by all DIMMS in all Channels (uJ)
DRAM_ENERGY_HIGHDRAM energy consumed by all DIMMS in all Channels (uJ)
tbandwidth_32bC2U_BWCore to Uncore Bandwidth (per core and per uncore)
U2C_BWUncore to Core Bandwidth (per core and per uncore)
PC2_LOWTime spent in the Package C-State 2 (PC2)
PC2_HIGHTime spent in the Package C-State 2 (PC2)
PC6_LOWTime spent in the Package C-State 6 (PC6)
PC6_HIGHTime spent in the Package C-State 6 (PC6)
MEM_RD_BWMemory Read Bandwidth (per channel)
MEM_WR_BWMemory Write Bandwidth (per channel)
DDRT_READ_BWDDRT Read Bandwidth (per channel)
DDRT_WR_BWDDRT Write Bandwidth (per channel)
THRT_COUNTNumber of clock ticks when throttling occurred on IMC channel (per channel)
PMSUMEnergy accumulated by IMC channel (per channel)
CMD_CNT_CH0Command count for IMC channel subchannel 0 (per channel)
CMD_CNT_CH1Command count for IMC channel subchannel 1 (per channel)
tU32.0PEM_ANYDuration for which a core frequency excursion occurred due to a listed or unlisted reason
PEM_THERMALDuration for which a core frequency excursion occurred due to EMTTM
PEM_EXT_PROCHOTDuration for which a core frequency excursion occurred due to an external PROCHOT assertion
PEM_PBMDuration for which a core frequency excursion occurred due to PBM
PEM_PL1Duration for which a core frequency excursion occurred due to PL1
PEM_RESERVEDPEM Reserved Counter
PEM_PL2Duration for which a core frequency excursion occurred due to PL2
PEM_PMAXDuration for which a core frequency excursion occurred due to PMAX
tbandwidth_28bC0ResidencyCore C0 Residency (per core)
C1ResidencyCore C1 Residency (per core)
tratioFETCurrent Frequency Excursion Threshold. Ratio of the core frequency.
tbandwidth_24bUFS_MAX_RING_TRAFFICIO Bandwidth for DMI or PCIE port (per port)
ttemperatureTEMPCurrent temperature of a core (per core)
tU8.0VERSIONFor SPR, it's 0. New feature versions will uprev this.
tebb_energyFIVR_HBM_ENERGYFIVR HBM Energy in uJ (per HBM)
tBOOLOOB_PEM_ENABLE0x0 (Default)=Inband interface for PEM is enabled. 0x1=OOB interface for PEM is enabled.
ENABLE_PEM0 (Default): Disable PEM. 1: Enable PEM
ANYSet if a core frequency excursion occurs due to a listed or unlisted reason
THERMALSet if a core frequency excursion occurs due to any thermal event in core/uncore
EXT_PROCHOTSet if a core frequency excursion occurs due to external PROCHOT assertion
PBMSet if a core frequency excursion occurs due to a power limit (socket RAPL and/or platform RAPL)
PL1Set if a core frequency excursion occurs due to PL1 input from any interfaces
PL2Set if a core frequency excursion occurs due to PL2 input from any interfaces
PMAXSet if a core frequency excursion occurs due to PMAX
ttscARTTSC Delta HBM (per HBM)
tproduct_idPRODUCT_IDProduct ID
tstringLOCAL_REVISIONLocal Revision ID for this product
RECORD_TYPERecord Type
tcore_stateENCore x is enabled (per core)
thist_counterFREQ_HIST_R0Frequency histogram range 0 (core in C6) counter (per core)
FREQ_HIST_R1Frequency histogram range 1 (16.67-800 MHz) counter (per core)
FREQ_HIST_R2Frequency histogram range 2 (801-1200 MHz) counter (per core)
FREQ_HIST_R3Frequency histogram range 3 (1201-1600 MHz) counter (per core)
FREQ_HIST_R4Frequency histogram range 4 (1601-2000 MHz) counter (per core)
FREQ_HIST_R5Frequency histogram range 5 (2001-2400 MHz) counter (per core)
FREQ_HIST_R6Frequency histogram range 6 (2401-2800 MHz) counter (per core)
FREQ_HIST_R7Frequency histogram range 7 (2801-3200 MHz) counter (per core)
FREQ_HIST_R8Frequency histogram range 8 (3201-3600 MHz) counter (per core)
FREQ_HIST_R9Frequency histogram range 9 (3601-4000 MHz) counter (per core)
FREQ_HIST_R10Frequency histogram range 10 (4001-4400 MHz) counter (per core)
FREQ_HIST_R11Frequency histogram range 11 (greater then 4400 MHz) (per core)
VOLT_HIST_R0Voltage histogram range 0 (less then 602 mV) counter (per core)
VOLT_HIST_R1Voltage histogram range 1 (602.5-657 mV) counter (per core)
VOLT_HIST_R2Voltage histogram range 2 (657.5-712 mV) counter (per core)
VOLT_HIST_R3Voltage histogram range 3 (712.5-767 mV) counter (per core)
VOLT_HIST_R4Voltage histogram range 4 (767.5-822 mV) counter (per core)
VOLT_HIST_R5Voltage histogram range 5 (822.5-877 mV) counter (per core)
VOLT_HIST_R6Voltage histogram range 6 (877.5-932 mV) counter (per core)
VOLT_HIST_R7Voltage histogram range 7 (932.5-987 mV) counter (per core)
VOLT_HIST_R8Voltage histogram range 8 (987.5-1042 mV) counter (per core)
VOLT_HIST_R9Voltage histogram range 9 (1042.5-1097 mV) counter (per core)
VOLT_HIST_R10Voltage histogram range 10 (1097.5-1152 mV) counter (per core)
VOLT_HIST_R11Voltage histogram range 11 (greater then 1152 mV) counter (per core)
TEMP_HIST_R0Temperature histogram range 0 (less then 20°C) counter
TEMP_HIST_R1Temperature histogram range 1 (20.5-27.5°C) counter
TEMP_HIST_R2Temperature histogram range 2 (28-35°C) counter
TEMP_HIST_R3Temperature histogram range 3 (35.5-42.5°C) counter
TEMP_HIST_R4Temperature histogram range 4 (43-50°C) counter
TEMP_HIST_R5Temperature histogram range 5 (50.5-57.5°C) counter
TEMP_HIST_R6Temperature histogram range 6 (58-65°C) counter
TEMP_HIST_R7Temperature histogram range 7 (65.5-72.5°C) counter
TEMP_HIST_R8Temperature histogram range 8 (73-80°C) counter
TEMP_HIST_R9Temperature histogram range 9 (80.5-87.5°C) counter
TEMP_HIST_R10Temperature histogram range 10 (88-95°C) counter
TEMP_HIST_R11Temperature histogram range 11 (greater then 95°C) counter
tpvp_throttle_counterPVP_THROTTLE_64Counter indicating the number of times the core x was throttled in the last 64 cycles window
PVP_THROTTLE_1024Counter indicating the number of times the core x was throttled in the last 1024 cycles window
tpvp_level_resPVP_LEVEL_RES_128_L0Counter indicating the percentage of residency during the last 2 ms measurement for level 0 of this type of CPU instruction
PVP_LEVEL_RES_128_L1Counter indicating the percentage of residency during the last 2 ms measurement for level 1 of this type of CPU instruction
PVP_LEVEL_RES_128_L2Counter indicating the percentage of residency during the last 2 ms measurement for level 2 of this type of CPU instruction
PVP_LEVEL_RES_128_L3Counter indicating the percentage of residency during the last 2 ms measurement for level 3 of this type of CPU instruction
PVP_LEVEL_RES_256_L0Counter indicating the percentage of residency during the last 2 ms measurement for level 0 of AVX256 CPU instructions
PVP_LEVEL_RES_256_L1Counter indicating the percentage of residency during the last 2 ms measurement for level 1 of AVX256 CPU instructions
PVP_LEVEL_RES_256_L2Counter indicating the percentage of residency during the last 2 ms measurement for level 2 of AVX256 CPU instructions
PVP_LEVEL_RES_256_L3Counter indicating the percentage of residency during the last 2 ms measurement for level 3 of AVX256 CPU instructions
PVP_LEVEL_RES_512_L0Counter indicating the percentage of residency during the last 2 ms measurement for level 0 of AVX512 CPU instructions
PVP_LEVEL_RES_512_L1Counter indicating the percentage of residency during the last 2 ms measurement for level 1 of AVX512 CPU instructions
PVP_LEVEL_RES_512_L2Counter indicating the percentage of residency during the last 2 ms measurement for level 2 of AVX512 CPU instructions
PVP_LEVEL_RES_512_L3Counter indicating the percentage of residency during the last 2 ms measurement for level 3 of AVX512 CPU instructions
PVP_LEVEL_RES_TMUL_L0Counter indicating the percentage of residency during the last 2 ms measurement for level 0 of TMUL CPU instructions
PVP_LEVEL_RES_TMUL_L1Counter indicating the percentage of residency during the last 2 ms measurement for level 1 of TMUL CPU instructions
PVP_LEVEL_RES_TMUL_L2Counter indicating the percentage of residency during the last 2 ms measurement for level 2 of TMUL CPU instructions
PVP_LEVEL_RES_TMUL_L3Counter indicating the percentage of residency during the last 2 ms measurement for level 3 of TMUL CPU instructions
ttsc_timerTSC_TIMEROOBMSM TSC (Time Stamp Counter) value
tnum_en_chaNUM_EN_CHANumber of enabled CHAs
trmid_usage_counterRMID0_RDT_CMTCHA x RMID 0 LLC cache line usage counter (per CHA)
RMID1_RDT_CMTCHA x RMID 1 LLC cache line usage counter (per CHA)
RMID2_RDT_CMTCHA x RMID 2 LLC cache line usage counter (per CHA)
RMID3_RDT_CMTCHA x RMID 3 LLC cache line usage counter (per CHA)
RMID4_RDT_CMTCHA x RMID 4 LLC cache line usage counter (per CHA)
RMID5_RDT_CMTCHA x RMID 5 LLC cache line usage counter (per CHA)
RMID6_RDT_CMTCHA x RMID 6 LLC cache line usage counter (per CHA)
RMID7_RDT_CMTCHA x RMID 7 LLC cache line usage counter (per CHA)
RMID0_RDT_MBM_TOTALCHA x RMID 0 total memory transactions counter (per CHA)
RMID1_RDT_MBM_TOTALCHA x RMID 1 total memory transactions counter (per CHA)
RMID2_RDT_MBM_TOTALCHA x RMID 2 total memory transactions counter (per CHA)
RMID3_RDT_MBM_TOTALCHA x RMID 3 total memory transactions counter (per CHA)
RMID4_RDT_MBM_TOTALCHA x RMID 4 total memory transactions counter (per CHA)
RMID5_RDT_MBM_TOTALCHA x RMID 5 total memory transactions counter (per CHA)
RMID6_RDT_MBM_TOTALCHA x RMID 6 total memory transactions counter (per CHA)
RMID7_RDT_MBM_TOTALCHA x RMID 7 total memory transactions counter (per CHA)
RMID0_RDT_MBM_LOCALCHA x RMID 0 local memory transactions counter (per CHA)
RMID1_RDT_MBM_LOCALCHA x RMID 1 local memory transactions counter (per CHA)
RMID2_RDT_MBM_LOCALCHA x RMID 2 local memory transactions counter (per CHA)
RMID3_RDT_MBM_LOCALCHA x RMID 3 local memory transactions counter (per CHA)
RMID4_RDT_MBM_LOCALCHA x RMID 4 local memory transactions counter (per CHA)
RMID5_RDT_MBM_LOCALCHA x RMID 5 local memory transactions counter (per CHA)
RMID6_RDT_MBM_LOCALCHA x RMID 6 local memory transactions counter (per CHA)
RMID7_RDT_MBM_LOCALCHA x RMID 7 local memory transactions counter (per CHA)
ttw_unitTWTime window. Valid TW range is 0 to 17. The unit is calculated as2.3 * 2^TWms (e.g.2.3 * 2^17ms = ~302 seconds).
tcore_stress_levelSTRESS_LEVELAccumulating counter indicating relative stress level for a core (per core)

过滤配置示例

示例 1:按 datatype 过滤获取 C-State 驻留与温度

以下配置仅启用tbandwidth_28b(C0/C1 驻留)与ttemperature(核心温度)两个数据类型的指标:

[[inputs.intel_pmt]] spec = "/home/telegraf/Intel-PMT/xml/pmt.xml" datatypes_enabled = ["tbandwidth_28b","ttemperature"]

示例 2:按 sample 名称过滤获取 C-State 驻留与温度

以下配置仅采集名为C0ResidencyC1ResidencyCx_TEMP的样本(其中Cx_TEMPCx_前缀表示会匹配到所有核心的 TEMP 样本):

[[inputs.intel_pmt]] spec = "/home/telegraf/Intel-PMT/xml/pmt.xml" samples_enabled = ["C0Residency","C1Residency", "Cx_TEMP"]

输出指标与标签(Metrics)

所有指标均携带以下标签:

  • guid:Intel PMT 空间的唯一 ID;
  • numa_node:采集该样本的 NUMA 节点;
  • pci_bdf:采集该样本的 PCI Bus:Device.Function(BDF);
  • sample_name:采集到的样本名称;
  • sample_group:样本所属的组名;
  • datatype_idref:样本所属的 datatype。

对于 XML 中以Cx_为前缀的样本名(x为核心编号),还会附加标签:

  • core:该指标对应的核心编号。

对于 XML 中以CHAx_为前缀的样本名(x为 CHA 编号),还会附加标签:

  • cha:该指标对应的 Caching and Home Agent(CHA)编号。

从实现上看,标签提取由 tags_extraction.go 完成:解析时通过正则^C([0-9]+)_^CHA([0-9]+)_从样本名中剥离前缀,分别写入corecha标签,同时把去掉前缀后的名字保留为sample_name,从而让同一资源维度的指标共享一个通用sample_name。字段则统一为value,对应变换公式求值结果。

示例输出

tpvp_throttle_counter作为 datatype 过滤条件时的输出示例如下(每核心两个指标:PVP_THROTTLE_64PVP_THROTTLE_1024):

intel_pmt,core=0,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C0_PVP_THROTTLE_64,sample_name=PVP_THROTTLE_64 value=1886465i 1693766334000000000 intel_pmt,core=1,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C1_PVP_THROTTLE_64,sample_name=PVP_THROTTLE_64 value=0i 1693766334000000000 intel_pmt,core=2,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C2_PVP_THROTTLE_64,sample_name=PVP_THROTTLE_64 value=0i 1693766334000000000 intel_pmt,core=4,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C4_PVP_THROTTLE_64,sample_name=PVP_THROTTLE_64 value=1357578i 1693766334000000000 intel_pmt,core=6,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C6_PVP_THROTTLE_64,sample_name=PVP_THROTTLE_64 value=2024801i 1693766334000000000 intel_pmt,core=8,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C8_PVP_THROTTLE_64,sample_name=PVP_THROTTLE_64 value=1390741i 1693766334000000000 intel_pmt,core=0,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C0_PVP_THROTTLE_1024,sample_name=PVP_THROTTLE_1024 value=12977949i 1693766334000000000 intel_pmt,core=4,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C4_PVP_THROTTLE_1024,sample_name=PVP_THROTTLE_1024 value=7180524i 1693766334000000000 intel_pmt,core=6,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C6_PVP_THROTTLE_1024,sample_name=PVP_THROTTLE_1024 value=8667263i 1693766334000000000 intel_pmt,core=8,datatype_idref=tpvp_throttle_counter,guid=0x87b6fef1,pmt,numa_node=0,pci_bdf=0000:e7:03.1,sample_group=C8_PVP_THROTTLE_1024,sample_name=PVP_THROTTLE_1024 value=5945851i 1693766334000000000

从输出可以看到,guidnuma_nodepci_bdf标识了具体的遥测空间与物理位置,core标签区分核心维度,未产生采样的核心(值为0)同样会被上报,便于下游做整体聚合与离群检测。

源码级深入:过滤、求值与位域解析

  • 位域解析:低层样本按 8 字节对齐存放在遥测缓冲区中,插件依据 XML 中每个样本的lsb/msb计算掩码mask(见 xml_parser.go),读取时执行(data & mask) >> lsb提取有效位(见 intel_pmt.go)。这保证了不同位宽、不同起始位的样本可以被精确切分。
  • 变换公式求值:高层指标并非直接读取,而是通过TransFormation公式对若干低层样本计算得到。公式中的变量以$前缀占位(如$a),XML 中的实体(&amp;&lt;&gt;)在预处理阶段被解码,十六进制常量被转换为十进制,最终交由 gval 表达式引擎求值(见 intel_pmt.go)。相关行为在 intel_pmt_test.go 中有TestTransformEquationTestEval等用例覆盖。
  • 指标过滤:datatype 与 sample 两种过滤在解析 XML 时即生效(见 xml_parser.go),未被选中的样本不会进入后续求值,从而在采集阶段就减少计算与输出量。
  • 平台降级:插件通过构建标签限定仅在linux && amd64下实现真正逻辑;在非 Linux 或非 amd64 平台,intel_pmt_notamd64linux.go 提供空实现并输出“Current platform is not supported”警告,避免启动失败。
  • 插件注册:插件通过 plugins/inputs/all/intel_pmt.go 以intel_pmt名称注册进 Telegraf 输入插件集合,编译时可借助自定义构建(custom build)按需裁剪。

使用注意事项

  1. 权限:非 root 运行 Telegraf 时,务必通过sudo setcap cap_dac_read_search+ep /usr/bin/telegraf赋予读取 PMT 空间所需的 capability,否则会因无法读取telem文件而采集失败;
  2. 内核与模块:内核需 >= 5.11,且依据内核版本加载intel_pmt_telemetry(5.11–5.14)或intel_pmt(5.14+)模块;
  3. spec 路径spec必须指向绝对路径下的pmt.xml,且该 XML 引用的 Aggregator / Aggregator Interface XML 需按basedir相对布局放置在同一目录树内;
  4. 过滤互斥datatypes_enabledsamples_enabled不可同时启用;配置的名称未匹配到时,插件会输出 Warn 日志,应核对 XML 中实际的 datatype 与样本名拼写;
  5. 平台限制:该插件只支持 Linux 平台,且实际采集逻辑仅面向 amd64 架构。

至此,你已经可以从零开始配置intel_pmt插件,按需裁剪指标,并理解其从内核 sysfs 到 Telegraf 指标输出的完整链路。更多关于输入插件通用配置(标签、字段处理、采样间隔、别名等)的说明可参考 docs/CONFIGURATION.md。

【免费下载链接】telegrafAgent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.项目地址: https://gitcode.com/GitHub_Trending/te/telegraf

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/14 6:19:45

用 Rufus 与 unattend.xml 实现 Windows 无人值守安装的完整指南

用 Rufus 与 unattend.xml 实现 Windows 无人值守安装的完整指南 【免费下载链接】rufus The Reliable USB Formatting Utility 项目地址: https://gitcode.com/GitHub_Trending/ru/rufus Rufus 是做 Windows 启动 U 盘的免费工具&#xff0c;它的 unattend.xml 应答文件…

作者头像 李华
网站建设 2026/9/14 6:18:11

2026年AI私有化部署服务商测评与技术趋势

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/9/14 6:17:35

AI Agent Skill生态解析与企业落地实践

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/9/14 6:16:25

别再手动写摘要了:3步完成T5微调,长文本摘要自动生成实战

别再手动写摘要了&#xff1a;3步完成T5微调&#xff0c;长文本摘要自动生成实战 【免费下载链接】Transformers-Tutorials This repository contains demos I made with the Transformers library by HuggingFace. 项目地址: https://gitcode.com/GitHub_Trending/tr/Transf…

作者头像 李华
网站建设 2026/9/14 6:15:49

改进NSGA-II算法解决柔性车间调度问题的Matlab实现

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/9/14 6:14:24

GEO工具怎么选?五款主流工具实测与选型思路

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华