2

我使用以下代码段注册了 Prometheus 计数器。

public static final Counter requestsReceived = Counter.build("total_request_count_proxy_serv", "Total number of requests to a proxy service").labelNames("service", "method", "endpoint", "remoteAddress").register();

当我公开指标并在浏览器中查看它们时,我得到了以下时间戳为空的结果。

Name: total_request_count_proxy_serv Type: COUNTER Help: Total number of requests to a proxy service Samples: [Name: total_request_count_proxy_serv LabelNames: [service, method, endpoint, remoteAddress] labelValues: [TestProxy, GET, /services/TestProxy, 127.0.0.1] Value: 2.0 **TimestampMs: null**]

为什么时间戳显示为空?

4

1 回答 1

2

直接检测没有时间戳,所以这是正确的。时间戳仅出现在出口商的某些利基用例中。

指标名称也应该从最少到最具体,避免冗余和计数器以 结尾_total,这样myproxy_requests_total会是一个更清晰、更简洁的名称。

于 2020-04-04T08:26:58.433 回答