文档文档

Google Cloud Monitoring 输出插件

此插件将指标写入Google Cloud Monitoring(以前称为 Stackdriver)的 project。需要使用服务帐户或用户凭据进行身份验证

此插件访问收费的 API,可能会产生费用。

默认情况下,指标按 namespace 变量和指标键分组,例如:custom.googleapis.com/telegraf/system/load5。但是,这不是最佳实践。设置 metric_name_format = "official" 将产生一种更易于查询的格式:metric_type_prefix/[namespace_]name_key/kind。如果未设置全局命名空间,则省略。

引入版本: Telegraf v1.9.0 标签: cloud, datastore 操作系统支持: all

全局配置选项

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

配置

# Configuration for Google Cloud Stackdriver to send metrics to
[[outputs.stackdriver]]
  ## GCP Project
  project = "erudite-bloom-151019"

  ## Quota Project
  ## Specifies the Google Cloud project that should be billed for metric ingestion.
  ## If omitted, the quota is charged to the service account’s default project.
  ## This is useful when sending metrics to multiple projects using a single service account.
  ## The caller must have the `serviceusage.services.use` permission on the specified project.
  # quota_project = ""

  ## The namespace for the metric descriptor
  ## This is optional and users are encouraged to set the namespace as a
  ## resource label instead. If omitted it is not included in the metric name.
  namespace = "telegraf"

  ## Metric Type Prefix
  ## The DNS name used with the metric type as a prefix.
  # metric_type_prefix = "custom.googleapis.com"

  ## Metric Name Format
  ## Specifies the layout of the metric name, choose from:
  ##  * path: 'metric_type_prefix_namespace_name_key'
  ##  * official: 'metric_type_prefix/namespace_name_key/kind'
  # metric_name_format = "path"

  ## Metric Data Type
  ## By default, telegraf will use whatever type the metric comes in as.
  ## However, for some use cases, forcing int64, may be preferred for values:
  ##   * source: use whatever was passed in
  ##   * double: preferred datatype to allow queries by PromQL.
  # metric_data_type = "source"

  ## Tags as resource labels
  ## Tags defined in this option, when they exist, are added as a resource
  ## label and not included as a metric label. The values from tags override
  ## the values defined under the resource_labels config options.
  # tags_as_resource_label = []

  ## Custom resource type
  # resource_type = "generic_node"

  ## Override metric type by metric name
  ## Metric names matching the values here, globbing supported, will have the
  ## metric type set to the corresponding type.
  # metric_counter = []
  # metric_gauge = []
  # metric_histogram = []

  ## NOTE: Due to the way TOML is parsed, tables must be at the END of the
  ## plugin definition, otherwise additional config options are read as part of
  ## the table

  ## Additional resource labels
  # [outputs.stackdriver.resource_labels]
  #   node_id = "$HOSTNAME"
  #   namespace = "myapp"
  #   location = "eu-north0"

限制

Stackdriver 不支持自定义指标中的字符串值,任何字符串字段都不会被写入。

Stackdriver API 不允许写入无序的点、超过 24 小时的数据,或者每分钟精度大于一点的数据。由于 Telegraf 先写入最新的点,然后向前遍历指标缓冲区,因此在中断后可能无法写入历史数据。

精度大于 1 分钟的点可能需要先进行聚合才能写入。可以考虑使用 basicstats 聚合器来完成此操作。

直方图仅通过 Prometheus 指标版本 1 解析器生成的指标来支持。版本 2 解析器生成的稀疏指标在发送到 Stackdriver 之前需要进行大量转换。

请注意,为了符合 Stackdriver API 的要求,该插件会为所有 COUNTER 指标维护一个内存缓存,其中包含它们的起始时间和上次观察到的值。此缓存不会被垃圾回收:如果您从输入端移除了大量计数器,您可能需要重启 telegraf 来清除它。


此页面是否有帮助?

感谢您的反馈!


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