作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 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
有什么我可能缺少的建议吗?
注意:我可以使用 URL localhost:8080/prometheus
看到计时器在 native prometheus 上发布。
最佳答案
8080 是您的应用程序服务器。您需要运行一个 Prometheus 服务器来抓取此应用程序,然后您可以使用 localhost:9090 作为数据源。
关于java - 格拉法纳中的"t.data.data is undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54011331/
我是一名优秀的程序员,十分优秀!