Struct MonitorsAPI

Source
pub struct MonitorsAPI { /* private fields */ }
Expand description

Monitors allow you to watch a metric or check that you care about and notifies your team when a defined threshold has exceeded.

For more information, see Creating Monitors.

Note: curl commands require url encoding.

Implementations§

Source§

impl MonitorsAPI

Source

pub fn new() -> Self

Source

pub fn with_config(config: Configuration) -> Self

Examples found in repository?
examples/v1_monitors_ListMonitors.rs (line 9)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = MonitorsAPI::with_config(configuration);
10    let resp = api
11        .list_monitors(ListMonitorsOptionalParams::default())
12        .await;
13    if let Ok(value) = resp {
14        println!("{:#?}", value);
15    } else {
16        println!("{:#?}", resp.unwrap_err());
17    }
18}
More examples
Hide additional examples
examples/v1_monitors_SearchMonitors.rs (line 9)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = MonitorsAPI::with_config(configuration);
10    let resp = api
11        .search_monitors(SearchMonitorsOptionalParams::default())
12        .await;
13    if let Ok(value) = resp {
14        println!("{:#?}", value);
15    } else {
16        println!("{:#?}", resp.unwrap_err());
17    }
18}
examples/v1_monitors_SearchMonitorGroups.rs (line 9)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = MonitorsAPI::with_config(configuration);
10    let resp = api
11        .search_monitor_groups(SearchMonitorGroupsOptionalParams::default())
12        .await;
13    if let Ok(value) = resp {
14        println!("{:#?}", value);
15    } else {
16        println!("{:#?}", resp.unwrap_err());
17    }
18}
examples/v1_monitors_CheckCanDeleteMonitor.rs (line 10)
6async fn main() {
7    // there is a valid "monitor" in the system
8    let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
9    let configuration = datadog::Configuration::new();
10    let api = MonitorsAPI::with_config(configuration);
11    let resp = api.check_can_delete_monitor(vec![monitor_id.clone()]).await;
12    if let Ok(value) = resp {
13        println!("{:#?}", value);
14    } else {
15        println!("{:#?}", resp.unwrap_err());
16    }
17}
examples/v1_monitors_ListMonitors_2154432960.rs (line 9)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = MonitorsAPI::with_config(configuration);
10    let resp = api
11        .list_monitors(
12            ListMonitorsOptionalParams::default()
13                .tags("test:examplemonitor".to_string())
14                .page_size(1),
15        )
16        .await;
17    if let Ok(value) = resp {
18        println!("{:#?}", value);
19    } else {
20        println!("{:#?}", resp.unwrap_err());
21    }
22}
examples/v1_monitors_ListMonitors_463213563.rs (line 11)
9async fn main() {
10    let configuration = datadog::Configuration::new();
11    let api = MonitorsAPI::with_config(configuration);
12    let response =
13        api.list_monitors_with_pagination(ListMonitorsOptionalParams::default().page_size(2));
14    pin_mut!(response);
15    while let Some(resp) = response.next().await {
16        if let Ok(value) = resp {
17            println!("{:#?}", value);
18        } else {
19            println!("{:#?}", resp.unwrap_err());
20        }
21    }
22}
Source

pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self

Source

pub async fn check_can_delete_monitor( &self, monitor_ids: Vec<i64>, ) -> Result<CheckCanDeleteMonitorResponse, Error<CheckCanDeleteMonitorError>>

Check if the given monitors can be deleted.

Examples found in repository?
examples/v1_monitors_CheckCanDeleteMonitor.rs (line 11)
6async fn main() {
7    // there is a valid "monitor" in the system
8    let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
9    let configuration = datadog::Configuration::new();
10    let api = MonitorsAPI::with_config(configuration);
11    let resp = api.check_can_delete_monitor(vec![monitor_id.clone()]).await;
12    if let Ok(value) = resp {
13        println!("{:#?}", value);
14    } else {
15        println!("{:#?}", resp.unwrap_err());
16    }
17}
Source

pub async fn check_can_delete_monitor_with_http_info( &self, monitor_ids: Vec<i64>, ) -> Result<ResponseContent<CheckCanDeleteMonitorResponse>, Error<CheckCanDeleteMonitorError>>

