Datadog monitors StateChange
Certified
Start a flow when Datadog monitors change to an alerting state
Datadog monitors StateChange
Start a flow when Datadog monitors change to an alerting state
Polls the Datadog monitors and starts one execution with the monitors that entered one of the watched states since the previous poll. Needs the API key and an application key with the monitors_read scope.
A monitor is returned when its overall_state is one of states and its overall_state_modified is later than the previous poll, so a monitor that stays in alert is returned once, not at every poll. overall_state_modified has a precision of one second, so the trigger keeps in the namespace KV store the newest value returned and the monitors returned at that second: a monitor that changes in the same second as another one is not lost. The first poll only records the time (taken from the Datadog clock, from the Date header of its answer): monitors that were already alerting are not returned. A monitor that goes into alert and recovers between two polls is not seen, so keep interval shorter than the shortest outage you care about.
type: io.kestra.plugin.datadog.monitors.StateChangeExamples
React to production monitors that go into alert
id: datadog_on_alert
namespace: company.observability
triggers:
- id: on_alert
type: io.kestra.plugin.datadog.monitors.StateChange
apiKey: "{{ secret('DATADOG_API_KEY') }}"
appKey: "{{ secret('DATADOG_APP_KEY') }}"
monitorTags:
- "env:prod"
states:
- ALERT
interval: PT2M
tasks:
- id: log
type: io.kestra.plugin.core.log.Log
message: "{{ trigger.count }} production monitor(s) went into alert: {{ trigger.monitors | jq('map(.name)') | first }}"
Installation
Our standard Docker images already include this plugin. If you use a -slim image or another setup, install it with the following command:
kestractl plugins get io.kestra.plugin:plugin-datadog --compatible-for $KESTRA_VERSION For kestractl, use your Kestra version with --compatible-for, or specify an exact plugin version.
Properties
apiKey *string
Datadog API key
The organization API key. Use a Kestra secret, e.g. {{ secret('DATADOG_API_KEY') }}.
appKey *string
Datadog application key
An application key. Datadog asks for it on every call that reads data or manages monitors and downtimes, so the tasks that only send data (events.Create, metrics.Submit, logs.Send) work without it. Create it with the scopes the task needs. Use a Kestra secret, e.g. {{ secret('DATADOG_APP_KEY') }}. The trigger needs the monitors_read scope.
allowConcurrent boolean
falseSpecifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.
apiUrl string
API base URL
Replaces https://api.<site> when set, for a proxy, a private link or a test server. Leave it empty for the public API. logs.Send does not use it: it calls the log intake, which has its own address (intakeUrl).
interval string
PT5MdurationInterval between two polls
The time between two polls of the Datadog API. Five minutes by default.
maxMonitors integerstring
1000Maximum number of monitors per poll
Reads at most this many monitors from Datadog at each poll, between 1 and 10000. Narrow the filters when the organization has more monitors than this.
monitorTags array
Monitor tags filter
Watches the monitors that carry all these monitor tags, such as env: prod.
name string
Name filter
Watches the monitors whose name contains this text.
site string
Datadog site
The Datadog site of the organization, the domain you see in the Datadog URL: datadoghq.com (US1, the default), us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com or ddog-gov.com. A key only works on the site of the organization that created it.
states array
ALERTWARNNO_DATAOKIGNOREDSKIPPEDUNKNOWNStates to watch
The monitor states that start an execution. ALERT only when it is not set.
stopAfter array
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTEDList of execution states after which a trigger should be stopped (a.k.a. disabled).
when string
trueA condition that determines whether the trigger should run.
A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.
Outputs
count integer
Number of monitors
monitors array
Monitors
The monitors that changed state, from the oldest change to the newest. Use {{ trigger.monitors }}.