我很难调试为什么我的指标没有达到我的普罗米修斯标准。 我正在尝试向oc代理发送简单的指标,并从中使用prometheus将其提取,但是我的代码没有失败,并且我在prometheus中看不到指标。 那么,我该如何调试呢?我可以查看指标是否到达oc代理吗?
cAgentMetricsExporter.createAndRegister(
OcAgentMetricsExporterConfiguration.builder()
.setEndPoint("IP:55678")
.setServiceName("my-service-name")
.setUseInsecure(true)
.build());
Aggregation latencyDistribution = Aggregation.Distribution.create(BucketBoundaries.create(
Arrays.asList(
0.0, 25.0, 100.0, 200.0, 400.0, 800.0, 10000.0)));
final Measure.MeasureDouble M_LATENCY_MS = Measure.MeasureDouble.create("latency", "The latency in milliseconds", "ms");
final Measure.MeasureLong M_LINES = Measure.MeasureLong.create("lines_in", "The number of lines processed", "1");
final Measure.MeasureLong M_BYTES_IN = Measure.MeasureLong.create("bytes_in", "The number of bytes received", "By");
View[] views = new View[]{
View.create(View.Name.create("myapp/latency"),
"The distribution of the latencies",
M_LATENCY_MS,
latencyDistribution,
Collections.emptyList()),
View.create(View.Name.create("myapp/lines_in"),
"The number of lines that were received",
M_LATENCY_MS,
Aggregation.Count.create(),
Collections.emptyList()),
};
// Ensure that they are registered so
// that measurements won't be dropped.
ViewManager manager = Stats.getViewManager();
for (View view : views)
manager.registerView(view);
final StatsRecorder STATS_RECORDER = Stats.getStatsRecorder();
STATS_RECORDER.newMeasureMap()
.put(M_LATENCY_MS, 17.0)
.put(M_LINES, 238)
.put(M_BYTES_IN, 7000)
.record();
答案 0 :(得分:0)
一个好问题;我也为此感到挣扎。
代理应提供更好的日志记录。
Prometheus出口商一直是我的通用解决方案。配置完成后,您可以点击代理的指标终结点以确认它是原始指标。
如果要获取指标,则问题出在Prometheus Server的目标配置上。您可以检查服务器的目标端点,以确保它正在从代理接收指标。
第二步是配置zPage,然后检查/debug/rpcz
和/debug/tracez
,以确保gRPC调用正在访问该代理。
例如
receivers:
opencensus:
address: ":55678"
exporters:
prometheus:
address: ":9100"
zpages:
port: 9999
您应该获取以下数据:
http://[AGENT]:9100/metrics
http://[AGENT]:9999/debug/rpcz
http://[AGENT]:9999/debug/tracez
另一种骇人听闻的解决方案是规避代理并配置例如一个Prometheus Exporter,直接在您的代码中运行它,并检查它的发货指标(通过/metrics
)。
通常您需要冲洗出口商。