Reputation: 2083
Is it possible to create DataDog alerts & notifications in IaC way via AWS CDK? I want to send notifications in case of any HTTP 500 errors my web service emits.
Upvotes: 2
Views: 2056
Reputation: 3452
You can use @goodnotes-oss/cdk-datadog-resources.
It's a fork of the library suggested by @miensol, but supports new Datadog Monitor versions (4.6.0) and cdk (v2).
Usage is similar. But now the credentials are configured at extension level.
import { DatadogMonitor } from '@nomadblacky/cdk-datadog-resources';
new DatadogMonitor(yourStack, 'TestMonitor', {
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,
},
});
Upvotes: 1
Reputation: 41648
You can use cdk-datadog-resources like so:
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,
},
});
Upvotes: 2