Create a monitor

POST {{baseUrl}}/api/v1/monitor

Create a monitor using the specified options.

Monitor Types

The type of monitor chosen from:

  • anomaly: query alert
  • APM: query alert or trace-analytics alert
  • composite: composite
  • custom: service check
  • event: event alert
  • forecast: query alert
  • host: service check
  • integration: query alert or service check
  • live process: process alert
  • logs: log alert
  • metric: query alert
  • network: service check
  • outlier: query alert
  • process: service check
  • rum: rum alert
  • SLO: slo alert
  • watchdog: event alert
  • event-v2: event-v2 alert
  • audit: audit alert
  • error-tracking: error-tracking alert
  • database-monitoring: database-monitoring alert

Note: Synthetic monitors are created through the Synthetics API. See the Synthetics API documentation for more information.

Query Types

Metric Alert Query

Example: time_aggr(time_window):space_aggr:metric{tags} [by {key}] operator #

  • time_aggr: avg, sum, max, min, change, or pct_change
  • 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
  • space_aggr: avg, sum, min, or max
  • tags: one or more tags (comma-separated), or *
  • key: a 'key' in key:value tag syntax; defines a separate alert for each tag in the group (multi-alert)
  • operator: <, <=, >, >=, ==, or !=
  • #: an integer or decimal number used to set the threshold

If you are using the _change_ or _pct_change_ time aggregator, instead use change_aggr(time_aggr(time_window), timeshift):space_aggr:metric{tags} [by {key}] operator # with:

  • change_aggr change, pct_change
  • time_aggr avg, sum, max, min Learn more
  • 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)
  • timeshift #mago (5, 10, 15, or 30), #hago (1, 2, or 4), or 1d_ago

Use this to create an outlier monitor using the following query: avg(last_30m):outliers(avg:system.cpu.user{role:es-events-data} by {host}, 'dbscan', 7) > 0

Service Check Query

Example: "check".over(tags).last(count).by(group).count_by_status()

  • check name of the check, for example datadog.agent.up
  • tags one or more quoted tags (comma-separated), or *. for example: .over("env:prod", "role:db"); over cannot be blank.
  • count must be at greater than or equal to your max threshold (defined in the options). It is limited to 100. For example, if you've specified to notify on 1 critical, 3 ok, and 2 warn statuses, count should be at least 3.
  • group must be specified for check monitors. Per-check grouping is already explicitly known for some service checks. For example, Postgres integration monitors are tagged by db, host, and port, and Network monitors by host, instance, and url. See Service Checks documentation for more information.
Event Alert Query

Example: events('sources:nagios status:error,warning priority:normal tags: "string query"').rollup("count").last("1h")"

  • event, the event query string:
  • string_query free text query to match against event title and text.
  • sources event sources (comma-separated).
  • status event statuses (comma-separated). Valid options: error, warn, and info.
  • priority event priorities (comma-separated). Valid options: low, normal, all.
  • host event reporting host (comma-separated).
  • tags event tags (comma-separated).
  • excluded_tags excluded event tags (comma-separated).
  • rollup the stats roll-up method. count is the only supported method now.
  • last the timeframe to roll up the counts. Examples: 45m, 4h. Supported timeframes: m, h and d. This value should not exceed 48 hours.

NOTE The Event Alert Query is being deprecated and replaced by the Event V2 Alert Query. For more information, see the Event Migration guide.

Event V2 Alert Query

