Skip to content

[outputs.prometheus_client] Support UTF-8 metric and label names #18340

@tianyu-2025

Description

@tianyu-2025

Use Case

I use outputs.prometheus_client plugin to expose metrics for Prometheus to scrape. In my current setup, the collected metrics contain UTF-8 text in metric names or label names.

As of now, Prometheus 3.0 has explicitly added support for UTF-8 metric names and label names (https://prometheus.io/docs/guides/utf8/).

I would like the outputs.prometheus_client plugin also support exporting UTF-8 encoded metric names and label names, so that its behavior aligns with the current capabilities of Prometheus.

Expected behavior

Given that Prometheus 3.0 already supports UTF-8, when using the outputs.prometheus_client plugin to expose metrics over HTTP, I expect that:

  • Telegraf can accept UTF-8 encoded metric names and label names
  • These UTF-8 names are exposed correctly in the Prometheus exposition output

Actual behavior

[[outputs.prometheus_client]]
  listen = ":9273"
  path = "/metrics"
  metric_version = 2
  expiration_interval = "5m"

Input

# metrics.lp
metric_ch_tag,中文标签=alpha value=1
metric_ch_tag_value,tag=中文 value=1
metric_ch_field,tag=alpha 中文字段=1

Output

# HELP metric_ch_field Telegraf collected metric
# TYPE metric_ch_field untyped
metric_ch_field{host="host_xxx",tag="alpha"} 1

# HELP metric_ch_tag_value Telegraf collected metric
# TYPE metric_ch_tag_value untyped
metric_ch_tag_value{host="host_xxx"} 1

# HELP metric_ch_tag_value_value Telegraf collected metric
# TYPE metric_ch_tag_value_value untyped
metric_ch_tag_value_value{host="host_xxx",tag="中文"} 1

In the current version of outputs.prometheus_client, even though Prometheus 3.0 supports UTF-8, when metric names or label names contain non-ASCII characters:

  • The plugin still applies sanitization during the serialization stage
  • Non-ASCII UTF-8 characters are replaced or filtered out
  • The exposed metric names or label names no longer match the original data

Additional info

I have already implemented UTF-8 support for metric names and label names based on the current outputs.prometheus_client plugin, and I would like to contribute to the development of this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestRequests for new plugin and for new features to existing plugins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions