diff --git a/API.md b/API.md index 12e8c16..7727d78 100644 --- a/API.md +++ b/API.md @@ -18,6 +18,13 @@ Name|Description [MonitorThresholds](#nomadblacky-cdk-datadog-resources-monitorthresholds)|*No description* +**Enums** + +Name|Description +----|----------- +[MonitorType](#nomadblacky-cdk-datadog-resources-monitortype)|The type of the monitor. + + ## class DatadogMonitor @@ -38,7 +45,7 @@ new DatadogMonitor(scope: Construct, id: string, props: DatadogMonitorProps) * **props** ([DatadogMonitorProps](#nomadblacky-cdk-datadog-resources-datadogmonitorprops)) *No description* * **datadogCredentials** ([DatadogCredentials](#nomadblacky-cdk-datadog-resources-datadogcredentials)) Credentials for the Datadog API. * **query** (string) The monitor query. - * **type** (string) The type of the monitor. + * **type** ([MonitorType](#nomadblacky-cdk-datadog-resources-monitortype)) The type of the monitor. * **message** (string) A message to include with notifications for the monitor. __*Optional*__ * **multi** (boolean) Whether or not the monitor is multi alert. __*Optional*__ * **name** (string) Name of the monitor. __*Optional*__ @@ -74,7 +81,7 @@ Name | Type | Description -----|------|------------- **datadogCredentials** | [DatadogCredentials](#nomadblacky-cdk-datadog-resources-datadogcredentials) | Credentials for the Datadog API. **query** | string | The monitor query. -**type** | string | The type of the monitor. +**type** | [MonitorType](#nomadblacky-cdk-datadog-resources-monitortype) | The type of the monitor. **message**? | string | A message to include with notifications for the monitor.
__*Optional*__ **multi**? | boolean | Whether or not the monitor is multi alert.
__*Optional*__ **name**? | string | Name of the monitor.
__*Optional*__ @@ -142,3 +149,20 @@ Name | Type | Description +## enum MonitorType + +The type of the monitor. + +Name | Description +-----|----- +**COMPOSITE** | +**EVENT_ALERT** | +**LOG_ALERT** | +**METRIC_ALERT** | +**PROCESS_ALERT** | +**QUERY_ALERT** | +**SERVICE_CHECK** | +**SYNTHETICS_ALERT** | +**TRACE_ANALYTICS_ALERT** | + + diff --git a/README.md b/README.md index 5372449..3b771c1 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ new DatadogMonitor(stack, 'TestMonitor', { applicationKey: process.env.DATADOG_APP_KEY || 'DATADOG_APP_KEY', }, query: 'avg(last_1h):sum:system.cpu.system{host:host0} > 100', - type: 'query alert', + type: MonitorType.QueryAlert, name: 'Test Monitor', options: { thresholds: { diff --git a/src/cdk-app.ts b/src/cdk-app.ts index 7c26ea0..77a53af 100644 --- a/src/cdk-app.ts +++ b/src/cdk-app.ts @@ -1,5 +1,6 @@ import { App, Stack } from '@aws-cdk/core'; import { DatadogMonitor } from './monitors/datadog-monitor'; +import { MonitorType } from './monitors/properties'; const app = new App(); const stack = new Stack(app, 'CdkDatadogResourcesTestStack'); @@ -10,7 +11,7 @@ new DatadogMonitor(stack, 'TestMonitor', { applicationKey: process.env.DATADOG_APP_KEY || 'DATADOG_APP_KEY', }, query: 'avg(last_1h):sum:system.cpu.system{host:host0} > 100', - type: 'query alert', + type: MonitorType.QUERY_ALERT, name: 'Test Monitor', options: { thresholds: { diff --git a/src/monitors/properties.ts b/src/monitors/properties.ts index 48e4eca..b5a5c07 100644 --- a/src/monitors/properties.ts +++ b/src/monitors/properties.ts @@ -10,16 +10,20 @@ export interface DatadogCredentials { readonly apiURL?: string; } -export type MonitorType = - | 'composite' - | 'event alert' - | 'log alert' - | 'metric alert' - | 'process alert' - | 'query alert' - | 'service check' - | 'synthetics alert' - | 'trace-analytics alert'; +/** + * The type of the monitor + */ +export enum MonitorType { + COMPOSITE = 'composite', + EVENT_ALERT = 'event alert', + LOG_ALERT = 'log alert', + METRIC_ALERT = 'metric alert', + PROCESS_ALERT = 'process alert', + QUERY_ALERT = 'query alert', + SERVICE_CHECK = 'service check', + SYNTHETICS_ALERT = 'synthetics alert', + TRACE_ANALYTICS_ALERT = 'trace-analytics alert', +} export interface MonitorOptions { /** Whether or not to include a sample of the logs */ diff --git a/test/monitors/datadog-monitor.test.ts b/test/monitors/datadog-monitor.test.ts index c6f7047..312933e 100644 --- a/test/monitors/datadog-monitor.test.ts +++ b/test/monitors/datadog-monitor.test.ts @@ -1,6 +1,6 @@ import { SynthUtils } from '@aws-cdk/assert'; import { Stack } from '@aws-cdk/core'; -import { DatadogMonitor } from '../../src'; +import { DatadogMonitor, MonitorType } from '../../src'; test('Snapshot test', () => { const stack = new Stack(); @@ -11,7 +11,7 @@ test('Snapshot test', () => { applicationKey: 'DATADOG_APP_KEY', }, query: 'avg(last_1h):sum:system.cpu.system{host:host0} > 100', - type: 'query alert', + type: MonitorType.QUERY_ALERT, name: 'Test Monitor', options: { thresholds: {