我正在尝试写入一个 openTSDB 数据库,以便可以使用 Bosun 分析我的数据。
如果我通过 Bosun 界面手动添加数据,它可以正常工作,但是如果我POST
向 < docker-ip>/api/put
(<docker-ip>
配置正确)发出请求,则数据不会显示在 Bosun 中。
如果我从我的 Java 应用程序以 JSON 格式发送数据点,Bosun 中根本没有显示任何内容,但如果我使用 chrome 应用程序“Postman”发送请求,那么指标会显示,但我随请求发送的数据不会.
这是我要发送的数据:
try {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("http://192.168.59.103:8070/api/put?summary");
StringEntity params = new StringEntity("{\"metric\":\"tester.example\",\"timestamp\":\"" + System.currentTimeMillis() + "\", \"value\": \"22\", \"tags\": { \"host\": \"chrisedwards\", \"dc\": \"lga\" }}");
request.setEntity(params);
request.setHeader("Content-Type", "application/json; charset=UTF-8");
HttpResponse response = httpClient.execute(request);
System.out.println(response);
// handle response here...
} catch (Exception ex) {
ex.printStackTrace();
} finally {
// httpClient.close();
}
它返回一个200 response code
. 我使用 Postmaster 将相同的请求发送到与 java 应用程序中相同的地址,但是,postmaster 请求在 Bosun 中显示指标名称但没有数据,Java 请求甚至不显示指标名称。