Example: events(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • rollup_method The stats roll-up method - supports count, avg and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.
Process Alert Query

Example: processes(search).over(tags).rollup('count').last(timeframe) operator #

  • search free text search string for querying processes. Matching processes match results on the Live Processes page.
  • tags one or more tags (comma-separated)
  • timeframe the timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and d
  • operator <, <=, >, >=, ==, or !=
  • # an integer or decimal number used to set the threshold
Logs Alert Query

Example: logs(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • index_name For multi-index organizations, the log index in which the request is performed.
  • rollup_method The stats roll-up method - supports count, avg and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.
Composite Query

Example: 12345 && 67890, where 12345 and 67890 are the IDs of non-composite monitors

  • name [required, default = dynamic, based on query]: The name of the alert.
  • message [required, default = dynamic, based on query]: A message to include with notifications for this monitor. Email notifications can be sent to specific users by using the same '@username' notation as events.
  • tags [optional, default = empty list]: A list of tags to associate with your monitor. When getting all monitor details via the API, use the monitor_tags argument to filter results by these tags. It is only available via the API and isn't visible or editable in the Datadog UI.
SLO Alert Query

Example: error_budget("slo_id").over("time_window") operator #

  • slo_id: The alphanumeric SLO ID of the SLO you are configuring the alert for.
  • time_window: The time window of the SLO target you wish to alert on. Valid options: 7d, 30d, 90d.
  • operator: >= or >
Audit Alert Query

Example: audits(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • rollup_method The stats roll-up method - supports count, avg and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.

NOTE Only available on US1-FED and in closed beta on US1, EU, AP1, US3, and US5.

CI Pipelines Alert Query

Example: ci-pipelines(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • rollup_method The stats roll-up method - supports count, avg, and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.

NOTE CI Pipeline monitors are in alpha on US1, EU, AP1, US3, and US5.

CI Tests Alert Query

Example: ci-tests(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • rollup_method The stats roll-up method - supports count, avg, and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.

NOTE CI Test monitors are available only in closed beta on US1, EU, AP1, US3, and US5.

Error Tracking Alert Query

Example(RUM): error-tracking-rum(query).rollup(rollup_method[, measure]).last(time_window) operator # Example(APM Traces): error-tracking-traces(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • rollup_method The stats roll-up method - supports count, avg, and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.

Database Monitoring Alert Query

Example: database-monitoring(query).rollup(rollup_method[, measure]).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • rollup_method The stats roll-up method - supports count, avg, and cardinality.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • time_window #m (between 1 and 2880), #h (between 1 and 48).
  • operator <, <=, >, >=, ==, or !=.
  • # an integer or decimal number used to set the threshold.

NOTE Database Monitoring monitors are in alpha on US1.

Request Body

{"message"=>"You may need to add web hosts if this is consistently high.", "name"=>"Bytes received on host0", "options"=>{"no_data_timeframe"=>20, "notify_no_data"=>true}, "query"=>"avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100", "tags"=>["app:webserver", "frontend"], "type"=>"query alert"}

HEADERS

KeyDatatypeRequiredDescription
Content-Typestring
Acceptstring

RESPONSES

status: OK

{&quot;type&quot;:&quot;query alert&quot;,&quot;query&quot;:&quot;avg(last_5m):sum:system.net.bytes_rcvd{host:host0} \u003e 100&quot;,&quot;created&quot;:&quot;1989-12-01T14:28:43.831Z&quot;,&quot;creator&quot;:{&quot;email&quot;:&quot;officia sunt&quot;,&quot;handle&quot;:&quot;pariatur&quot;,&quot;name&quot;:&quot;aute do&quot;},&quot;deleted&quot;:&quot;2020-10-30T20:46:24.520Z&quot;,&quot;id&quot;:-50675854,&quot;matching_downtimes&quot;:[{&quot;id&quot;:1625,&quot;end&quot;:1412792983,&quot;scope&quot;:[&quot;env:staging&quot;],&quot;start&quot;:1412792983},{&quot;id&quot;:1625,&quot;end&quot;:1412792983,&quot;scope&quot;:[&quot;env:staging&quot;],&quot;start&quot;:1412792983}],&quot;message&quot;:&quot;ullamco incididunt cupidatat&quot;,&quot;modified&quot;:&quot;1981-03-27T05:04:03.098Z&quot;,&quot;multi&quot;:false,&quot;name&quot;:&quot;My monitor&quot;,&quot;options&quot;:{&quot;aggregation&quot;:{&quot;group_by&quot;:&quot;host&quot;,&quot;metric&quot;:&quot;metrics.name&quot;,&quot;type&quot;:&quot;count&quot;},&quot;device_ids&quot;:[&quot;mobile_small&quot;,&quot;chrome.tablet&quot;],&quot;enable_logs_sample&quot;:false,&quot;enable_samples&quot;:false,&quot;escalation_message&quot;:&quot;none&quot;,&quot;evaluation_delay&quot;:-52819274,&quot;group_retention_duration&quot;:&quot;dolor Lorem qui&quot;,&quot;groupby_simple_monitor&quot;:false,&quot;include_tags&quot;:true,&quot;locked&quot;:false,&quot;min_failure_duration&quot;:0,&quot;min_location_failed&quot;:1,&quot;new_group_delay&quot;:-94315945,&quot;new_host_delay&quot;:300,&quot;no_data_timeframe&quot;:-86360342,&quot;notification_preset_name&quot;:&quot;show_all&quot;,&quot;notify_audit&quot;:false,&quot;notify_by&quot;:[&quot;labore dolore&quot;,&quot;deserunt commodo consectetur&quot;],&quot;notify_no_data&quot;:false,&quot;on_missing_data&quot;:&quot;resolve&quot;,&quot;renotify_interval&quot;:null,&quot;renotify_occurrences&quot;:56355858,&quot;renotify_statuses&quot;:[&quot;warn&quot;,&quot;no data&quot;],&quot;require_full_window&quot;:false,&quot;scheduling_options&quot;:{&quot;evaluation_window&quot;:{&quot;day_starts&quot;:&quot;04:00&quot;,&quot;hour_starts&quot;:0,&quot;month_starts&quot;:1}},&quot;silenced&quot;:{&quot;non_6f_&quot;:77287100},&quot;synthetics_check_id&quot;:&quot;culpa in laborum irure&quot;,&quot;threshold_windows&quot;:{&quot;recovery_window&quot;:&quot;culpa cupidatat Lorem ut&quot;,&quot;trigger_window&quot;:&quot;fugiat officia mollit esse quis&quot;},&quot;thresholds&quot;:{&quot;critical&quot;:-44507487.0891542,&quot;critical_recovery&quot;:94365870.17342958,&quot;ok&quot;:26645340.31156695,&quot;unknown&quot;:-32772943.396166816,&quot;warning&quot;:75330874.10211122,&quot;warning_recovery&quot;:30665996.226613894},&quot;timeout_h&quot;:null,&quot;variables&quot;:[{&quot;data_source&quot;:&quot;rum&quot;,&quot;compute&quot;:{&quot;aggregation&quot;:&quot;avg&quot;,&quot;interval&quot;:60000,&quot;metric&quot;:&quot;@duration&quot;},&quot;name&quot;:&quot;query_errors&quot;,&quot;group_by&quot;:[{&quot;facet&quot;:&quot;status&quot;,&quot;limit&quot;:10,&quot;sort&quot;:{&quot;aggregation&quot;:&quot;avg&quot;,&quot;metric&quot;:&quot;minim tempor i&quot;,&quot;order&quot;:&quot;desc&quot;}},{&quot;facet&quot;:&quot;status&quot;,&quot;limit&quot;:10,&quot;sort&quot;:{&quot;aggregation&quot;:&quot;avg&quot;,&quot;metric&quot;:&quot;Ut fugiat officia&quot;,&quot;order&quot;:&quot;desc&quot;}}],&quot;indexes&quot;:[&quot;days-3&quot;,&quot;days-7&quot;],&quot;search&quot;:{&quot;query&quot;:&quot;service:query&quot;}},{&quot;data_source&quot;:&quot;rum&quot;,&quot;compute&quot;:{&quot;aggregation&quot;:&quot;avg&quot;,&quot;interval&quot;:60000,&quot;metric&quot;:&quot;@duration&quot;},&quot;name&quot;:&quot;query_errors&quot;,&quot;group_by&quot;:[{&quot;facet&quot;:&quot;status&quot;,&quot;limit&quot;:10,&quot;sort&quot;:{&quot;aggregation&quot;:&quot;avg&quot;,&quot;metric&quot;:&quot;do velit&quot;,&quot;order&quot;:&quot;desc&quot;}},{&quot;facet&quot;:&quot;status&quot;,&quot;limit&quot;:10,&quot;sort&quot;:{&quot;aggregation&quot;:&quot;avg&quot;,&quot;metric&quot;:&quot;amet proident anim in&quot;,&quot;order&quot;:&quot;desc&quot;}}],&quot;indexes&quot;:[&quot;days-3&quot;,&quot;days-7&quot;],&quot;search&quot;:{&quot;query&quot;:&quot;service:query&quot;}}]},&quot;overall_state&quot;:&quot;Warn&quot;,&quot;priority&quot;:1,&quot;restricted_roles&quot;:[&quot;enim qui cillum est&quot;,&quot;quis ut&quot;],&quot;state&quot;:{&quot;groups&quot;:{&quot;Lorem_1&quot;:{&quot;last_nodata_ts&quot;:-12653992,&quot;last_notified_ts&quot;:-66141067,&quot;last_resolved_ts&quot;:5643925,&quot;last_triggered_ts&quot;:-6121593,&quot;name&quot;:&quot;dolore nulla i&quot;,&quot;status&quot;:&quot;OK&quot;},&quot;nisi_c43&quot;:{&quot;last_nodata_ts&quot;:-66061060,&quot;last_notified_ts&quot;:-86988012,&quot;last_resolved_ts&quot;:-39919633,&quot;last_triggered_ts&quot;:13467862,&quot;name&quot;:&quot;Ut fugiat eiusmod anim&quot;,&quot;status&quot;:&quot;Ignored&quot;},&quot;minim_c&quot;:{&quot;last_nodata_ts&quot;:6509669,&quot;last_notified_ts&quot;:39348490,&quot;last_resolved_ts&quot;:13221088,&quot;last_triggered_ts&quot;:21889420,&quot;name&quot;:&quot;in velit Duis&quot;,&quot;status&quot;:&quot;Alert&quot;}}},&quot;tags&quot;:[&quot;ex tempor&quot;,&quot;enim veniam dolore&quot;]}