Giter Site home page Giter Site logo

node-dogapi's People

Contributors

alexcreek avatar brettlangdon avatar crrobinson14 avatar dalehamel avatar erikboesen avatar jetmind avatar jkurz avatar jrgm avatar jupemara avatar miskiw avatar mklopets avatar mousavian avatar posto avatar reason-bv avatar robertprediger avatar rscheuermann avatar tdlsheriff avatar vijayparikh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-dogapi's Issues

Can I submit metrics using client token? (intead of api_key/app_key)

Thanks for building this great library!

Hi, I'm building an Electron app and I'd like to collect metrics from the app. Is there any way I can use a Client Token to submit metrics? I'm playing with the API but keep getting erros that api_key is required.

The log management system and RUM can take a client token, but I haven't found a way to get their metrics APIs to accept a client token.

Client returns status ok for most of random API keys with length of 32

When I initialize dogapi with for example:

dogapi.initialize({
    api_key: "12123456789012345678901234567890",
    api_host: "api.datadoghq.eu"
})

Which is random API key with length of 32 chars, then it returns status: ok after calling dogapi.metric.send_all.

To make stuff more interesting, for api_key: 123456789012345678901234567890az it raises an error with "Forbidden" description.

For keys with api_key.length !== 32 it's always "Forbidden".

Is this expected behaviour due to limitations of DataDog API? It's a little bit confusing for me.

Add documentation about big numbers

I could have sworn I had written something in the readme about it, but apparently I didn't.

For reference for anyone finding this before I actually get around to adding it to the docs:

We ran into an issue #16 which is that number values returned from Datadog were larger than JSON could support, so there was lose of precision/overflowing for large numbers.

The solution was to utilize json-bigint which utilizes bignumber.js to support larger numbers in JSON.

The problem with this is that the format that bignumber.js stores numbers in isn't the most intuitive manner.

> var bn = require('bignumber.js');
> console.dir(new bn('2349082309420934834234234'));
{ s: 1, e: 24, c: [ 23490823094, 20934834234234 ] }

For information on how to interact with bignumber.js please see their documentation: https://www.npmjs.com/package/bignumber.js

Event 'id' loss of precision due to JSON.parse

Here is the output before JSON.parse(data) on line #100 of lib/api/client.js

{"status": "ok",
  "event": 
    {  "priority": null,
       "date_happened": 1435260251,
       "handle": null, "title": "Nimbus Sanity Test",
       "url": "https://app.datadoghq.com/event/event?id=2868860079149422351",
       "text": "Sanity Test Datadog",
       "tags": null,
       "related_event_id": null,
       "id": 2868860079149422351 }
}

After parsing:

{ status: 'ok',
  event: 
   { priority: null,
     date_happened: 1435260251,
     handle: null,
     title: 'Nimbus Sanity Test',
     url: 'https://app.datadoghq.com/event/event?id=2868860079149422351',
     text: 'Sanity Test Datadog',
     tags: null,
     related_event_id: null,
     id: 2868860079149422600 }
 }

using metric.send_all from EU region to US causing timeout 80% time

Using this librarys metric.send_all methos and sending metrics from Europe region to Datadog US site:
we get 20% success rate , 80% failures caused with timeout errors?
How can we increase timeout or add Header Connection: Keep-alive in our requests

2019-10-08T11:25:24.857Z 8d847170-26e0-42e2-a336-c7bd86fd1840 ERROR 1570533907242 'Failed send_all: Error: Client network socket disconnected before secure TLS connection was established Error: Client network socket disconnected before secure TLS connection was established\n at TLSSocket.onConnectEnd (_tls_wrap.js:1095:19)\n at Object.onceWrapper (events.js:286:20)\n at TLSSocket.emit (events.js:203:15)\n at TLSSocket.EventEmitter.emit (domain.js:448:20)\n at endReadableNT (_stream_readable.js:1145:12)\n at process._tickCallback (internal/process/next_tick.js:63:19)'

Weird format returned from the API

Getting the following points with the query API for a metrics query.

[[1460670060000,{"s":1,"e":0,"c":[8,6,6,6,6,6,6,9,8,4,5,5,8,1,0,5,5]}]]

Is this related to this lib?

await returns undefined

 const now = parseInt(new Date().getTime() / 1000);
  const then = now - 3600; // one hour ago
  const query = '';
  const response = await dogapi.metric.query(then, now, query);
  console.log(`response: ${response}`);
  return response;
};

it returns undefined

state object is missing when get a monitor using dogapi.monitor.getAll(..)