Check if the given monitors can be deleted.

Source

pub async fn create_monitor( &self, body: Monitor, ) -> Result<Monitor, Error<CreateMonitorError>>

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
  • 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-v2 alert
  • event-v2: event-v2 alert
  • audit: audit alert
  • error-tracking: error-tracking alert
  • database-monitoring: database-monitoring alert
  • network-performance: network-performance alert
  • cloud cost: cost alert

Notes:

  • Synthetic monitors are created through the Synthetics API. See the Synthetics API documentation for more information.
  • Log monitors require an unscoped App Key.
§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 #m_ago (5, 10, 15, or 30), #h_ago (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

Note: The Event Alert Query has been 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.
§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.
§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.
§Error Tracking Alert Query

“New issue” example: error-tracking(query).source(issue_source).new().rollup(rollup_method[, measure]).by(group_by).last(time_window) operator # “High impact issue” example: error-tracking(query).source(issue_source).impact().rollup(rollup_method[, measure]).by(group_by).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • issue_source The issue source - supports all, browser, mobile and backend and defaults to all if omitted.
  • rollup_method The stats roll-up method - supports count, avg, and cardinality and defaults to count if omitted.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • group by Comma-separated list of attributes to group by - should contain at least issue.id.
  • 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.

Network Performance Alert Query

