文档文档

AWS EC2 元数据处理器插件

此插件将从AWS IMDS 收集的元数据附加到与 EC2 实例相关的指标。

引入于: Telegraf v1.18.0 标签: annotation, cloud 操作系统支持: all

全局配置选项

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

配置

# Attach AWS EC2 metadata to metrics
[[processors.aws_ec2]]
  ## Instance identity document tags to attach to metrics.
  ## For more information see:
  ## https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html
  ##
  ## Available tags:
  ## * accountId
  ## * architecture
  ## * availabilityZone
  ## * billingProducts
  ## * imageId
  ## * instanceId
  ## * instanceType
  ## * kernelId
  ## * pendingTime
  ## * privateIp
  ## * ramdiskId
  ## * region
  ## * version
  # imds_tags = []

  ## EC2 instance tags retrieved with DescribeTags action.
  ## In case tag is empty upon retrieval it's omitted when tagging metrics.
  ## Note that in order for this to work, role attached to EC2 instance or AWS
  ## credentials available from the environment must have a policy attached, that
  ## allows ec2:DescribeTags.
  ##
  ## For more information see:
  ## https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeTags.html
  # ec2_tags = []

  ## Paths to instance metadata information to attach to the metrics.
  ## Specify the full path without the base-path e.g. `tags/instance/Name`.
  ##
  ## For more information see:
  ## https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
  # metadata_paths = []

  ## Allows to convert metadata tag-names to canonical names representing the
  ## full path with slashes ('/') being replaces with underscores. By default,
  ## only the last path element is used to name the tag.
  # canonical_metadata_tags = false

  ## Timeout for http requests made by against aws ec2 metadata endpoint.
  # timeout = "10s"

  ## ordered controls whether or not the metrics need to stay in the same order
  ## this plugin received them in. If false, this plugin will change the order
  ## with requests hitting cached results moving through immediately and not
  ## waiting on slower lookups. This may cause issues for you if you are
  ## depending on the order of metrics staying the same. If so, set this to true.
  ## Keeping the metrics ordered may be slightly slower.
  # ordered = false

  ## max_parallel_calls is the maximum number of AWS API calls to be in flight
  ## at the same time.
  ## It's probably best to keep this number fairly low.
  # max_parallel_calls = 10

  ## cache_ttl determines how long each cached item will remain in the cache before
  ## it is removed and subsequently needs to be queried for from the AWS API. By
  ## default, no items are cached.
  # cache_ttl = "0s"

  ## tag_cache_size determines how many of the values which are found in imds_tags
  ## or ec2_tags will be kept in memory for faster lookup on successive processing
  ## of metrics. You may want to adjust this if you have excessively large numbers
  ## of tags on your EC2 instances, and you are using the ec2_tags field. This
  ## typically does not need to be changed when using the imds_tags field.
  # tag_cache_size = 1000

  ## log_cache_stats will emit a log line periodically to stdout with details of
  ## cache entries, hits, misses, and evacuations since the last time stats were
  ## emitted. This can be helpful in determining whether caching is being effective
  ## in your environment. Stats are emitted every 30 seconds. By default, this
  ## setting is disabled.
  # log_cache_stats = false

示例

accountIdinstanceId 追加到指标标签

[[processors.aws_ec2]]
  tags = [ "accountId", "instanceId"]
- cpu,hostname=localhost time_idle=42
+ cpu,hostname=localhost,accountId=123456789,instanceId=i-123456789123 time_idle=42

注意

我们使用一个单一的缓存,因为 telegraf 的 AddTag 函数遵循这种模式。

用户可以指定一个 EC2 标签和 IMDS 标签的列表。这些项在技术上可以是相同的。这将导致 EC2 标签的值覆盖 IMDS 标签的值。

尽管这是不理想的,但这是不可避免的,因为 AddTag 函数不支持这种情况。

您应该避免使用 IMDS 标签作为 EC2 标签,因为 EC2 标签将始终“获胜”,因为它们在这个插件中 IMDS 标签之后被处理。


此页面是否有帮助?

感谢您的反馈!


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