kairosdb / kairosdb-client

Java Client for KairosDB
65 stars 67 forks source link

Get 500 error adding metrics #5

Closed stevemenke closed 11 years ago

stevemenke commented 11 years ago

I get a 500 error whenever I try to add a metric. I simplified my code to reproduce and inserted below:

    try {
        MetricBuilder builder = MetricBuilder.getInstance();
        Metric metric = builder.addMetric("Test");
        metric.addTag("Host", "localhost");
        metric.addDataPoint(System.currentTimeMillis(), 10L);

        System.out.println(builder.build());
        Response response = httpClient.pushMetrics(builder);    
        if (response.getStatusCode() != 200) {
            System.out.println(response.getErrors().toString());
            throw new Exception("Did not return 200");
        }
    } finally {
        httpClient.shutdown();
    }

The resulting JSON string is as follows:

[{"datapoints":[[1374407396775,10]],"name":"Test","dataPoints":[{"value":10,"integer":true,"timestamp":1374407396775}],"tags":{"Host":"localhost"}}]

The error message with the 500 errors is as follows: [Expected a name but was BEGIN_ARRAY at line 1 column 65]

It appears that the build is using both the "timestamp" with "value" for a single data point and "datapoints" at the same time.

stevemenke commented 11 years ago

Sorry, I should have waited before I posted. I found a dependency conflict with jackson-mapper-asl that was forcing it to use and older version. Once I forced the version everything worked fine.