Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@datadog/datadog-api-client
Advanced tools
@datadog/datadog-api-client is an official Node.js client library for interacting with the Datadog API. It allows developers to programmatically manage and interact with Datadog's monitoring, logging, and tracing services. This includes creating and managing dashboards, monitors, events, and more.
Create a Dashboard
This code sample demonstrates how to create a new dashboard in Datadog using the @datadog/datadog-api-client package.
const { v1: datadog } = require('@datadog/datadog-api-client');
const configuration = datadog.createConfiguration();
const apiInstance = new datadog.DashboardsApi(configuration);
const params = {
body: {
title: 'Example-Dashboard',
widgets: [],
layoutType: 'ordered',
description: 'A sample dashboard',
isReadOnly: false,
notifyList: []
}
};
apiInstance.createDashboard(params).then((data) => {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}).catch((error) => {
console.error(error);
});
Create a Monitor
This code sample demonstrates how to create a new monitor in Datadog using the @datadog/datadog-api-client package.
const { v1: datadog } = require('@datadog/datadog-api-client');
const configuration = datadog.createConfiguration();
const apiInstance = new datadog.MonitorsApi(configuration);
const params = {
body: {
name: 'Example-Monitor',
type: 'metric alert',
query: 'avg(last_5m):avg:system.cpu.user{host:host0} > 75',
message: 'CPU usage is high on host0',
tags: ['env:production'],
options: {
thresholds: {
critical: 75
}
}
}
};
apiInstance.createMonitor(params).then((data) => {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}).catch((error) => {
console.error(error);
});
Post an Event
This code sample demonstrates how to post a new event to Datadog using the @datadog/datadog-api-client package.
const { v1: datadog } = require('@datadog/datadog-api-client');
const configuration = datadog.createConfiguration();
const apiInstance = new datadog.EventsApi(configuration);
const params = {
body: {
title: 'Example-Event',
text: 'An example event for Datadog',
tags: ['env:production'],
alertType: 'info'
}
};
apiInstance.createEvent(params).then((data) => {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}).catch((error) => {
console.error(error);
});
The 'newrelic' package is the official Node.js client for New Relic, a competitor to Datadog. It provides similar functionalities for monitoring and managing application performance, but is specific to New Relic's ecosystem.
The 'prom-client' package is a client for Prometheus, an open-source monitoring and alerting toolkit. While it doesn't offer the same breadth of features as Datadog, it is widely used for metrics collection and monitoring in cloud-native environments.
The 'elastic-apm-node' package is the official Node.js agent for Elastic APM, part of the Elastic Stack. It provides performance monitoring and error tracking for Node.js applications, similar to Datadog's APM features.
This repository contains a Node.js API client for the Datadog API. The code is generated using openapi-generator and apigentools.
The package is under @datadog/datadog-api-client and can be installed through NPM or Yarn:
# NPM
npm install @datadog/datadog-api-client
# Yarn
yarn add @datadog/datadog-api-client
Here's an example getting a monitor:
import { v1 } from 'datadog-api-client';
import * as fs from 'fs';
const configuration = v1.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);
let params:v1.MonitorsApiGetMonitorRequest = {
// number | The ID of the monitor
monitorId: 1,
// string | When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`. (optional)
groupStates: "group_states_example",
};
apiInstance.getMonitor(params).then((data:any) => {
console.log('API called successfully. Returned data: ' + data);
}).catch((error:any) => console.error(error));
Documentation for API endpoints can be found under the docs subdirectories, in v1 and v2.
As most of the code in this repository is generated, we will only accept PRs for files that are not modified by our code-generation machinery (changes to the generated files would get overwritten). We happily accept contributions to files that are not autogenerated, such as tests and development tooling.
FAQs
OpenAPI client for Datadog APIs
We found that @datadog/datadog-api-client demonstrated a healthy version release cadence and project activity because the last version was released less than 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.