【问题标题】:Escape special characters in Prometheus metric names?转义 Prometheus 指标名称中的特殊字符?
【发布时间】:2018-09-27 12:27:37
【问题描述】:

在从遗留应用程序中公开 Prometheus 指标时,我发现某些指标包含无效字符,例如 my.metric、my-metric、my:metric

我可以例如转义这些字符,而不是更改我的旧应用程序中的指标名称(它很大): my.metric, my-metric, my:metric

或者,我可以用(单引号或双引号)将这些名称括起来: “my.metric”、“my-metric”、“my:metric” 'my.metric'、'my-metric'、'my:metric'

这些功能能否与现有的 Prometheus 功能配合使用? 上游/实现对其中任何一个或两者的支持是否可以?

【问题讨论】:

    标签: escaping special-characters metrics prometheus


    【解决方案1】:

    对于 Prometheus 指标名称,引号也不是有效字符。

    处理此问题的标准方法是将无效字符转换为下划线:https://prometheus.io/docs/instrumenting/writing_exporters/#naming

    【讨论】:

    • 明白。我希望以某种方式添加对(至少一些)特殊字符的支持,我的目标是在遗留 Prometheus 代码中找到侵入性最小的方法。
    • 是否可以像上面建议的那样逃避可能性,可以在 Prometheus 中实现而不与旧功能冲突?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多