Giter VIP home page Giter VIP logo

deno-datadog_api's Introduction

Deno CI

/x/datadog_api: Deno library for Datadog

Very incomplete Typescript client for Datadog's API.

Purpose

My primary goal is to give important parts of the Datadog API a typed interface for use in Deno scripts. I'm comparing API docs with actual API payloads as much as possible. If you just want to make calls and get JSON back, you can use the datadog.fetchJson({...}) function.

PS: This library doesn't really depend on Deno APIs, it's just targetting Deno as a runtime (Typescript, URL imports, fetch, etc).

Implemented APIs

  • v1Dashboards: get by id, list all
  • v1Metrics: submit custom data series points to Datadog
    • For a working example of metrics submission, see examples/emit-metrics.ts
  • v1Monitors: get by id, get all, search by query
  • v1ServiceChecks: submit 'check run' statuses to Datadog
  • v1ServiceDependencies: list APM services and their dependencies
  • v1Events: submit events to Datadog
  • v1UsageMetering: get billable summary, get top custom metrics
  • v2Roles: list and describe roles & permissions
  • v2Users: list, search, and describe datadog users
  • v2Teams: list, search, and describe datadog teams

If you want a different API not listed here, please open a Github issue or PR into v1/ or v2/ as appropriate. In the meantime you can use fetchJson for such APIs.

Usage

Importing mod.ts gives you the whole implemented API surface.

import DatadogApi from "https://deno.land/x/datadog_api/mod.ts";

// Set up an API client using DATADOG_API_KEY and such
const datadog = DatadogApi.fromEnvironment(Deno.env);

// Optionally check that our API key works, without actually doing anything
await datadog.validateAccess();

// Perform a monitor search by tag
const {monitors} = await datadog.v1Monitors.search('env:"prod"');
console.log("First monitor:", monitors[0]);

// Or, directly fetch JSON (for using APIs that don't have functions yet)
const dashboardLists = await datadog.fetchJson({
  path: '/api/v2/dashboard/lists/manual',
});

Selective Imports

You can also import specific parts of this module by starting with client.ts and adding specific APIs from v1/ or v2/. This lets you skip downloading APIs you don't plan on using.

// Assemble an API client manually
import ApiClient from "https://deno.land/x/datadog_api/client.ts";
const datadog = new ApiClient({
  apiKey: Deno.env.get("DATADOG_API_KEY"),
  appKey: Deno.env.get("DATADOG_APP_KEY"),
  apiBase: Deno.env.get("DATADOG_HOST"), // defaults to US server
});

// Set up a Monitors API client
import V1MonitorsApi from "https://deno.land/x/datadog_api/v1/monitors.ts";
const monitorsApi = new V1MonitorsApi(datadog);

// Get a monitor
console.log(await monitorsApi.getOne("234231"));

License

MIT License

deno-datadog_api's People

Contributors

danopia avatar vandr0iy avatar rodmatos avatar

Watchers

 avatar

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.