kairosdb-client icon indicating copy to clipboard operation
kairosdb-client copied to clipboard

bug1

Open 15116303251 opened this issue 6 years ago • 2 comments

image

这是3.0.0 版本测试复杂数据类型的用例,添加的时候直接返回400

15116303251 avatar Apr 11 '19 02:04 15116303251

I need more information. If you are using a custom type you need to make sure that you added the type to the KairosDB server.

jsabin avatar May 30 '19 02:05 jsabin

It seems I'm having the same problem. I'm trying to push via JAVA a sample metric taken from documentation's examples. Her is my code (portion):

HttpClient client = new HttpClient(url);
client.registerCustomDataType("complex", ComplexNumber.class); // "complex" is the group type
MetricBuilder metricBuilder = MetricBuilder.getInstance();
Metric metric = metricBuilder.addMetric("metric1", "complex-number");  // "complex-number" is the registered type
metric.addTag("host", "myHost");
metric.addDataPoint(System.currentTimeMillis(), new ComplexNumber(2.3, 3.4));
metric.addDataPoint(System.currentTimeMillis(), new ComplexNumber(1.1, 5));
client.pushMetrics(metricBuilder);

[...]

class ComplexNumber {
	private double real;
	private double imaginary;
	public ComplexNumber(double real, double imaginary) {
		this.real = real;
		this.imaginary = imaginary;
	}
}

And this is the error a get:

UnexpectedResponseException{request=Request{uri=http://localhost:6080/api/v1/datapoints, method=POST, headers={Content-Type=[application/json; charset=UTF-8]}, bodySource=org.kairosdb.client.HttpClient$StringBodySource@2ddc8ecb, followRedirects=false}, statusCode=400, statusMessage=Bad Request, headers={Access-Control-Allow-Origin=[*], Content-Type=[application/json], Transfer-Encoding=[chunked], Server=[Jetty(8.1.16.v20140903)]}}
	at org.kairosdb.client.response.DefaultJsonResponseHandler.handle(DefaultJsonResponseHandler.java:100)
	at org.kairosdb.client.HttpClient.execute(HttpClient.java:330)
	at org.kairosdb.client.HttpClient.postData(HttpClient.java:290)
	at org.kairosdb.client.HttpClient.pushMetrics(HttpClient.java:253)

P.S.: I'm using KairosDB v1.2.2.

otrebor1979 avatar Nov 06 '19 17:11 otrebor1979

This is likely due to the server not having the type registered in the config file. You will need to provide a plugin jar that has the type in it and load it in a module. See the comments in the kairosdb.conf file for further information.

brianhks avatar Mar 22 '24 22:03 brianhks