Giter VIP home page Giter VIP logo

cdk-datadog-resources's Introduction

AWS CDK Datadog Resources

npm version

An AWS CDK construct library that wraps DataDog/datadog-cloudformation-resources.

Requirements

Before using this library, register datadog-cloudformation-resources to your AWS account.

You need to register the correct version listed in Supported Resources.

Supported CDK Languages

  • TypeScript
  • Python
  • Java Sorry, there is a problem with the release. (#22)

Supported Resources

Supported? Resource Datadog CF Resource Name Description Datadog CF Version
Dashboards Datadog::Dashboards::Dashboard Create, update, and delete Datadog dashboards. 1.0.0
Datadog-AWS integration Datadog::Integrations::AWS Manage your Datadog-Amazon Web Service integration. 1.1.0
Monitors Datadog::Monitors::Monitor Create, update, and delete Datadog monitors. 3.0.0
Downtimes Datadog::Monitors::Downtime Enable or disable downtimes for your monitors. 2.0.0
Users Datadog::IAM::User Create and manage Datadog users. 1.2.0

Installation

TypeScript

npm install @nomadblacky/cdk-datadog-resources

Python

pip install cdk-datadog-resources

Java

<dependency>
    <groupId>dev.nomadblacky</groupId>
    <artifactId>cdk-datadog-resources</artifactId>
    <version>x.y.z</version>
</dependency>

Usage

Below are examples of TypeScript.

Dashboards

import * as fs from 'fs';
import { DatadogDashboard } from '@nomadblacky/cdk-datadog-resources';

new DatadogDashboard(yourStack, 'TestDashboard', {
  datadogCredentials: {
    apiKey: process.env.DATADOG_API_KEY!,
    applicationKey: process.env.DATADOG_APP_KEY!,
  },
  dashboardDefinition: fs.readFileSync(`${__dirname}/path/to/your/dashboard-definition.json`).toString(),
});

Monitors

import { DatadogMonitor } from '@nomadblacky/cdk-datadog-resources';

new DatadogMonitor(yourStack, 'TestMonitor', {
  datadogCredentials: {
    apiKey: process.env.DATADOG_API_KEY!,
    applicationKey: process.env.DATADOG_APP_KEY!,
  },
  query: 'avg(last_1h):sum:system.cpu.system{host:host0} > 100',
  type: MonitorType.QueryAlert,
  name: 'Test Monitor',
  options: {
    thresholds: {
      critical: 100,
      warning: 80,
      oK: 90,
    },
    notifyNoData: true,
    evaluationDelay: 60,
  },
});

Downtimes

import { DatadogDowntime } from '@nomadblacky/cdk-datadog-resources';

new DatadogDowntime(stack, 'TestMonitor', {
  datadogCredentials: {
    apiKey: 'DATADOG_API_KEY',
    applicationKey: 'DATADOG_APP_KEY',
  },
  scope: ['host:myserver', 'service:myservice'],
  start: 1624542715,
  end: 1624546321,
});

Users

import { DatadogIAMUser } from '@nomadblacky/cdk-datadog-resources';

new DatadogIAMUser(stack, 'TestUser', {
  datadogCredentials: {
    apiKey: 'DATADOG_API_KEY',
    applicationKey: 'DATADOG_APP_KEY',
  },
  email: '[email protected]',
  name: 'name_example',
  handle: 'title_example',
  disabled: false,
});

DataDog Integration

import { DatadogIntegrationAWS } from '@nomadblacky/cdk-datadog-resources';

new DatadogIntegrationAWS(this, 'DataDogIntegration', {
  datadogCredentials: {
    apiKey: "DATADOG_API_KEY",
    applicationKey: "DATADOG_APP_KEY",
  },
  accountId: "ACCOUNT_ID",
  roleName: "DatadogIntegrationRole",
});

cdk-datadog-resources's People

Contributors

dependabot[bot] avatar frankwese avatar github-actions[bot] avatar nomadblacky avatar phrawzty avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

cdk-datadog-resources's Issues

DatadogCredentials should not be mandatory in Monitors

DatadogCredentials should not be mandatory in monitors, and possibly elsewhere.

CloudFormation extensions can define a JSON block that is "injected" into stacks, and that can refer to the secrets. The Datadog configuration schema does indeed do this:

image

eg, once this is defined in the AWS console, then credentials are not needed to be in the stack.

{
 "DatadogCredentials": {
   "ApiKey": "{{resolve:secretsmanager:datadog-cloudformation-extensions:SecretString:api-key}}",
   "ApplicationKey": "{{resolve:secretsmanager:datadog-cloudformation-extensions:SecretString:application-key}}",
   "ApiURL": "https://api.datadoghq.eu"
 }

Upgrade constructs dependency

I would love to use this library. Love the idea of being able to setup Datadog monitors in AWS CDK code.

In my current project, I'm using more recent "aws-cdk"@ "2.46.0" as dependency. Unfortunately, this leads to dependency conflicts.

"aws-cdk" is already on "constructs": "10.1.133"
cdk-datadog-resources still relies on constructs@"^3.2.27"

Any plans to upgrade?
(--legacy-peer-deps does not solve the issue as there are real incompatibilies involved.)

AWS-CDK v2 support

I would really love to use this project but I use AWS-CDK V2 for new projects.

Would it be thinkable to support it?

Can't reference properties of `DatadogMonitor` (ID, creator and etc.)

A CDK application should be able to reference the properties of DatadogMonior.
For example, when want to display the id of the created monitor.

const stack = new Stack();

const monitor = new DatadogMonitor(stack, 'TestMonitor', {
  datadogCredentials: {
    apiKey: 'DATADOG_API_KEY',
    applicationKey: 'DATADOG_APP_KEY',
  },
  query: 'avg(last_1h):sum:system.cpu.system{host:host0} > 100',
  type: 'query alert',
  name: 'Test Monitor',
  options: {
    thresholds: {
      critical: 100,
      warning: 80,
      oK: 90,
    },
    notifyNoData: true,
    evaluationDelay: 60,
  },
});
  
new CfnOutput(stack, 'OutputTestMonitorId', {
  value: monitor.monitorId,
});

The required properties are here.

Fail to create `Datadog::Monitors::Downtime` v3.0.0

I tried to create Datadog::Monitors::Downtime v3.0.0 but it failed with the following error.

0:27:21 | CREATE_FAILED        | Datadog::Monitors::Downtime    | TestDowntime
Properties validation failed for resource TestDowntime with message:
#: extraneous key [DatadogCredentials] is not permitted

schema

source
import { CfnResource, Construct } from '@aws-cdk/core';
import * as camelcaseKeys from 'camelcase-keys';
import { DatadogCredentials } from '../common/properties';

export interface DatadogDowntimeProps {
  /** Credentials for the Datadog API */
  readonly datadogCredentials: DatadogCredentials;

  /** Whether or not this downtime is currently active */
  readonly active?: boolean;

  /** POSIX Timestamp of cancellation of this downtime (null if not canceled) */
  readonly canceled?: number;

  /** Id of the user who created this downtime */
  readonly creatorId?: number;

  /** Whether or not this downtime is disabled */
  readonly disabled?: boolean;

  /** Type of this downtime */
  readonly downtimeType?: number;

  /** POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely (i.e. until you cancel it). */
  readonly end?: number;

  /** Id of this downtime */
  readonly id?: number;

  /** Message on the downtime */
  readonly message?: string;

  /** A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors. */
  readonly monitorId?: number;

  /** A comma-separated list of monitor tags, to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. */
  readonly monitorTags?: string[];

  /** The ID of the parent downtime to this one */
  readonly parentId?: number;

  /** The scope(s) to which the downtime applies */
  readonly scope: string[];

  /** POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created. */
  readonly start?: number;

  /** The timezone for the downtime */
  readonly timezone?: string;

  /** Id of the user who updated this downtime */
  readonly updaterId?: number;
}

/**
 * Datadog Monitor Downtime 3.0.0
 */
export class DatadogDowntime {
  constructor(scope: Construct, id: string, props: DatadogDowntimeProps) {
    const cfnProperties = camelcaseKeys(props, {
      deep: true,
      pascalCase: true,
    });
    new CfnResource(scope, id, {
      type: 'Datadog::Monitors::Downtime',
      properties: { ...cfnProperties },
    });
  }
}

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.