brettlangdon / node-dogapi

Datadog API Node.JS Client
https://brettlangdon.github.io/node-dogapi/
105 stars 45 forks source link

dogapi.metric.send_all sends points in wrong format. #28

Closed brentax closed 8 years ago

brentax commented 8 years ago

The following code will return a 202 {"status":"ok"} from DataDog, but the metrics will not appear in DataDog. (That's a bug on their side, they seem to silently swallow the malformed points).

var metrics = [
    {
        metric: "some.key",
        points: 8,
        tags: ["environment:qa"]
    },
    {
        metric: "some.other.key",
        points: 22,
        tags: ["environment:qa"]
    }
];

dogapi.metric.send_all(metrics, function(err, results) {
    console.log(results);
});

dogapi formats the above data into {"series":[{"metric":"some.key","points":[1455834677,8],"tags":["environment:qa"]},{"metric":"some.other.key","points":[1455834677,22],"tags":["environment:qa"]}]}. Note that both points keys have a single array as their values.

According to the API documentation, they expect an array of arrays for the points. Instead of "points":[1455834677,8], we should have "points":[[1455834677,8]].

brentax commented 8 years ago

Ah, looks like this got fixed for send but not send_all: https://github.com/brettlangdon/node-dogapi/pull/21

brettlangdon commented 8 years ago

@brentax thank you so much for reporting this issue, I have opened up #29 to address the issue by moving the metric points normalization process into send_all.

brettlangdon commented 8 years ago

I will let you know when I release an updated version of the client.

brettlangdon commented 8 years ago

@brentax should be resolved now with version 2.0.0.

Thanks again for all the help here.