brettlangdon / node-dogapi

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

Metrics Reporting is Broken? #20

Closed Aslan11 closed 9 years ago

Aslan11 commented 9 years ago

Hey Brett,

Thanks for putting together this handy little package. My co-worker and I have been working hard to implement data-dog in our app, your package seems to report events fine but the metrics section might need to be updated... Neither of us have been able to successfully implement the metric.send() function from both the app and the command line. We scrubbed your package's code and it seems sound but we're wondering if you're aware of this issue or if we're just derping it up somehow.

code (coffeescript):

dogapi.metric.send(metric, points, extra, (err, res)->
  console.log "Metric Sent! #{metric}"
  if err
    console.log err
  console.dir res           
)

the res that comes back from our function above always evaluates to the following object:

{status: 'ok'}

however the metric never appears in the data dog GUI, the events that we log using the dogapi and same app keys do show up without a hitch.

Best,

Kevin

brettlangdon commented 9 years ago

Hey @Aslan11 thanks for reporting. I'll have to give this a try later and investigate what is going on.

I'll let you know if I end up needing more information for debugging, once I get started.

brettlangdon commented 9 years ago

@Aslan11 hmm... I am getting the same results. I have reached out to DD and hopefully with their help I can debug this issue.

I do have to ask though, are you planning on using this dogapi.metric.send instead of sending metrics via statsd? Because I would strongly suggest using statsd instead of this library for sending metrics since that uses a local UDP server vs this connecting to DD over http for each call.

brettlangdon commented 9 years ago

Suppose I should leave the re-pro info here.

If you run the following:

curl -X POST -H "Content-type: application/json" \
     -d "{\"series\":[{\"metric\":\"my.metric\",\"points\":[$(date +%s),1000]}]}" \
     "https://app.datadoghq.com/api/v1/series?api_key=<API_KEY>"

And then check out the metrics summary and search for your metric (in this case my should find it): https://app.datadoghq.com/metric/summary

But... nothing shows up :(

Aslan11 commented 9 years ago

@brettlangdon we were not planning on using statsd but we'll look into it, thanks for the insight

brettlangdon commented 9 years ago

Ok, with the help of DataDog, my example above is broken, points needs to be an array of arrays.

This is an incorrect assumption: https://github.com/brettlangdon/node-dogapi/blob/b06bf7a1b91105c0937d6ab7e323ee557a971f8a/lib/api/metric.js#L10-L11

Which is that points can be a single value as opposed to an array of [timestamp, value].

Instead we need to coerce points into an array of arrays.

Will work on a fix.

Aslan11 commented 9 years ago

You da man @brettlangdon

jryoo commented 9 years ago

Can you give an example of a correct request?

brettlangdon commented 9 years ago

@jryoo this is the proper api call to datadog. I need to fix dogapi still.

curl -X POST -H "Content-type: application/json" \
     -d "{\"series\":[{\"metric\":\"my.metric\",\"points\":[[$(date +%s),1000]]}]}" \
     "https://app.datadoghq.com/api/v1/series?api_key=<API_KEY>"

Notice, points: [ [<timestamp>, <value>] ] as opposed to points: [<timestamp>, <value>](as it is being sent now).

brettlangdon commented 9 years ago

@Aslan11 this should be resolved, please update to v1.0.6 and give it a try.

Aslan11 commented 9 years ago

@brettlangdon it's flawless now, thank you so much!