When I get a monitor I expect to have a state object in the response, the state includes information like the effected hosts from the alert.
dogapi.monitor.getAll(['alert'],(err, monitors) => {...

I expect:
"state": {"groups": {"host:data-tests-mongo-prod-mongo-127-conf-0": {"status": "OK", "last_triggered_ts": null, "last_nodata_ts": null, "name": "host:data-tests-mongo-prod-mongo-127-conf-0", "last_notified_ts": null, "last_resolved_ts": null}

but actually, I don't get the state object, the state object I'm showing above is from python datadog : https://github.com/DataDog/datadogpy

Any idea why it's missing?

Metrics Reporting is Broken?

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

update the client

the api has had a few changes since I wrote it, should probably do a full sweep and update to the latest.

XMLHttpRequest cannot load

Not sure if this is related to the api or my node setup, but I'm getting

XMLHttpRequest cannot load <link>. 
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access.

I've added this to my app already:

app.use(function (req, res, next) {
  // Website you wish to allow to connect
  res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8080');

  // Request methods you wish to allow
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');

  // Request headers you wish to allow
  res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');

  // Set to true if you need the website to include cookies in the requests sent
  // to the API (e.g. in case you use sessions)
  res.setHeader('Access-Control-Allow-Credentials', true);

  // Pass to next layer of middleware
  next();
});

I also tried running it through a proxy like in the example-

agent = new HttpsProxyAgent({
   proxyHost: "localhost",
   proxyPort: 8080
  });

but then I get
Error: (SystemJS) Node tls module not supported in browsers.

I think that may be a separate issue as I used JSPM to install https-proxy-agent for an angularjs app.

But overall how would I get it set up to not have the XMLHttpRequest error?

Update documentation for metrics send and send_all with all metric types

Right now documentation says, that for Metrics send_all and send functions, we can pick one of 2 metric types:
metric_type|type: the type of metric to use ("gauge" or "count") [default: gauge]
and it's no longer true.

Since DataDog supports metric type "rate" and this library doesn't do any type validation, "rate" metric type is correctly supported by those functions.

Documentation for Metrics send_all and send should be:
metric_type|type: the type of metric to use ("gauge", "count" or "rate") [default: gauge]

metric_type isn't doing anything?

dogapi.metric.send takes metric_type as extra parameter and documentation specifies it can be either "gauge" or "counter", but setting it to "counter" works exactly as setting it to "gauge" (i.e. it reports constant value to the datadog).

I don't see any mentions of metric type at all in the Datadog's HTTP API docs and official API libraries (e.g. datadogpy) rely on the statsd to implement counters.

Maybe this option is obsolete? Or am I missing something?

Thanks!

move from rc to run-con

The most popular fork of rc is currently run-con which is being maintained whereas rc has been deprecated. We should move to run-con

dogapi.metric.send_all sends points in wrong format.

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]].

Metrics not being sent

Hello there,

I've noticed that since updating to 1.0.0 metrics aren't being sent correctly and I'm getting no response back in my callbacks, and no metrics are being posted.

E.G

var dogapi = require('dogapi');
dogapi.initialize({
    api_key: this.config.keys.datadog.api,
    app_key: this.config.keys.datadog.app
  });
var metrics =  [{
        metric: 'loadTest.avg_response_time',
        points: [1431343811, 2834],
        tags: [ 'exampleTag:v1' ]
      },
      {
        metric: 'loadTest.avg_error_rate',
        points: [1431343811, 0],
        tags: [ 'exampleTag:v1' ]
      }];

dogapi.metric.send_all(metrics, function(err, res) {
    if (err) {
      return callback(new DataDogAPIError(err), res);
    }
    callback(false, res);
  });

I get an empty response back and no error ({ response: '' }). Comparitively If I use the REST endpoint:

curl -X POST -H "Content-type: application/json"
-d "{"series": [{
"metric": "loadTest.avg_response_time",
"points": [[1431342268, 2834], [1431342268, 2833]],
"tags": ["exampleTag:v1"]
}]}"
'https://app.datadoghq.com/api/v1/series?api_key=DD_API_KEY'

using postman I get the response
{ "status": "ok" }

share function in screenboard.js doesn't share the given board

in Screenboard.js the function share is not using the correct http method it should be "POST" instead of "GET"
as the current behavior wont actually share the given screen-board
function share(boardId, callback){
client.request("GET", util.format("/screen/share/%s", boardId), callback);
}
it should be
function share(boardId, callback){
client.request("POST", util.format("/screen/share/%s", boardId), callback);
}

`lodash@latest` can break projects using yarn

If lodash releases a major version that breaks any API changes that this repo relies on, consuming repos that use yarn will cause this library to break.

Could you please lock lodash to a specific version?

You will otherwise see an error message like the one below if using yarn and other dependencies that rely on lodash:

Pattern ["lodash@latest"] is trying to unpack in the same destination "~/Library/Caches/Yarn/v1/npm-lodash-4.17.5-99a92d65c0272debe8c96b6057bc8fbfa3bed511" as pattern ["lodash@^4.8.0","lodash@^4.8.0","lodash@^4.14.0","lodash@^4.8.0","lodash@^4.0.0","lodash@^4.13.1","lodash@^4.14.0","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.11.1","lodash@^4.17.4","lodash@^4.6.0","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.2.0","lodash@^4.2.0","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.17.4","lodash@^4.3.0","lodash@^4.17.4","lodash@^4.15.0","lodash@^4.2.0","lodash@^4.2.0","lodash@^4.2.0","lodash@^4.2.0","lodash@^4.2.0","lodash@^4.14.2","lodash@^4.17.5","lodash@^4.13.1","lodash@^4.8.0","lodash@^4.11.1","lodash@^4.17.4","lodash@^4.17.4"]. This could result in non-deterministic behavior, skipping.

Update Screenboard API

Screenboard API's create api in the library currently indicates that a 'graph' key should be passed in.

However http://docs.datadoghq.com/api/screenboards/ doesn't make a mention of the graph key.

Additionally it looks like the update method isn't supported on the Screenboard API though it shouldn't be hard to add.

I'm happy to open a pull request to add it if you're okay with it @brettlangdon

Memory leak

I'm experiencing a memory leak when using this library.
So far I've nailed it down to the use of V8Type . Have you seen similar issues in the past?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.