文档文档

Azure Monitor 输出插件

此插件将指标写入 Azure Monitor,其指标分辨率为一分钟。为了在 Telegraf 中进行适应,该插件将自动将指标聚合到一分钟的桶中,并在每个刷新间隔将其发送到服务。

Azure Monitor 自定义指标服务目前处于预览状态,可能并非在所有 Azure 区域都可用。也请注意指标时间限制!

每个输入插件的指标将写入一个单独的 Azure Monitor 命名空间,默认情况下以 Telegraf/ 作为前缀。每个指标的字段名将作为 Azure Monitor 指标名写入。所有字段值将作为汇总集写入,包括:最小值、最大值、总和、计数。标签将作为维度写入每个 Azure Monitor 指标。

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

全局配置选项

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

配置

# Send aggregate metrics to Azure Monitor
[[outputs.azure_monitor]]
  ## Timeout for HTTP writes.
  # timeout = "20s"

  ## Set the namespace prefix, defaults to "Telegraf/<input-name>".
  # namespace_prefix = "Telegraf/"

  ## Azure Monitor doesn't have a string value type, so convert string
  ## fields to dimensions (a.k.a. tags) if enabled. Azure Monitor allows
  ## a maximum of 10 dimensions so Telegraf will only send the first 10
  ## alphanumeric dimensions.
  # strings_as_dimensions = false

  ## Both region and resource_id must be set or be available via the
  ## Instance Metadata service on Azure Virtual Machines.
  #
  ## Azure Region to publish metrics against.
  ##   ex: region = "southcentralus"
  # region = ""
  #
  ## The Azure Resource ID against which metric will be logged, e.g.
  ##   ex: resource_id = "/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.Compute/virtualMachines/<vm_name>"
  # resource_id = ""

  ## Optionally, if in Azure US Government, China, or other sovereign
  ## cloud environment, set the appropriate REST endpoint for receiving
  ## metrics. (Note: region may be unused in this context)
  # endpoint_url = "https://monitoring.core.usgovcloudapi.net"

  ## Time limitations of metric to send
  ## Documentation can be found here:
  ##   https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-store-custom-rest-api?tabs=rest#timestamp
  ## However, the returned (400) error message might document more strict or
  ## relaxed settings. By default, only past metrics witin the limit are sent.
  # timestamp_limit_past = "30m"
  # timestamp_limit_future = "-1m"

设置

  1. 在您的 Azure 订阅中注册 microsoft.insights 资源提供程序.
  2. 如果使用托管服务标识来认证 Azure VM,请 启用系统分配的托管标识
  3. 使用支持 Azure Monitor 自定义指标的区域。对于支持自定义指标的区域,将有一个格式为 https://<region>.monitoring.azure.com 的终结点。

区域和资源 ID

插件将尝试使用 Azure VM 实例元数据服务发现区域和资源 ID。如果 Telegraf 未在虚拟机上运行或 VM 实例元数据服务不可用,则输出功能需要以下变量。

  • region
  • resource_id

身份验证

此插件使用几种不同的身份验证方法之一。首选的身份验证方法与检查每种身份验证的顺序不同。以下是首选的身份验证方法。

  1. 托管服务标识 (MSI) 令牌:这是首选的身份验证方法。在 Azure VM 上运行时,Telegraf 将自动使用此方法进行身份验证。

  2. AAD 应用程序令牌(服务主体)

    • 主要适用于 Telegraf 为其他资源写入指标。 更多信息
    • 需要将服务主体或用户主体分配到要发出指标的资源上的 Monitoring Metrics Publisher 角色。
  3. AAD 用户令牌(用户主体)

    • 允许 Telegraf 像用户一样进行身份验证。最好在开发中使用此方法。

插件将使用以下配置中第一个可用的进行身份验证

  1. 客户端凭据:Azure AD 应用程序 ID 和密钥。设置以下环境变量

    • AZURE_TENANT_ID:指定要进行身份验证的租户。
    • AZURE_CLIENT_ID:指定要使用的应用程序客户端 ID。
    • AZURE_CLIENT_SECRET:指定要使用的应用程序密钥。
  2. 客户端证书:Azure AD 应用程序 ID 和 X.509 证书。

    • AZURE_TENANT_ID:指定要进行身份验证的租户。
    • AZURE_CLIENT_ID:指定要使用的应用程序客户端 ID。
    • AZURE_CERTIFICATE_PATH:指定要使用的证书路径。
    • AZURE_CERTIFICATE_PASSWORD:指定要使用的证书密码。
  3. 资源所有者密码:Azure AD 用户和密码。不推荐使用此授权类型,如果您需要交互式登录,请改用设备登录。

    • AZURE_TENANT_ID:指定要进行身份验证的租户。
    • AZURE_CLIENT_ID:指定要使用的应用程序客户端 ID。
    • AZURE_USERNAME:指定要使用的用户名。
    • AZURE_PASSWORD:指定要使用的密码。
  4. Azure 托管服务标识:将凭据管理委托给平台。要求代码在 Azure 中运行,例如在 VM 上。所有配置均由 Azure 处理。有关更多详细信息,请参阅 Azure 托管服务标识。仅在使用 Azure 资源管理器时可用。

如上所示,当 Telegraf 在 Azure VM 上运行时,最后一个选项(#4)是首选的身份验证方式。

维度

Azure Monitor 仅接受数值类型的值。默认情况下,插件将丢弃字符串类型的字段。通过将配置选项 strings_as_dimensions 设置为 true,插件可以将所有字符串类型字段设置为 Azure Monitor 自定义指标中的额外维度。

请记住,Azure Monitor 每个指标最多允许 10 个维度。插件将确定性地丢弃任何超出 10 个维度限制的维度。

要仅将一部分字符串类型字段转换为维度,请启用 strings_as_dimensions 并使用 fieldincludefieldexclude 修饰符来限制发送到插件的字符串类型字段。

指标时间限制

Azure Monitor 不接受太久以前或将来的指标。在配置输出缓冲区限制或其他变量(如刷新间隔)或使用可能导致指标超出此允许范围的输入源时,请牢记这一点。

根据 文档,在将指标发送到 Azure Monitor 服务时,时间戳不应早于 20 分钟或晚于 5 分钟。但是,服务返回的 HTTP 400 错误消息可能指定其他值,例如 30 分钟前和 4 分钟后的时间。

您可以使用 timestamp_limit_pasttimestamp_limit_future 设置来控制实际发送的时间范围。默认情况下,只发送 30 分钟内最多一分钟前的指标。下限代表在 400 错误消息中收到的更宽松的限制。上限留有足够的时间进行聚合,避免过早发送聚合。

在调整限制时,您需要考虑服务允许的限制以及发送指标时的延迟。此外,您不应过早发送指标,因为在这种情况下,聚合可能不会发生,值也会产生误导。


此页面是否有帮助?

感谢您的反馈!


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