Example: network-performance(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.

Cost Alert Query

Example: formula(query).timeframe_type(time_window).function(parameter) operator #

  • query The search query - following the Log search syntax.
  • timeframe_type The timeframe type to evaluate the cost - for forecast supports current - for change, anomaly, threshold supports last
  • time_window - supports daily roll-up e.g. 7d
  • function - [optional, defaults to threshold monitor if omitted] supports change, anomaly, forecast
  • parameter Specify the parameter of the type
    • for change:
      • supports relative, absolute
      • [optional] supports #, where # is an integer or decimal number used to set the threshold
    • for anomaly:
      • supports direction=both, direction=above, direction=below
      • [optional] supports threshold=#, where # is an integer or decimal number used to set the threshold
  • operator
    • for threshold supports <, <=, >, >=, ==, or !=
    • for change supports >, <
    • for anomaly supports >=
    • for forecast supports >
  • # an integer or decimal number used to set the threshold.
Examples found in repository?
examples/v1_monitors_CreateMonitor_440013737.rs (line 23)
10async fn main() {
11    let body =
12        Monitor::new(
13            r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
14            MonitorType::ERROR_TRACKING_ALERT,
15        )
16            .message("some message".to_string())
17            .name("Example-Monitor".to_string())
18            .options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
19            .priority(Some(3))
20            .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21    let configuration = datadog::Configuration::new();
22    let api = MonitorsAPI::with_config(configuration);
23    let resp = api.create_monitor(body).await;
24    if let Ok(value) = resp {
25        println!("{:#?}", value);
26    } else {
27        println!("{:#?}", resp.unwrap_err());
28    }
29}
More examples
Hide additional examples
examples/v1_monitors_CreateMonitor_2520912138.rs (line 23)
10async fn main() {
11    let body =
12        Monitor::new(
13            r#"ci-tests("type:test @git.branch:staging* @test.status:fail").rollup("count").by("@test.name").last("5m") >= 1"#.to_string(),
14            MonitorType::CI_TESTS_ALERT,
15        )
16            .message("some message Notify: @hipchat-channel".to_string())
17            .name("Example-Monitor".to_string())
18            .options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
19            .priority(Some(3))
20            .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21    let configuration = datadog::Configuration::new();
22    let api = MonitorsAPI::with_config(configuration);
23    let resp = api.create_monitor(body).await;
24    if let Ok(value) = resp {
25        println!("{:#?}", value);
26    } else {
27        println!("{:#?}", resp.unwrap_err());
28    }
29}
examples/v1_monitors_CreateMonitor_3790803616.rs (line 23)
10async fn main() {
11    let body =
12        Monitor::new(
13            r#"ci-pipelines("ci_level:pipeline @git.branch:staging* @ci.status:error").rollup("count").by("@git.branch,@ci.pipeline.name").last("5m") >= 1"#.to_string(),
14            MonitorType::CI_PIPELINES_ALERT,
15        )
16            .message("some message Notify: @hipchat-channel".to_string())
17            .name("Example-Monitor".to_string())
18            .options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
19            .priority(Some(3))
20            .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21    let configuration = datadog::Configuration::new();
22    let api = MonitorsAPI::with_config(configuration);
23    let resp = api.create_monitor(body).await;
24    if let Ok(value) = resp {
25        println!("{:#?}", value);
26    } else {
27        println!("{:#?}", resp.unwrap_err());
28    }
29}
examples/v1_monitors_CreateMonitor.rs (line 23)
8async fn main() {
9    // there is a valid "role" in the system
10    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
11    let body =
12        Monitor::new(
13            r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
14            MonitorType::LOG_ALERT,
15        )
16            .message("some message Notify: @hipchat-channel".to_string())
17            .name("Example-Monitor".to_string())
18            .priority(Some(3))
19            .restricted_roles(Some(vec![role_data_id.clone()]))
20            .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21    let configuration = datadog::Configuration::new();
22    let api = MonitorsAPI::with_config(configuration);
23    let resp = api.create_monitor(body).await;
24    if let Ok(value) = resp {
25        println!("{:#?}", value);
26    } else {
27        println!("{:#?}", resp.unwrap_err());
28    }
29}
examples/v1_monitors_CreateMonitor_2012680290.rs (line 32)
12async fn main() {
13    let body = Monitor::new(
14        "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
15        MonitorType::METRIC_ALERT,
16    )
17    .message("some message Notify: @hipchat-channel".to_string())
18    .name("Example-Monitor".to_string())
19    .options(
20        MonitorOptions::new()
21            .scheduling_options(
22                MonitorOptionsSchedulingOptions::new().evaluation_window(
23                    MonitorOptionsSchedulingOptionsEvaluationWindow::new()
24                        .day_starts("04:00".to_string())
25                        .month_starts(1),
26                ),
27            )
28            .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
29    );
30    let configuration = datadog::Configuration::new();
31    let api = MonitorsAPI::with_config(configuration);
32    let resp = api.create_monitor(body).await;
33    if let Ok(value) = resp {
34        println!("{:#?}", value);
35    } else {
36        println!("{:#?}", resp.unwrap_err());
37    }
38}
examples/v1_monitors_CreateMonitor_1539578087.rs (line 44)
14async fn main() {
15    let body = Monitor::new(
16        "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
17        MonitorType::QUERY_ALERT,
18    )
19    .message("some message Notify: @hipchat-channel".to_string())
20    .name("Example-Monitor".to_string())
21    .options(
22        MonitorOptions::new()
23            .include_tags(false)
24            .notify_audit(false)
25            .scheduling_options(
26                MonitorOptionsSchedulingOptions::new()
27                    .custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
28                                        MonitorOptionsCustomScheduleRecurrence::new()
29                                            .rrule("FREQ=DAILY;INTERVAL=1".to_string())
30                                            .start("2024-10-26T09:13:00".to_string())
31                                            .timezone("America/Los_Angeles".to_string())
32                                    ]))
33                    .evaluation_window(
34                        MonitorOptionsSchedulingOptionsEvaluationWindow::new()
35                            .day_starts("04:00".to_string())
36                            .month_starts(1),
37                    ),
38            )
39            .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
40    )
41    .tags(vec![]);
42    let configuration = datadog::Configuration::new();
43    let api = MonitorsAPI::with_config(configuration);
44    let resp = api.create_monitor(body).await;
45    if let Ok(value) = resp {
46        println!("{:#?}", value);
47    } else {
48        println!("{:#?}", resp.unwrap_err());
49    }
50}
Source

pub async fn create_monitor_with_http_info( &self, body: Monitor, ) -> Result<ResponseContent<Monitor>, Error<CreateMonitorError>>

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
  • 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-v2 alert
  • event-v2: event-v2 alert
  • audit: audit alert
  • error-tracking: error-tracking alert
  • database-monitoring: database-monitoring alert
  • network-performance: network-performance alert
  • cloud cost: cost alert

