将标签添加到默认的Golang Prometheus指标

问题描述 投票:1回答:1

我目前正在使用github.com/prometheus/client_golang作为检索Golang应用程序指标的端点。它提供了许多默认的默认数据集,例如:

go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0
go_gc_duration_seconds_sum 0
go_gc_duration_seconds_count 0
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 10
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.13.10"} 1

似乎我在库中找不到向这些数据集添加标签的任何功能。因为我将在同一台计算机上运行许多这些应用程序,所以我需要添加标签来区分数据点。 client_golang库中有什么方法可以做到这一点?

http go
1个回答
0
投票

这些应用程序中的每个应用程序都应由普罗米修斯作为单独的工作/实例进行刮擦。它将添加job标签和instance标签,它们也可以区分不同的进程(并允许您区分同一作业的多个实例)。

请参见https://prometheus.io/docs/concepts/jobs_instances/#automatically-generated-labels-and-time-series以获取更多详细信息。

您还可以使用重新标记规则来添加其他标签,这取决于发现应用程序的方式。如果使用的是静态配置(https://prometheus.io/docs/prometheus/latest/configuration/configuration/#static_config),则可以在该配置中添加其他区分标签。对于file_sd_config同样:https://prometheus.io/docs/prometheus/latest/configuration/configuration/#file_sd_config

© www.soinside.com 2019 - 2024. All rights reserved.