Skip to content

Commit

Permalink
Merge pull request #14 from NomadBlacky/add-monitor
Browse files Browse the repository at this point in the history
feat: Add Datadog::Monitors::Monitor resource
  • Loading branch information
Takumi Kadowaki authored Apr 27, 2021
2 parents ba632cb + 84bdb78 commit 04e8845
Show file tree
Hide file tree
Showing 15 changed files with 1,275 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/lib
/test-reports/
build/Release
cdk.out/
coverage
jspm_packages/
junit.xml
Expand Down
8 changes: 8 additions & 0 deletions .projen/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"name": "@typescript-eslint/parser",
"type": "build"
},
{
"name": "aws-cdk",
"type": "build"
},
{
"name": "eslint",
"type": "build"
Expand Down Expand Up @@ -89,6 +93,10 @@
"name": "typescript",
"type": "build"
},
{
"name": "camelcase-keys",
"type": "bundled"
},
{
"name": "@aws-cdk/core",
"version": "^1.95.2",
Expand Down
6 changes: 3 additions & 3 deletions .projenrc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 111 additions & 10 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@

Name|Description
----|-----------
[Hello](#nomadblacky-cdk-datadog-resources-hello)|*No description*
[DatadogMonitor](#nomadblacky-cdk-datadog-resources-datadogmonitor)|Datadog Monitor 3.0.0.


**Structs**

Name|Description
----|-----------
[DatadogCredentials](#nomadblacky-cdk-datadog-resources-datadogcredentials)|Credentials for the Datadog API.
[DatadogMonitorProps](#nomadblacky-cdk-datadog-resources-datadogmonitorprops)|*No description*
[MonitorOptions](#nomadblacky-cdk-datadog-resources-monitoroptions)|*No description*
[MonitorThresholdWindows](#nomadblacky-cdk-datadog-resources-monitorthresholdwindows)|*No description*
[MonitorThresholds](#nomadblacky-cdk-datadog-resources-monitorthresholds)|*No description*

## class Hello <a id="nomadblacky-cdk-datadog-resources-hello"></a>


## class DatadogMonitor <a id="nomadblacky-cdk-datadog-resources-datadogmonitor"></a>

Datadog Monitor 3.0.0.


### Initializer
Expand All @@ -19,25 +30,115 @@ Name|Description


```ts
new Hello()
new DatadogMonitor(scope: Construct, id: string, props: DatadogMonitorProps)
```

* **scope** (<code>[Construct](#aws-cdk-core-construct)</code>) *No description*
* **id** (<code>string</code>) *No description*
* **props** (<code>[DatadogMonitorProps](#nomadblacky-cdk-datadog-resources-datadogmonitorprops)</code>) *No description*
* **datadogCredentials** (<code>[DatadogCredentials](#nomadblacky-cdk-datadog-resources-datadogcredentials)</code>) Credentials for the Datadog API.
* **query** (<code>string</code>) The monitor query.
* **type** (<code>string</code>) The type of the monitor.
* **message** (<code>string</code>) A message to include with notifications for the monitor. __*Optional*__
* **multi** (<code>boolean</code>) Whether or not the monitor is multi alert. __*Optional*__
* **name** (<code>string</code>) Name of the monitor. __*Optional*__
* **options** (<code>[MonitorOptions](#nomadblacky-cdk-datadog-resources-monitoroptions)</code>) The monitor options. __*Optional*__
* **tags** (<code>Array<string></code>) Tags associated with the monitor. __*Optional*__


### Methods


#### sayHello() <a id="nomadblacky-cdk-datadog-resources-hello-sayhello"></a>
## struct DatadogCredentials <a id="nomadblacky-cdk-datadog-resources-datadogcredentials"></a>


Credentials for the Datadog API.



Name | Type | Description
-----|------|-------------
**apiKey** | <code>string</code> | Datadog API key.
**applicationKey** | <code>string</code> | Datadog application key.
**apiURL**? | <code>string</code> | Datadog API URL (defaults to https://api.datadoghq.com) Use https://api.datadoghq.eu for EU accounts.<br/>__*Optional*__



## struct DatadogMonitorProps <a id="nomadblacky-cdk-datadog-resources-datadogmonitorprops"></a>






Name | Type | Description
-----|------|-------------
**datadogCredentials** | <code>[DatadogCredentials](#nomadblacky-cdk-datadog-resources-datadogcredentials)</code> | Credentials for the Datadog API.
**query** | <code>string</code> | The monitor query.
**type** | <code>string</code> | The type of the monitor.
**message**? | <code>string</code> | A message to include with notifications for the monitor.<br/>__*Optional*__
**multi**? | <code>boolean</code> | Whether or not the monitor is multi alert.<br/>__*Optional*__
**name**? | <code>string</code> | Name of the monitor.<br/>__*Optional*__
**options**? | <code>[MonitorOptions](#nomadblacky-cdk-datadog-resources-monitoroptions)</code> | The monitor options.<br/>__*Optional*__
**tags**? | <code>Array<string></code> | Tags associated with the monitor.<br/>__*Optional*__



## struct MonitorOptions <a id="nomadblacky-cdk-datadog-resources-monitoroptions"></a>






Name | Type | Description
-----|------|-------------
**enableLogsSample**? | <code>boolean</code> | Whether or not to include a sample of the logs.<br/>__*Optional*__
**escalationMessage**? | <code>string</code> | Message to include with a re-notification when renotify_interval is set.<br/>__*Optional*__
**evaluationDelay**? | <code>number</code> | Time in seconds to delay evaluation.<br/>__*Optional*__
**includeTags**? | <code>boolean</code> | Whether or not to include triggering tags into notification title.<br/>__*Optional*__
**locked**? | <code>boolean</code> | Whether or not changes to this monitor should be restricted to the creator or admins.<br/>__*Optional*__
**minLocationFailed**? | <code>number</code> | Number of locations allowed to fail before triggering alert.<br/>__*Optional*__
**newHostDelay**? | <code>number</code> | Time in seconds to allow a host to start reporting data before starting the evaluation of monitor results.<br/>__*Optional*__
**noDataTimeframe**? | <code>number</code> | Number of minutes data stopped reporting before notifying.<br/>__*Optional*__
**notifyAudit**? | <code>boolean</code> | Whether or not to notify tagged users when changes are made to the monitor.<br/>__*Optional*__
**notifyNoData**? | <code>boolean</code> | Whether or not to notify when data stops reporting.<br/>__*Optional*__
**renotifyInterval**? | <code>number</code> | Number of minutes after the last notification before the monitor re-notifies on the current status.<br/>__*Optional*__
**requireFullWindow**? | <code>boolean</code> | Whether or not the monitor requires a full window of data before it is evaluated.<br/>__*Optional*__
**syntheticsCheckID**? | <code>number</code> | ID of the corresponding synthetics check.<br/>__*Optional*__
**thresholdWindows**? | <code>[MonitorThresholdWindows](#nomadblacky-cdk-datadog-resources-monitorthresholdwindows)</code> | The threshold window definitions.<br/>__*Optional*__
**thresholds**? | <code>[MonitorThresholds](#nomadblacky-cdk-datadog-resources-monitorthresholds)</code> | The threshold definitions.<br/>__*Optional*__
**timeoutH**? | <code>number</code> | Number of hours of the monitor not reporting data before it automatically resolves.<br/>__*Optional*__



## struct MonitorThresholdWindows <a id="nomadblacky-cdk-datadog-resources-monitorthresholdwindows"></a>






Name | Type | Description
-----|------|-------------
**recoveryWindow**? | <code>string</code> | How long an anomalous metric must be normal before recovering from an alert state.<br/>__*Optional*__
**triggerWindow**? | <code>string</code> | How long a metric must be anomalous before triggering an alert.<br/>__*Optional*__



## struct MonitorThresholds <a id="nomadblacky-cdk-datadog-resources-monitorthresholds"></a>




```ts
sayHello(): string
```


__Returns__:
* <code>string</code>
Name | Type | Description
-----|------|-------------
**critical**? | <code>number</code> | Threshold value for triggering an alert.<br/>__*Optional*__
**criticalRecovery**? | <code>number</code> | Threshold value for recovering from an alert state.<br/>__*Optional*__
**oK**? | <code>number</code> | Threshold value for recovering from an alert state.<br/>__*Optional*__
**warning**? | <code>number</code> | Threshold value for triggering a warning.<br/>__*Optional*__
**warningRecovery**? | <code>number</code> | Threshold value for recovering from a warning state.<br/>__*Optional*__



72 changes: 71 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,71 @@
# replace this
# AWS CDK Datadog Resources

An AWS CDK construct library that wrapped [DataDog/datadog-cloudformation-resources](https://github.com/DataDog/datadog-cloudformation-resources).

## Requirements

Before use this library, [register datadog-cloudformation-resources to your AWS account.](https://github.com/DataDog/datadog-cloudformation-resources#datadog-aws-cloudformation)

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

## Supported CDK Languages

- TypeScript

## Supported Resources

| Supported? | Resource | Name | Description | Datadog CF Version |
| :--------: | ----------------------- | -------------------------------- | -------------------------------------------------------- | ------------------ |
| | Dashboards | `Datadog::Dashboards::Dashboard` | [Create, update, and delete Datadog dashboards.][1] | N/A |
| | Datadog-AWS integration | `Datadog::Integrations::AWS` | [Manage your Datadog-Amazon Web Service integration.][2] | N/A |
|| Monitors | `Datadog::Monitors::Monitor` | [Create, update, and delete Datadog monitors.][3] | [3.0.0][6] |
| | Downtimes | `Datadog::Monitors::Downtime` | [Enable or disable downtimes for your monitors.][4] | N/A |
| | User | `Datadog::IAM::User` | [ Create and manage Datadog users.][5] | N/A |

## Installation

TypeScript

```shell
npm install --save-dev @nomadblacky/cdk-datadog-resources
```

## Usage

Belows are examples of TypeScript.

### Monitors

```typescript
import { App, Stack } from '@aws-cdk/core';
import { DatadogMonitor } from '@nomadblacky/cdk-datadog-resources';

const app = new App();
const stack = new Stack(app, 'CdkDatadogResourcesTestStack');

new DatadogMonitor(stack, 'TestMonitor', {
datadogCredentials: {
apiKey: process.env.DATADOG_API_KEY || 'DATADOG_API_KEY',
applicationKey: process.env.DATADOG_APP_KEY || '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,
},
});
```

[1]: https://github.com/DataDog/datadog-cloudformation-resources/tree/master/datadog-dashboards-dashboard-handler
[2]: https://github.com/DataDog/datadog-cloudformation-resources/tree/master/datadog-integrations-aws-handler
[3]: https://github.com/DataDog/datadog-cloudformation-resources/tree/master/datadog-monitors-monitor-handler
[4]: https://github.com/DataDog/datadog-cloudformation-resources/tree/master/datadog-monitors-downtime-handler
[5]: https://github.com/DataDog/datadog-cloudformation-resources/tree/master/datadog-iam-user-handler
[6]: https://github.com/DataDog/datadog-cloudformation-resources/blob/master/datadog-monitors-monitor-handler/CHANGELOG.md#300--2021-02-16
Loading

0 comments on commit 04e8845

Please sign in to comment.