Notes:

  • Synthetic monitors are created through the Synthetics API. See the Synthetics API documentation for more information.
  • Log monitors require an unscoped App Key.
§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 #m_ago (5, 10, 15, or 30), #h_ago (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

Note: The Event Alert Query has been 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.
§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.
§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.
§Error Tracking Alert Query

“New issue” example: error-tracking(query).source(issue_source).new().rollup(rollup_method[, measure]).by(group_by).last(time_window) operator # “High impact issue” example: error-tracking(query).source(issue_source).impact().rollup(rollup_method[, measure]).by(group_by).last(time_window) operator #

  • query The search query - following the Log search syntax.
  • issue_source The issue source - supports all, browser, mobile and backend and defaults to all if omitted.
  • rollup_method The stats roll-up method - supports count, avg, and cardinality and defaults to count if omitted.
  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.
  • group by Comma-separated list of attributes to group by - should contain at least issue.id.
  • 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.

Network Performance Alert Query

Example: network-performance(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.

Cost Alert Query

Example: formula(query).timeframe_type(time_window).function(parameter) operator #

  • query The search query - following the Log search syntax.
  • timeframe_type The timeframe type to evaluate the cost - for forecast supports current - for change, anomaly, threshold supports last
  • time_window - supports daily roll-up e.g. 7d
  • function - [optional, defaults to threshold monitor if omitted] supports change, anomaly, forecast
  • parameter Specify the parameter of the type
    • for change:
      • supports relative, absolute
      • [optional] supports #, where # is an integer or decimal number used to set the threshold
    • for anomaly:
      • supports direction=both, direction=above, direction=below
      • [optional] supports threshold=#, where # is an integer or decimal number used to set the threshold
  • operator
    • for threshold supports <, <=, >, >=, ==, or !=
    • for change supports >, <
    • for anomaly supports >=
    • for forecast supports >
  • # an integer or decimal number used to set the threshold.
Source

pub async fn delete_monitor( &self, monitor_id: i64, params: DeleteMonitorOptionalParams, ) -> Result<DeletedMonitor, Error<DeleteMonitorError>>

Delete the specified monitor

Examples found in repository?
examples/v1_monitors_DeleteMonitor.rs (line 13)
7async fn main() {
8    // there is a valid "monitor" in the system
9    let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = MonitorsAPI::with_config(configuration);
12    let resp = api
13        .delete_monitor(monitor_id.clone(), DeleteMonitorOptionalParams::default())
14        .await;
15    if let Ok(value) = resp {
16        println!("{:#?}", value);
17    } else {
18        println!("{:#?}", resp.unwrap_err());
19    }
20}
Source

pub async fn delete_monitor_with_http_info( &self, monitor_id: i64, params: DeleteMonitorOptionalParams, ) -> Result<ResponseContent<DeletedMonitor>, Error<DeleteMonitorError>>

Delete the specified monitor

Source

pub async fn get_monitor( &self, monitor_id: i64, params: GetMonitorOptionalParams, ) -> Result<Monitor, Error<GetMonitorError>>

Get details about the specified monitor from your organization.

Examples found in repository?
examples/v1_monitors_GetMonitor.rs (lines 13-16)
7async fn main() {
8    // there is a valid "monitor" in the system
9    let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = MonitorsAPI::with_config(configuration);
12    let resp = api
13        .get_monitor(
14            monitor_id.clone(),
15            GetMonitorOptionalParams::default().with_downtimes(true),
16        )
17        .await;
18    if let Ok(value) = resp {
19        println!("{:#?}", value);
20    } else {
21        println!("{:#?}", resp.unwrap_err());
22    }
23}
More examples
Hide additional examples
examples/v1_monitors_GetMonitor_2200114573.rs (lines 13-16)
7async fn main() {
8    // there is a valid "monitor" in the system
9    let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = MonitorsAPI::with_config(configuration);
12    let resp = api
13        .get_monitor(
14            monitor_id.clone(),
15            GetMonitorOptionalParams::default().with_downtimes(true),
16        )
17        .await;
18    if let Ok(value) = resp {
19        println!("{:#?}", value);
20    } else {
21        println!("{:#?}", resp.unwrap_err());
22    }
23}
examples/v1_monitors_GetMonitor_3691711704.rs (lines 16-19)
7async fn main() {
8    // there is a valid "synthetics_api_test" in the system
9    let synthetics_api_test_monitor_id: i64 = std::env::var("SYNTHETICS_API_TEST_MONITOR_ID")
10        .unwrap()
11        .parse()
12        .unwrap();
13    let configuration = datadog::Configuration::new();
14    let api = MonitorsAPI::with_config(configuration);
15    let resp = api
16        .get_monitor(
17            synthetics_api_test_monitor_id.clone(),
18            GetMonitorOptionalParams::default(),
19        )
20        .await;
21    if let Ok(value) = resp {
22        println!("{:#?}", value);
23    } else {
24        println!("{:#?}", resp.unwrap_err());
25    }
26}
Source

pub async fn get_monitor_with_http_info( &self, monitor_id: i64, params: GetMonitorOptionalParams, ) -> Result<ResponseContent<Monitor>, Error<GetMonitorError>>

Get details about the specified monitor from your organization.

Source

pub async fn list_monitors( &self, params: ListMonitorsOptionalParams, ) -> Result<Vec<Monitor>, Error<ListMonitorsError>>

Get all monitors from your organization.

Examples found in repository?
examples/v1_monitors_ListMonitors.rs (line 11)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = MonitorsAPI::with_config(configuration);
10    let resp = api
11        .list_monitors(ListMonitorsOptionalParams::default())
12        .await;
13    if let Ok(value) = resp {
14        println!("{:#?}", value);
15    } else {
16        println!("{:#?}", resp.unwrap_err());
17    }
18}
More examples
Hide additional examples
examples/v1_monitors_ListMonitors_2154432960.rs (lines 11-15)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = MonitorsAPI::with_config(configuration);
10    let resp = api
11        .list_monitors(
12            ListMonitorsOptionalParams::default()
13                .tags("test:examplemonitor".to_string())
14                .page_size(1),
15        )
16        .await;
17    if let Ok(value) = resp {
18        println!("{:#?}", value);
19    } else {
20        println!("{:#?}", resp.unwrap_err());
21    }
22}
Source

