Skip to main content

monitors

Creates, updates, deletes, gets or lists a monitors resource.

Overview

Namemonitors
TypeResource
Iddatadog.monitoring.monitors

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idinteger (int64)ID of this monitor.
namestringThe monitor name. (example: My monitor)
assetsarrayThe list of monitor assets tied to a monitor, which represents key links for users to take action on monitor alerts (for example, runbooks).
createdstring (date-time)Timestamp of the monitor creation.
creatorobjectObject describing the creator of the shared element.
deletedstring (date-time)Whether or not the monitor is deleted. (Always null)
draft_statusstringIndicates whether the monitor is in a draft or published state. draft: The monitor appears as Draft and does not send notifications. published: The monitor is active and evaluates conditions and notify as configured. This field is in preview. The draft value is only available to customers with the feature enabled. (draft, published) (default: published)
matching_downtimesarrayA list of active v1 downtimes that match this monitor.
messagestringA message to include with notifications for this monitor.
modifiedstring (date-time)Last timestamp when the monitor was edited.
multibooleanWhether or not the monitor is broken down on different groups.
optionsobjectList of options associated with your monitor.
overall_statestringThe different states your monitor can be in. (Alert, Ignored, No Data, OK, Skipped, Unknown, Warn)
priorityinteger (int64)Integer from 1 (high) to 5 (low) indicating alert severity.
querystringThe monitor query. (example: avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100)
restricted_rolesarrayA list of unique role identifiers to define which roles are allowed to edit the monitor. The unique identifiers for all roles can be pulled from the [Roles API](https:​//docs.datadoghq.com/api/latest/roles/#list-roles) and are located in the data.id field. Editing a monitor includes any updates to the monitor configuration, monitor deletion, and muting of the monitor for any amount of time. You can use the [Restriction Policies API](https:​//docs.datadoghq.com/api/latest/restriction-policies/) to manage write authorization for individual monitors by teams and users, in addition to roles.
stateobjectWrapper object with the different monitor states.
tagsarrayTags associated to your monitor.
typestringThe type of the monitor. For more information about type, see the [monitor options](https:​//docs.datadoghq.com/monitors/guide/monitor_api_options/) docs. (composite, event alert, log alert, metric alert, process alert, query alert, rum alert, service check, synthetics alert, trace-analytics alert, slo alert, event-v2 alert, audit alert, ci-pipelines alert, ci-tests alert, error-tracking alert, database-monitoring alert, network-performance alert, cost alert, data-quality alert, network-path alert, data-jobs alert, llm-observability alert) (example: query alert)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_monitorselectmonitor_idgroup_states, with_downtimes, with_assetsGet details about the specified monitor from your organization.
list_monitorsselectgroup_states, name, tags, monitor_tags, with_downtimes, id_offset, page, page_sizeGet all monitors from your organization.
check_can_delete_monitorselectmonitor_idsCheck if the given monitors can be deleted.
create_monitorinserttype, queryCreate a monitor using the specified options.<br /><br />#### Monitor Types<br /><br />The type of monitor chosen from:<br /><br />- anomaly: query alert<br />- APM: query alert or trace-analytics alert<br />- composite: composite<br />- custom: service check<br />- forecast: query alert<br />- host: service check<br />- integration: query alert or service check<br />- live process: process alert<br />- logs: log alert<br />- metric: query alert<br />- network: service check<br />- outlier: query alert<br />- process: service check<br />- rum: rum alert<br />- SLO: slo alert<br />- watchdog: event-v2 alert<br />- event-v2: event-v2 alert<br />- audit: audit alert<br />- error-tracking: error-tracking alert<br />- database-monitoring: database-monitoring alert<br />- network-performance: network-performance alert<br />- cloud cost: cost alert<br />- network-path: network-path alert<br /><br />Notes:<br />- Synthetic monitors are created through the Synthetics API. See the [Synthetics API](https:​//docs.datadoghq.com/api/latest/synthetics/) documentation for more information.<br />- Log monitors require an unscoped App Key.<br /><br />#### Query Types<br /><br />##### Metric Alert Query<br /><br />Example: time_aggr(time_window):space_aggr:metric&#123;tags&#125; &#91;by &#123;key&#125;&#93; operator #<br /><br />- time_aggr: avg, sum, max, min, change, or pct_change<br />- time_window: last_#m (with # between 1 and 10080 depending on the monitor type) or last_#h(with # between 1 and 168 depending on the monitor type) or last_1d, or last_1w<br />- space_aggr: avg, sum, min, or max<br />- tags: one or more tags (comma-separated), or <br />- key: a 'key' in key:value tag syntax; defines a separate alert for each tag in the group (multi-alert)<br />- operator: <, <=, >, >=, ==, or !=<br />- #: an integer or decimal number used to set the threshold<br /><br />To use a dynamic threshold on a metric monitor with a formula query, replace # with the threshold keyword<br />(for example, ... &gt; threshold) and provide the threshold as a query via critical_query on options.thresholds.<br />This feature is in preview.<br /><br />If you are using the _change_ or _pct_change_ time aggregator, instead use change_aggr(time_aggr(time_window),&lt;br /&gt;timeshift):space_aggr:metric&#123;tags&#125; &#91;by &#123;key&#125;&#93; operator # with:<br /><br />- change_aggr change, pct_change<br />- time_aggr avg, sum, max, min [Learn more](https:​//docs.datadoghq.com/monitors/create/types/#define-the-conditions)<br />- time_window last_#m (between 1 and 2880 depending on the monitor type), last_#h (between 1 and 48 depending on the monitor type), or last_#d (1 or 2)<br />- timeshift #m_ago (5, 10, 15, or 30), #h_ago (1, 2, or 4), or 1d_ago<br /><br />Use this to create an outlier monitor using the following query:<br />avg(last_30m):outliers(avg:system.cpu.user&#123;role:es-events-data&#125; by &#123;host&#125;, 'dbscan', 7) &gt; 0<br /><br />##### Service Check Query<br /><br />Example: "check".over(tags).last(count).by(group).count_by_status()<br /><br />- check name of the check, for example datadog.agent.up<br />- tags one or more quoted tags (comma-separated), or "". for example: .over("env:prod", "role:db"); over cannot be blank.<br />- count must be at greater than or equal to your max threshold (defined in the options). It is limited to 100.<br />For example, if you've specified to notify on 1 critical, 3 ok, and 2 warn statuses, count should be at least 3.<br />- group must be specified for check monitors. Per-check grouping is already explicitly known for some service checks.<br />For example, Postgres integration monitors are tagged by db, host, and port, and Network monitors by host, instance, and url. See [Service Checks](https:​//docs.datadoghq.com/api/latest/service-checks/) documentation for more information.<br /><br />##### Event Alert Query<br /><br />Note: The Event Alert Query has been replaced by the Event V2 Alert Query. For more information, see the [Event Migration guide](https:​//docs.datadoghq.com/service_management/events/guides/migrating_to_new_events_features/).<br /><br />##### Event V2 Alert Query<br /><br />Example: events(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### Process Alert Query<br /><br />Example: processes(search).over(tags).rollup('count').last(timeframe) operator #<br /><br />- search free text search string for querying processes.<br />Matching processes match results on the [Live Processes](https:​//docs.datadoghq.com/infrastructure/process/?tab=linuxwindows) page.<br />- tags one or more tags (comma-separated)<br />- timeframe the timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and d<br />- operator <, <=, >, >=, ==, or !=<br />- # an integer or decimal number used to set the threshold<br /><br />##### Logs Alert Query<br /><br />Example: logs(query).index(index_name).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- index_name For multi-index organizations, the log index in which the request is performed.<br />- rollup_method The stats roll-up method - supports count, avg and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### Composite Query<br /><br />Example: 12345 && 67890, where 12345 and 67890 are the IDs of non-composite monitors<br /><br />* name [required, default = dynamic, based on query]: The name of the alert.<br />* message [required, default = dynamic, based on query]: A message to include with notifications for this monitor.<br />Email notifications can be sent to specific users by using the same '@username' notation as events.<br />* tags [optional, default = empty list]: A list of tags to associate with your monitor.<br />When getting all monitor details via the API, use the monitor_tags argument to filter results by these tags.<br />It is only available via the API and isn't visible or editable in the Datadog UI.<br /><br />##### SLO Alert Query<br /><br />Example: error_budget("slo_id").over("time_window") operator #<br /><br />- slo_id: The alphanumeric SLO ID of the SLO you are configuring the alert for.<br />- time_window: The time window of the SLO target you wish to alert on. Valid options: 7d, 30d, 90d.<br />- operator: &gt;= or &gt;<br /><br />##### Audit Alert Query<br /><br />Example: audits(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### CI Pipelines Alert Query<br /><br />Example: ci-pipelines(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### CI Tests Alert Query<br /><br />Example: ci-tests(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### Error Tracking Alert Query<br /><br />"New issue" example: error-tracking(query).source(issue_source).new().rollup(rollup_method&#91;, measure&#93;).by(group_by).last(time_window) operator #<br />"High impact issue" example: error-tracking(query).source(issue_source).impact().rollup(rollup_method&#91;, measure&#93;).by(group_by).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- issue_source The issue source - supports all, browser, mobile and backend and defaults to all if omitted.<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality and defaults to count if omitted.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- group by Comma-separated list of attributes to group by - should contain at least issue.id.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />Database Monitoring Alert Query<br /><br />Example: database-monitoring(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />Network Performance Alert Query<br /><br />Example: network-performance(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />Cost Alert Query<br /><br />Example: formula(query).timeframe_type(time_window).function(parameter) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- timeframe_type The timeframe type to evaluate the cost<br /> - for forecast supports current<br /> - for change, anomaly, threshold supports last<br />- time_window - supports daily roll-up e.g. 7d<br />- function - [optional, defaults to threshold monitor if omitted] supports change, anomaly, forecast<br />- parameter Specify the parameter of the type<br /> - for change:<br /> - supports relative, absolute<br /> - [optional] supports #, where # is an integer or decimal number used to set the threshold<br /> - for anomaly:<br /> - supports direction=both, direction=above, direction=below<br /> - [optional] supports threshold=#, where # is an integer or decimal number used to set the threshold<br />- operator<br /> - for threshold supports &lt;, &lt;=, &gt;, &gt;=, ==, or !=<br /> - for change supports &gt;, &lt;<br /> - for anomaly supports &gt;=<br /> - for forecast supports &gt;<br />- # an integer or decimal number used to set the threshold.<br /><br />Network Path Alert Query<br /><br />Example: network-path(query).index(index_name).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- index_name The data type to monitor on - supports netpath-path and netpath-hop.<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.
update_monitorreplacemonitor_idEdit the specified monitor.
delete_monitordeletemonitor_idforceDelete the specified monitor
validate_monitorexectype, queryValidate the monitor provided in the request.<br /><br />Note: Log monitors require an unscoped App Key and logs_read_data permission.
validate_existing_monitorexecmonitor_id, type, queryValidate the monitor provided in the request.<br /><br />Note: Log monitors require an unscoped App Key and logs_read_data permission.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
monitor_idinteger (int64)The ID of the monitor
monitor_idsarrayThe IDs of the monitor to check.
sitestringThe Datadog site (region) for your organization, for example datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, ap2.datadoghq.com, datadoghq.eu, ddog-gov.com. Resolved from the DD_SITE environment variable when set. Optional: defaults to datadoghq.com, or the value of the DD_SITE environment variable when set; a WHERE value overrides both.
forcestringDelete the monitor even if it's referenced by other resources (for example SLO, composite monitor).
group_statesstringWhen specified, shows additional information about the group states. Choose one or more from all, alert, warn, and no data.
id_offsetinteger (int64)Use this parameter for paginating through large sets of monitors. Start with a value of zero, make a request, set the value to the last ID of result set, and then repeat until the response is empty.
monitor_tagsstringA comma separated list indicating what service and/or custom tags, if any, should be used to filter the list of monitors. Tags created in the Datadog UI automatically have the service key prepended. For example, service:my-app.
namestringA string to filter monitors by name.
pageinteger (int64)The page to start paginating from. If this argument is not specified, the request returns all monitors without pagination.
page_sizeinteger (int32)The number of monitors to return per page. If the page argument is not specified, the default behavior returns all monitors without a page_size limit. However, if page is specified and page_size is not, the argument defaults to 100.
tagsstringA comma separated list indicating what tags, if any, should be used to filter the list of monitors by scope. For example, host:host0.
with_assetsbooleanIf this argument is set to true, the returned data includes all assets tied to this monitor.
with_downtimesbooleanIf this argument is set to true, then the returned data includes all current active downtimes for each monitor.

SELECT examples

Get details about the specified monitor from your organization.

SELECT
id,
name,
assets,
created,
creator,
deleted,
draft_status,
matching_downtimes,
message,
modified,
multi,
options,
overall_state,
priority,
query,
restricted_roles,
state,
tags,
type
FROM datadog.monitoring.monitors
WHERE monitor_id = '{{ monitor_id }}' -- required
AND group_states = '{{ group_states }}'
AND with_downtimes = '{{ with_downtimes }}'
AND with_assets = '{{ with_assets }}'
;

INSERT examples

Create a monitor using the specified options.<br /><br />#### Monitor Types<br /><br />The type of monitor chosen from:<br /><br />- anomaly: query alert<br />- APM: query alert or trace-analytics alert<br />- composite: composite<br />- custom: service check<br />- forecast: query alert<br />- host: service check<br />- integration: query alert or service check<br />- live process: process alert<br />- logs: log alert<br />- metric: query alert<br />- network: service check<br />- outlier: query alert<br />- process: service check<br />- rum: rum alert<br />- SLO: slo alert<br />- watchdog: event-v2 alert<br />- event-v2: event-v2 alert<br />- audit: audit alert<br />- error-tracking: error-tracking alert<br />- database-monitoring: database-monitoring alert<br />- network-performance: network-performance alert<br />- cloud cost: cost alert<br />- network-path: network-path alert<br /><br />Notes:<br />- Synthetic monitors are created through the Synthetics API. See the [Synthetics API](https:​//docs.datadoghq.com/api/latest/synthetics/) documentation for more information.<br />- Log monitors require an unscoped App Key.<br /><br />#### Query Types<br /><br />##### Metric Alert Query<br /><br />Example: time_aggr(time_window):space_aggr:metric&#123;tags&#125; &#91;by &#123;key&#125;&#93; operator #<br /><br />- time_aggr: avg, sum, max, min, change, or pct_change<br />- time_window: last_#m (with # between 1 and 10080 depending on the monitor type) or last_#h(with # between 1 and 168 depending on the monitor type) or last_1d, or last_1w<br />- space_aggr: avg, sum, min, or max<br />- tags: one or more tags (comma-separated), or <br />- key: a 'key' in key:value tag syntax; defines a separate alert for each tag in the group (multi-alert)<br />- operator: <, <=, >, >=, ==, or !=<br />- #: an integer or decimal number used to set the threshold<br /><br />To use a dynamic threshold on a metric monitor with a formula query, replace # with the threshold keyword<br />(for example, ... &gt; threshold) and provide the threshold as a query via critical_query on options.thresholds.<br />This feature is in preview.<br /><br />If you are using the _change_ or _pct_change_ time aggregator, instead use change_aggr(time_aggr(time_window),&lt;br /&gt;timeshift):space_aggr:metric&#123;tags&#125; &#91;by &#123;key&#125;&#93; operator # with:<br /><br />- change_aggr change, pct_change<br />- time_aggr avg, sum, max, min [Learn more](https:​//docs.datadoghq.com/monitors/create/types/#define-the-conditions)<br />- time_window last_#m (between 1 and 2880 depending on the monitor type), last_#h (between 1 and 48 depending on the monitor type), or last_#d (1 or 2)<br />- timeshift #m_ago (5, 10, 15, or 30), #h_ago (1, 2, or 4), or 1d_ago<br /><br />Use this to create an outlier monitor using the following query:<br />avg(last_30m):outliers(avg:system.cpu.user&#123;role:es-events-data&#125; by &#123;host&#125;, 'dbscan', 7) &gt; 0<br /><br />##### Service Check Query<br /><br />Example: "check".over(tags).last(count).by(group).count_by_status()<br /><br />- check name of the check, for example datadog.agent.up<br />- tags one or more quoted tags (comma-separated), or "". for example: .over("env:prod", "role:db"); over cannot be blank.<br />- count must be at greater than or equal to your max threshold (defined in the options). It is limited to 100.<br />For example, if you've specified to notify on 1 critical, 3 ok, and 2 warn statuses, count should be at least 3.<br />- group must be specified for check monitors. Per-check grouping is already explicitly known for some service checks.<br />For example, Postgres integration monitors are tagged by db, host, and port, and Network monitors by host, instance, and url. See [Service Checks](https:​//docs.datadoghq.com/api/latest/service-checks/) documentation for more information.<br /><br />##### Event Alert Query<br /><br />Note: The Event Alert Query has been replaced by the Event V2 Alert Query. For more information, see the [Event Migration guide](https:​//docs.datadoghq.com/service_management/events/guides/migrating_to_new_events_features/).<br /><br />##### Event V2 Alert Query<br /><br />Example: events(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### Process Alert Query<br /><br />Example: processes(search).over(tags).rollup('count').last(timeframe) operator #<br /><br />- search free text search string for querying processes.<br />Matching processes match results on the [Live Processes](https:​//docs.datadoghq.com/infrastructure/process/?tab=linuxwindows) page.<br />- tags one or more tags (comma-separated)<br />- timeframe the timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and d<br />- operator <, <=, >, >=, ==, or !=<br />- # an integer or decimal number used to set the threshold<br /><br />##### Logs Alert Query<br /><br />Example: logs(query).index(index_name).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- index_name For multi-index organizations, the log index in which the request is performed.<br />- rollup_method The stats roll-up method - supports count, avg and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### Composite Query<br /><br />Example: 12345 && 67890, where 12345 and 67890 are the IDs of non-composite monitors<br /><br />* name [required, default = dynamic, based on query]: The name of the alert.<br />* message [required, default = dynamic, based on query]: A message to include with notifications for this monitor.<br />Email notifications can be sent to specific users by using the same '@username' notation as events.<br />* tags [optional, default = empty list]: A list of tags to associate with your monitor.<br />When getting all monitor details via the API, use the monitor_tags argument to filter results by these tags.<br />It is only available via the API and isn't visible or editable in the Datadog UI.<br /><br />##### SLO Alert Query<br /><br />Example: error_budget("slo_id").over("time_window") operator #<br /><br />- slo_id: The alphanumeric SLO ID of the SLO you are configuring the alert for.<br />- time_window: The time window of the SLO target you wish to alert on. Valid options: 7d, 30d, 90d.<br />- operator: &gt;= or &gt;<br /><br />##### Audit Alert Query<br /><br />Example: audits(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### CI Pipelines Alert Query<br /><br />Example: ci-pipelines(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### CI Tests Alert Query<br /><br />Example: ci-tests(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />##### Error Tracking Alert Query<br /><br />"New issue" example: error-tracking(query).source(issue_source).new().rollup(rollup_method&#91;, measure&#93;).by(group_by).last(time_window) operator #<br />"High impact issue" example: error-tracking(query).source(issue_source).impact().rollup(rollup_method&#91;, measure&#93;).by(group_by).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- issue_source The issue source - supports all, browser, mobile and backend and defaults to all if omitted.<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality and defaults to count if omitted.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- group by Comma-separated list of attributes to group by - should contain at least issue.id.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />Database Monitoring Alert Query<br /><br />Example: database-monitoring(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />Network Performance Alert Query<br /><br />Example: network-performance(query).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.<br /><br />Cost Alert Query<br /><br />Example: formula(query).timeframe_type(time_window).function(parameter) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- timeframe_type The timeframe type to evaluate the cost<br /> - for forecast supports current<br /> - for change, anomaly, threshold supports last<br />- time_window - supports daily roll-up e.g. 7d<br />- function - [optional, defaults to threshold monitor if omitted] supports change, anomaly, forecast<br />- parameter Specify the parameter of the type<br /> - for change:<br /> - supports relative, absolute<br /> - [optional] supports #, where # is an integer or decimal number used to set the threshold<br /> - for anomaly:<br /> - supports direction=both, direction=above, direction=below<br /> - [optional] supports threshold=#, where # is an integer or decimal number used to set the threshold<br />- operator<br /> - for threshold supports &lt;, &lt;=, &gt;, &gt;=, ==, or !=<br /> - for change supports &gt;, &lt;<br /> - for anomaly supports &gt;=<br /> - for forecast supports &gt;<br />- # an integer or decimal number used to set the threshold.<br /><br />Network Path Alert Query<br /><br />Example: network-path(query).index(index_name).rollup(rollup_method&#91;, measure&#93;).last(time_window) operator #<br /><br />- query The search query - following the [Log search syntax](https:​//docs.datadoghq.com/logs/search_syntax/).<br />- index_name The data type to monitor on - supports netpath-path and netpath-hop.<br />- rollup_method The stats roll-up method - supports count, avg, and cardinality.<br />- measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.<br />- time_window #m (between 1 and 2880), #h (between 1 and 48).<br />- operator &lt;, &lt;=, &gt;, &gt;=, ==, or !=.<br />- # an integer or decimal number used to set the threshold.

INSERT INTO datadog.monitoring.monitors (
assets,
draft_status,
matching_downtimes,
message,
name,
options,
priority,
query,
restricted_roles,
tags,
type
)
SELECT
'{{ assets }}',
'{{ draft_status }}',
'{{ matching_downtimes }}',
'{{ message }}',
'{{ name }}',
'{{ options }}',
{{ priority }},
'{{ query }}' /* required */,
'{{ restricted_roles }}',
'{{ tags }}',
'{{ type }}' /* required */
RETURNING
id,
name,
assets,
created,
creator,
deleted,
draft_status,
matching_downtimes,
message,
modified,
multi,
options,
overall_state,
priority,
query,
restricted_roles,
state,
tags,
type
;

REPLACE examples

Edit the specified monitor.

REPLACE datadog.monitoring.monitors
SET
assets = '{{ assets }}',
draft_status = '{{ draft_status }}',
message = '{{ message }}',
name = '{{ name }}',
options = '{{ options }}',
priority = {{ priority }},
query = '{{ query }}',
restricted_roles = '{{ restricted_roles }}',
tags = '{{ tags }}',
type = '{{ type }}'
WHERE
monitor_id = '{{ monitor_id }}' --required
RETURNING
id,
name,
assets,
created,
creator,
deleted,
draft_status,
matching_downtimes,
message,
modified,
multi,
options,
overall_state,
priority,
query,
restricted_roles,
state,
tags,
type;

DELETE examples

Delete the specified monitor

DELETE FROM datadog.monitoring.monitors
WHERE monitor_id = '{{ monitor_id }}' --required
AND force = '{{ force }}'
;

Lifecycle Methods

EXEC variables use wire (API) names.

Validate the monitor provided in the request.<br /><br />Note: Log monitors require an unscoped App Key and logs_read_data permission.

EXEC datadog.monitoring.monitors.validate_monitor
@@json=
'{
"assets": "{{ assets }}",
"draft_status": "{{ draft_status }}",
"matching_downtimes": "{{ matching_downtimes }}",
"message": "{{ message }}",
"name": "{{ name }}",
"options": "{{ options }}",
"priority": {{ priority }},
"query": "{{ query }}",
"restricted_roles": "{{ restricted_roles }}",
"tags": "{{ tags }}",
"type": "{{ type }}"
}'
;