1

我很难调试为什么我的指标没有达到我的普罗米修斯。我正在尝试将简单的指标发送到 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();
4

1 回答 1

1

一个好问题;我也为此苦苦挣扎。

代理应该提供更好的日志记录。

Prometheus Exporter 一直是我的通用解决方案。配置完成后,您可以点击代理的指标端点以确认它是原始指标。

如果您正在获取指标,那么问题在于您的 Prometheus 服务器的目标配置。您可以检查服务器的目标端点以确保它正在从代理接收指标。

第二步是配置 zPages,然后检查/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

另一个 hacky 解决方案是绕过代理并直接在您的代码中配置例如 Prometheus Exporter,运行它并检查它的运输指标(通过/metrics)。

通常你需要刷新出口商。

于 2019-10-10T17:23:43.510 回答