Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
The dogapi npm package is a client library for interacting with the Datadog API. It allows developers to programmatically manage Datadog resources such as events, metrics, tags, and more.
Send Metrics
This feature allows you to send custom metrics to Datadog. The code sample demonstrates how to initialize the dogapi client and send a metric named 'test.metric' with a value of 100 and a tag 'environment:test'.
const dogapi = require('dogapi');
const options = { api_key: 'YOUR_API_KEY', app_key: 'YOUR_APP_KEY' };
dogapi.initialize(options);
dogapi.metric.send('test.metric', 100, { tags: ['environment:test'] }, function(err, results) {
if (err) console.error(err);
else console.log(results);
});
Post Events
This feature allows you to post events to Datadog. The code sample shows how to create an event with a title 'Event Title' and text 'Event Text', along with a tag 'environment:test'.
const dogapi = require('dogapi');
const options = { api_key: 'YOUR_API_KEY', app_key: 'YOUR_APP_KEY' };
dogapi.initialize(options);
dogapi.event.create('Event Title', 'Event Text', { tags: ['environment:test'] }, function(err, results) {
if (err) console.error(err);
else console.log(results);
});
Manage Tags
This feature allows you to manage tags for your Datadog resources. The code sample demonstrates how to add tags 'tag1' and 'tag2' to a host named 'myhost'.
const dogapi = require('dogapi');
const options = { api_key: 'YOUR_API_KEY', app_key: 'YOUR_APP_KEY' };
dogapi.initialize(options);
dogapi.tag.create('host:myhost', ['tag1', 'tag2'], function(err, results) {
if (err) console.error(err);
else console.log(results);
});
The datadog-metrics package is another client library for sending metrics to Datadog. It is simpler and more focused on metrics compared to dogapi, which offers a broader range of functionalities including events and tags management.
The node-dogstatsd package is a client for DogStatsD, which is Datadog's implementation of the StatsD protocol. It is used for sending metrics and events to Datadog, similar to dogapi, but it is more specialized for DogStatsD.
Datadog API Node.JS Client.
Official Datadog API Documentation: http://docs.datadoghq.com/api/
dogapi API Docs: http://brettlangdon.github.io/node-dogapi/
dogapi
does not provide any functionality to talk to a local dogstatsd
server.
This library is purely an interface to the HTTP api.
If you are looking for a good Datadog StatsD library, I recommend checking out node-dogstatsd.
From NPM:
[sudo] npm install dogapi
From source:
git clone git://github.com/brettlangdon/node-dogapi.git
cd ./node-dogapi
npm install
You will need your Datadog api key as well as an application key to use dogapi
.
Keys can be found at: https://app.datadoghq.com/account/settings#api
var dogapi = require("dogapi");
var options = {
api_key: "YOUR_KEY_HERE",
app_key: "YOUR_KEY_HERE",
// if you are on the Datadog EU site, you need to overwrite the default value of api_host key:
// api_host: "app.datadoghq.eu"
};
dogapi.initialize(options);
If you are behind a proxy you need to a proxy agent. You can use the https proxy agent from http://blog.vanamco.com/proxy-requests-in-node-js/ if you like. To configure dogapi with the agent just add it to the options.
var dogapi = require("dogapi");
//Code from http://blog.vanamco.com/proxy-requests-in-node-js/
var HttpsProxyAgent = require("./httpsproxyagent");
var agent = new HttpsProxyAgent({
proxyHost: "MY_PROXY_HOST",
proxyPort: 3128
});
var options = {
api_key: "YOUR_KEY_HERE",
app_key: "YOUR_KEY_HERE",
proxy_agent: agent
};
dogapi.initialize(options);
dogapi
now ships with a command line interface dogapi
. To use it you
will need a .dogapirc
file which meets the standards of
https://github.com/dominictarr/rc
The config file must contain both api_key
and app_key
keys (you can find
your datadog api and app keys here
https://app.datadoghq.com/account/settings#api)
Example:
{
"api_key": "<API_KEY>",
"app_key": "<APP_KEY>"
}
Please run dogapi --help
to see current usage documentation for the tool.
Every api method available in dogapi
is exposed via the cli tool.
We have updated major versions for this library due to a backwards incompatible change to the argument format for dogapi.metric.send
and dogapi.metric.send_all
.
Previously in 1.x.x
:
var now = parseInt(new Date().getTime() / 1000);
dogapi.metric.send("metric.name", 50);
dogapi.metric.send("metric.name", [now, 50]);
Now in 2.x.x
:
var now = parseInt(new Date().getTime() / 1000);
dogapi.metric.send("metric.name", 50);
dogapi.metric.send("metric.name", [50, 100]);
dogapi.metric.send("metric.name", [[now, 50]]);
Previously in 1.x.x
:
var now = parseInt(new Date().getTime() / 1000);
var metrics = [
{
metric: "metric.name",
points: [now, 50]
},
{
metric: "metric.name",
points: 50
}
];
dogapi.metric.send_all(metrics);
Now in 2.x.x
:
var now = parseInt(new Date().getTime() / 1000);
var metrics = [
{
metric: "metric.name",
points: [[now, 50]]
},
{
metric: "metric.name",
points: [50, 100]
},
{
metric: "metric.name",
points: 50
}
];
dogapi.metric.send_all(metrics);
The MIT License (MIT) Copyright (c) 2013 Brett Langdon me@brett.is
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Datadog API Node.JS Client
The npm package dogapi receives a total of 476,539 weekly downloads. As such, dogapi popularity was classified as popular.
We found that dogapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.