pub fn list_monitors_with_pagination( &self, params: ListMonitorsOptionalParams, ) -> impl Stream<Item = Result<Monitor, Error<ListMonitorsError>>> + '_

Examples found in repository?
examples/v1_monitors_ListMonitors_463213563.rs (line 13)
9async fn main() {
10    let configuration = datadog::Configuration::new();
11    let api = MonitorsAPI::with_config(configuration);
12    let response =
13        api.list_monitors_with_pagination(ListMonitorsOptionalParams::default().page_size(2));
14    pin_mut!(response);
15    while let Some(resp) = response.next().await {
16        if let Ok(value) = resp {
17            println!("{:#?}", value);
18        } else {
19            println!("{:#?}", resp.unwrap_err());
20        }
21    }
22}
Source

pub async fn list_monitors_with_http_info( &self, params: ListMonitorsOptionalParams, ) -> Result<ResponseContent<Vec<Monitor>>, Error<ListMonitorsError>>

Get all monitors from your organization.

Source

pub async fn search_monitor_groups( &self, params: SearchMonitorGroupsOptionalParams, ) -> Result<MonitorGroupSearchResponse, Error<SearchMonitorGroupsError>>

Search and filter your monitor groups details.

Examples found in repository?
examples/v1_monitors_SearchMonitorGroups.rs (line 11)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = MonitorsAPI::with_config(configuration);
10    let resp = api
11        .search_monitor_groups(SearchMonitorGroupsOptionalParams::default())
12        .await;
13    if let Ok(value) = resp {
14        println!("{:#?}", value);
15    } else {
16        println!("{:#?}", resp.unwrap_err());
17    }
18}
Source

