文档文档

P4 Runtime 输入插件

此插件通过读取设备上运行的 P4 程序Counter 值,从网络设备(如可编程交换机或可编程网卡)的数据平面收集指标。通过与 P4 runtime 服务器的 gRPC 连接来收集指标。

如果您想收集有关程序名称的信息,请按照 6.2.1. 使用 PkgInfo 注释 P4 代码 中的说明修改您的 P4 程序。

引入于: Telegraf v1.26.0 标签: network, applications 操作系统支持: all

全局配置选项

插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md

配置

# P4Runtime telemetry input plugin
[[inputs.p4runtime]]
  ## Define the endpoint of P4Runtime gRPC server to collect metrics.
  # endpoint = "127.0.0.1:9559"
  ## Set DeviceID required for Client Arbitration.
  ## https://p4.org/p4-spec/p4runtime/main/P4Runtime-Spec.html#sec-client-arbitration-and-controller-replication
  # device_id = 1
  ## Filter counters by their names that should be observed.
  ## Example: counter_names_include=["ingressCounter", "egressCounter"]
  # counter_names_include = []

  ## Optional TLS Config.
  ## Enable client-side TLS and define CA to authenticate the device.
  # enable_tls = false
  # tls_ca = "/etc/telegraf/ca.crt"
  ## Set minimal TLS version to accept by the client.
  # tls_min_version = "TLS12"
  ## Use TLS but skip chain & host verification.
  # insecure_skip_verify = true

  ## Define client-side TLS certificate & key to authenticate to the device.
  # tls_cert = "/etc/telegraf/client.crt"
  # tls_key = "/etc/telegraf/client.key"

Metrics

P4 运行时服务器使用 P4 Protocol Buffer 定义进行通信。有关加载到可编程交换机中的程序的静态信息是通过 GetForwardingPipelineConfigRequest 消息收集的。该插件使用 Read 方法收集动态指标。Readrequest 定义为单个 Entity,类型为 CounterEntry。由于 P4 计数器是数组类型,因此该插件通过 通配符查询 收集数组的每个单元格的值。

P4 程序中定义的计数器具有唯一的 ID 和名称。counter_index 定义了在指标中使用计数器数组的哪个单元格值。

标签按以下方式构建

  • p4program_name:用户提供的 P4 程序名称。
  • counter_name:P4 程序中给定计数器的名称。
  • counter_type:计数器类型(BYTES, PACKETS, BOTH)。

字段按以下方式构建

  • bytes:在计数器中收集的字节数。
  • packets:在计数器中收集的数据包数。
  • counter_index:在 P4 计数器中收集指标的索引。

示例输出

p4_runtime,counter_name=MyIngress.egressTunnelCounter,counter_type=BOTH,host=p4 bytes=408i,packets=4i,counter_index=200i 1675175030000000000

此页面是否有帮助?

感谢您的反馈!


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