gpt4 book ai didi

java - 格拉法纳中的"t.data.data is undefined"

转载 作者:行者123 更新时间:2023-12-02 01:43:50 25 4
gpt4 key购买 nike

我是 micrometer、prometheus 和 grafana 的新手。我正在尝试将这三件事一起运行来运行我的第一个示例。但我很难弄清楚我做错了什么。

我正在使用 micrometer 的 API 创建一个 PrometheusMeterRegistry,如下所示:

new PrometheusMeterRegistry(new PrometheusConfig() {
@Override
public Duration step() {
return Duration.ofSeconds(10);
}

@Override
@Nullable
public String get(String k) {
return null;
}
});

我正在使用以下代码创建一个 HttpServer,如下所述:

try {
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
server.createContext("/prometheus", httpExchange -> {
String response = prometheusMeterRegistry.scrape();
httpExchange.sendResponseHeaders(200, response.getBytes().length);
try (OutputStream os = httpExchange.getResponseBody()) {
os.write(response.getBytes());
}
});

new Thread(server::start).start();
} catch (IOException e) {
throw new RuntimeException(e);
}

我将 Prometheus 配置为 grafana 中的数据源,并将 URL 设置为 http://localhost:8080/prometheus。但是,当我尝试创建新的仪表板并向其中添加图表时,我收到一个红色感叹号,提示 t.data.data 未定义。因此我无法查看图表。完整的堆栈跟踪如下:

kr</t.prototype.transform@http://localhost:3000/public/build/app.dfabdd44b3be44288eac.js:22:723420
jr</t.prototype.query/</<@http://localhost:3000/public/build/app.dfabdd44b3be44288eac.js:22:736135
qt@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:9:5239
Wa@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:9:40274
jr</t.prototype.query/<@http://localhost:3000/public/build/app.dfabdd44b3be44288eac.js:22:735858
c/</<@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:130:92198
c/<@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:130:92043
$digest@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:130:97575
$apply@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:130:99590
$applyAsync/r<@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:130:99735
h@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:130:33036
ln/this.$get</</i.defer/n<@http://localhost:3000/public/build/vendor.dfabdd44b3be44288eac.js:130:34396

以下是我在grafana中得到的错误截图: enter image description here

有什么我可能缺少的建议吗?

注意:我可以使用 URL localhost:8080/prometheus 看到计时器在 native prometheus 上发布。

最佳答案

8080 是您的应用程序服务器。您需要运行一个 Prometheus 服务器来抓取此应用程序,然后您可以使用 localhost:9090 作为数据源。

关于java - 格拉法纳中的"t.data.data is undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54011331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com