pub async fn search_monitor_groups_with_http_info( &self, params: SearchMonitorGroupsOptionalParams, ) -> Result<ResponseContent<MonitorGroupSearchResponse>, Error<SearchMonitorGroupsError>>

Search and filter your monitor groups details.

Source

pub async fn search_monitors( &self, params: SearchMonitorsOptionalParams, ) -> Result<MonitorSearchResponse, Error<SearchMonitorsError>>

Search and filter your monitors details.

Examples found in repository?
examples/v1_monitors_SearchMonitors.rs (line 11)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = MonitorsAPI::with_config(configuration);
10    let resp = api
11        .search_monitors(SearchMonitorsOptionalParams::default())
12        .await;
13    if let Ok(value) = resp {
14        println!("{:#?}", value);
15    } else {
16        println!("{:#?}", resp.unwrap_err());
17    }
18}
Source

pub async fn search_monitors_with_http_info( &self, params: SearchMonitorsOptionalParams, ) -> Result<ResponseContent<MonitorSearchResponse>, Error<SearchMonitorsError>>

Search and filter your monitors details.

Source

pub async fn update_monitor( &self, monitor_id: i64, body: MonitorUpdateRequest, ) -> Result<Monitor, Error<UpdateMonitorError>>

Edit the specified monitor.

Examples found in repository?
examples/v1_monitors_UpdateMonitor.rs (line 26)
9async fn main() {
10    // there is a valid "monitor" in the system
11    let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
12    let body = MonitorUpdateRequest::new()
13        .name("My monitor-updated".to_string())
14        .options(
15            MonitorOptions::new()
16                .evaluation_delay(None)
17                .new_group_delay(Some(600))
18                .new_host_delay(None)
19                .renotify_interval(None)
20                .thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(None))
21                .timeout_h(None),
22        )
23        .priority(None);
24    let configuration = datadog::Configuration::new();
25    let api = MonitorsAPI::with_config(configuration);
26    let resp = api.update_monitor(monitor_id.clone(), body).await;
27    if let Ok(value) = resp {
28        println!("{:#?}", value);
29    } else {
30        println!("{:#?}", resp.unwrap_err());
31    }
32}
Source

pub async fn update_monitor_with_http_info( &self, monitor_id: i64, body: MonitorUpdateRequest, ) -> Result<ResponseContent<Monitor>, Error<UpdateMonitorError>>

Edit the specified monitor.

Source

pub async fn validate_existing_monitor( &self, monitor_id: i64, body: Monitor, ) -> Result<BTreeMap<String, Value>, Error<ValidateExistingMonitorError>>

Validate the monitor provided in the request.

Examples found in repository?
examples/v1_monitors_ValidateExistingMonitor.rs (line 45)
12async fn main() {
13    // there is a valid "monitor" in the system
14    let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
15    let body =
16        Monitor::new(
17            r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
18            MonitorType::LOG_ALERT,
19        )
20            .message("some message Notify: @hipchat-channel".to_string())
21            .name("Example-Monitor".to_string())
22            .options(
23                MonitorOptions::new()
24                    .enable_logs_sample(true)
25                    .escalation_message("the situation has escalated".to_string())
26                    .evaluation_delay(Some(700))
27                    .include_tags(true)
28                    .locked(false)
29                    .new_host_delay(Some(600))
30                    .no_data_timeframe(None)
31                    .notification_preset_name(MonitorOptionsNotificationPresets::HIDE_HANDLES)
32                    .notify_audit(false)
33                    .notify_no_data(false)
34                    .on_missing_data(OnMissingDataOption::SHOW_AND_NOTIFY_NO_DATA)
35                    .renotify_interval(Some(60))
36                    .require_full_window(true)
37                    .thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(Some(1.0 as f64)))
38                    .timeout_h(Some(24)),
39            )
40            .priority(Some(3))
41            .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
42    let configuration = datadog::Configuration::new();
43    let api = MonitorsAPI::with_config(configuration);
44    let resp = api
45        .validate_existing_monitor(monitor_id.clone(), body)
46        .await;
47    if let Ok(value) = resp {
48        println!("{:#?}", value);
49    } else {
50        println!("{:#?}", resp.unwrap_err());
51    }
52}
Source

