【发布时间】:2018-03-09 16:23:16
【问题描述】:
我正在尝试计算唯一 URI 的数量并记录它们。这些 URI 会随着时间而改变,并且可以有多个相同类型的 URI。例如,可以有多个“/foo”和“/bar”,并且可以输入一个新的 URI - 比如说“pooh” - 我必须将它们添加到计数器并保持计数。在这种情况下,我不能使用常量标签。例如,如果我要按方法和/或状态码计算 http 请求的数量,我可以这样做:
httpRequestInfo := prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "http_requests_sum",
ConstLabels: prometheus.Labels{"component": "foo"},
Help: " A Counter of the number of each type of request by status code and method",
},
[]string{"code", "method"},
)
在这种情况下如何使用计数器?谢谢!
【问题讨论】:
标签: go prometheus