pub async fn validate_existing_monitor_with_http_info( &self, monitor_id: i64, body: Monitor, ) -> Result<ResponseContent<BTreeMap<String, Value>>, Error<ValidateExistingMonitorError>>

Validate the monitor provided in the request.

Source

pub async fn validate_monitor( &self, body: Monitor, ) -> Result<BTreeMap<String, Value>, Error<ValidateMonitorError>>

Validate the monitor provided in the request.

Note: Log monitors require an unscoped App Key.

Examples found in repository?
examples/v1_monitors_ValidateMonitor.rs (line 42)
12async fn main() {
13    let body =
14        Monitor::new(
15            r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
16            MonitorType::LOG_ALERT,
17        )
18            .message("some message Notify: @hipchat-channel".to_string())
19            .name("Example-Monitor".to_string())
20            .options(
21                MonitorOptions::new()
22                    .enable_logs_sample(true)
23                    .escalation_message("the situation has escalated".to_string())
24                    .evaluation_delay(Some(700))
25                    .include_tags(true)
26                    .locked(false)
27                    .new_host_delay(Some(600))
28                    .no_data_timeframe(None)
29                    .notification_preset_name(MonitorOptionsNotificationPresets::HIDE_HANDLES)
30                    .notify_audit(false)
31                    .notify_no_data(false)
32                    .on_missing_data(OnMissingDataOption::SHOW_AND_NOTIFY_NO_DATA)
33                    .renotify_interval(Some(60))
34                    .require_full_window(true)
35                    .thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(Some(1.0 as f64)))
36                    .timeout_h(Some(24)),
37            )
38            .priority(Some(3))
39            .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
40    let configuration = datadog::Configuration::new();
41    let api = MonitorsAPI::with_config(configuration);
42    let resp = api.validate_monitor(body).await;
43    if let Ok(value) = resp {
44        println!("{:#?}", value);
45    } else {
46        println!("{:#?}", resp.unwrap_err());
47    }
48}
More examples
Hide additional examples
examples/v1_monitors_ValidateMonitor_4247196452.rs (line 42)
11async fn main() {
12    let body =
13        Monitor::new(
14            r#"logs("service:foo AND type:error").index("main").rollup("count").by("source,status").last("5m") > 2"#.to_string(),
15            MonitorType::LOG_ALERT,
16        )
17            .message("some message Notify: @hipchat-channel".to_string())
18            .name("Example-Monitor".to_string())
19            .options(
20                MonitorOptions::new()
21                    .enable_logs_sample(true)
22                    .escalation_message("the situation has escalated".to_string())
23                    .evaluation_delay(Some(700))
24                    .group_retention_duration("2d".to_string())
25                    .include_tags(true)
26                    .locked(false)
27                    .new_host_delay(Some(600))
28                    .no_data_timeframe(None)
29                    .notify_audit(false)
30                    .notify_by(vec!["status".to_string()])
31                    .notify_no_data(false)
32                    .on_missing_data(OnMissingDataOption::SHOW_AND_NOTIFY_NO_DATA)
33                    .renotify_interval(Some(60))
34                    .require_full_window(true)
35                    .thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(Some(1.0 as f64)))
36                    .timeout_h(Some(24)),
37            )
38            .priority(Some(3))
39            .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
40    let configuration = datadog::Configuration::new();
41    let api = MonitorsAPI::with_config(configuration);
42    let resp = api.validate_monitor(body).await;
43    if let Ok(value) = resp {
44        println!("{:#?}", value);
45    } else {
46        println!("{:#?}", resp.unwrap_err());
47    }
48}
Source

pub async fn validate_monitor_with_http_info( &self, body: Monitor, ) -> Result<ResponseContent<BTreeMap<String, Value>>, Error<ValidateMonitorError>>

Validate the monitor provided in the request.

Note: Log monitors require an unscoped App Key.

Trait Implementations§

Source§

impl Clone for MonitorsAPI

Source§

fn clone(&self) -> MonitorsAPI

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MonitorsAPI

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MonitorsAPI

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T