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
 
impl MonitorsAPI
pub fn new() -> Self
Sourcepub fn with_config(config: Configuration) -> Self
 
pub fn with_config(config: Configuration) -> Self
Examples found in repository?
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
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}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}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}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}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}- examples/v1_monitors_DeleteMonitor.rs
 - examples/v1_monitors_GetMonitor.rs
 - examples/v1_monitors_GetMonitor_2200114573.rs
 - examples/v1_monitors_GetMonitor_3691711704.rs
 - examples/v1_monitors_CreateMonitor_2520912138.rs
 - examples/v1_monitors_CreateMonitor_440013737.rs
 - examples/v1_monitors_CreateMonitor_3790803616.rs
 - examples/v1_monitors_UpdateMonitor.rs
 - examples/v1_monitors_CreateMonitor.rs
 - examples/v1_monitors_CreateMonitor_2012680290.rs
 - examples/v1_monitors_CreateMonitor_1539578087.rs
 - examples/v1_monitors_ValidateMonitor.rs
 - examples/v1_monitors_ValidateMonitor_4247196452.rs
 - examples/v1_monitors_CreateMonitor_1303514967.rs
 - examples/v1_monitors_ValidateExistingMonitor.rs
 - examples/v1_monitors_CreateMonitor_3883669300.rs
 - examples/v1_monitors_CreateMonitor_1969035628.rs
 - examples/v1_monitors_CreateMonitor_3824294658.rs
 
pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self
Sourcepub async fn check_can_delete_monitor(
    &self,
    monitor_ids: Vec<i64>,
) -> Result<CheckCanDeleteMonitorResponse, Error<CheckCanDeleteMonitorError>>
 
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?
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}Sourcepub async fn check_can_delete_monitor_with_http_info(
    &self,
    monitor_ids: Vec<i64>,
) -> Result<ResponseContent<CheckCanDeleteMonitorResponse>, Error<CheckCanDeleteMonitorError>>
 
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.
Sourcepub async fn create_monitor(
    &self,
    body: Monitor,
) -> Result<Monitor, Error<CreateMonitorError>>
 
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 alertortrace-analytics alert - composite: 
composite - custom: 
service check - forecast: 
query alert - host: 
service check - integration: 
query alertorservice 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_changetime_window:last_#m(with#between 1 and 10080 depending on the monitor type) orlast_#h(with#between 1 and 168 depending on the monitor type) orlast_1d, orlast_1wspace_aggr: avg, sum, min, or maxtags: 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_aggrchange, pct_changetime_aggravg, sum, max, min Learn moretime_windowlast_#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()
checkname of the check, for exampledatadog.agent.uptagsone or more quoted tags (comma-separated), or “*”. for example:.over("env:prod", "role:db");overcannot be blank.countmust be at greater than or equal to your max threshold (defined in theoptions). It is limited to 100. For example, if you’ve specified to notify on 1 critical, 3 ok, and 2 warn statuses,countshould be at least 3.groupmust be specified for check monitors. Per-check grouping is already explicitly known for some service checks. For example, Postgres integration monitors are tagged bydb,host, andport, and Network monitors byhost,instance, andurl. 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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_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 #
searchfree text search string for querying processes. Matching processes match results on the Live Processes page.tagsone or more tags (comma-separated)timeframethe timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and doperator<, <=, >, >=, ==, 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 #
queryThe search query - following the Log search syntax.index_nameFor multi-index organizations, the log index in which the request is performed.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_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 themonitor_tagsargument 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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.issue_sourceThe issue source - supportsall,browser,mobileandbackendand defaults toallif omitted.rollup_methodThe stats roll-up method - supportscount,avg, andcardinalityand defaults tocountif omitted.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.group byComma-separated list of attributes to group by - should contain at leastissue.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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.timeframe_typeThe timeframe type to evaluate the cost - forforecastsupportscurrent- forchange,anomaly,thresholdsupportslasttime_window- supports daily roll-up e.g.7dfunction- [optional, defaults tothresholdmonitor if omitted] supportschange,anomaly,forecastparameterSpecify the parameter of the type- for 
change:- supports 
relative,absolute - [optional] supports 
#, where#is an integer or decimal number used to set the threshold 
 - supports 
 - for 
anomaly:- supports 
direction=both,direction=above,direction=below - [optional] supports 
threshold=#, where#is an integer or decimal number used to set the threshold 
 - supports 
 
- for 
 operator- for 
thresholdsupports<,<=,>,>=,==, or!= - for 
changesupports>,< - for 
anomalysupports>= - for 
forecastsupports> 
- for 
 #an integer or decimal number used to set the threshold.
Examples found in repository?
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}More examples
11async fn main() {
12    let body =
13        Monitor::new(
14            r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
15            MonitorType::ERROR_TRACKING_ALERT,
16        )
17            .draft_status(MonitorDraftStatus::DRAFT)
18            .message("some message".to_string())
19            .name("Example-Monitor".to_string())
20            .options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
21            .priority(Some(3))
22            .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
23    let configuration = datadog::Configuration::new();
24    let api = MonitorsAPI::with_config(configuration);
25    let resp = api.create_monitor(body).await;
26    if let Ok(value) = resp {
27        println!("{:#?}", value);
28    } else {
29        println!("{:#?}", resp.unwrap_err());
30    }
31}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}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}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}15async fn main() {
16    let body = Monitor::new(
17        "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
18        MonitorType::QUERY_ALERT,
19    )
20    .draft_status(MonitorDraftStatus::PUBLISHED)
21    .message("some message Notify: @hipchat-channel".to_string())
22    .name("Example-Monitor".to_string())
23    .options(
24        MonitorOptions::new()
25            .include_tags(false)
26            .notify_audit(false)
27            .scheduling_options(
28                MonitorOptionsSchedulingOptions::new()
29                    .custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
30                                        MonitorOptionsCustomScheduleRecurrence::new()
31                                            .rrule("FREQ=DAILY;INTERVAL=1".to_string())
32                                            .start("2024-10-26T09:13:00".to_string())
33                                            .timezone("America/Los_Angeles".to_string())
34                                    ]))
35                    .evaluation_window(
36                        MonitorOptionsSchedulingOptionsEvaluationWindow::new()
37                            .day_starts("04:00".to_string())
38                            .month_starts(1),
39                    ),
40            )
41            .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
42    )
43    .tags(vec![]);
44    let configuration = datadog::Configuration::new();
45    let api = MonitorsAPI::with_config(configuration);
46    let resp = api.create_monitor(body).await;
47    if let Ok(value) = resp {
48        println!("{:#?}", value);
49    } else {
50        println!("{:#?}", resp.unwrap_err());
51    }
52}Sourcepub async fn create_monitor_with_http_info(
    &self,
    body: Monitor,
) -> Result<ResponseContent<Monitor>, Error<CreateMonitorError>>
 
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 alertortrace-analytics alert - composite: 
composite - custom: 
service check - forecast: 
query alert - host: 
service check - integration: 
query alertorservice 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_changetime_window:last_#m(with#between 1 and 10080 depending on the monitor type) orlast_#h(with#between 1 and 168 depending on the monitor type) orlast_1d, orlast_1wspace_aggr: avg, sum, min, or maxtags: 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_aggrchange, pct_changetime_aggravg, sum, max, min Learn moretime_windowlast_#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()
checkname of the check, for exampledatadog.agent.uptagsone or more quoted tags (comma-separated), or “*”. for example:.over("env:prod", "role:db");overcannot be blank.countmust be at greater than or equal to your max threshold (defined in theoptions). It is limited to 100. For example, if you’ve specified to notify on 1 critical, 3 ok, and 2 warn statuses,countshould be at least 3.groupmust be specified for check monitors. Per-check grouping is already explicitly known for some service checks. For example, Postgres integration monitors are tagged bydb,host, andport, and Network monitors byhost,instance, andurl. 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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_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 #
searchfree text search string for querying processes. Matching processes match results on the Live Processes page.tagsone or more tags (comma-separated)timeframethe timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and doperator<, <=, >, >=, ==, 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 #
queryThe search query - following the Log search syntax.index_nameFor multi-index organizations, the log index in which the request is performed.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_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 themonitor_tagsargument 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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.issue_sourceThe issue source - supportsall,browser,mobileandbackendand defaults toallif omitted.rollup_methodThe stats roll-up method - supportscount,avg, andcardinalityand defaults tocountif omitted.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.group byComma-separated list of attributes to group by - should contain at leastissue.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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_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 #
queryThe search query - following the Log search syntax.timeframe_typeThe timeframe type to evaluate the cost - forforecastsupportscurrent- forchange,anomaly,thresholdsupportslasttime_window- supports daily roll-up e.g.7dfunction- [optional, defaults tothresholdmonitor if omitted] supportschange,anomaly,forecastparameterSpecify the parameter of the type- for 
change:- supports 
relative,absolute - [optional] supports 
#, where#is an integer or decimal number used to set the threshold 
 - supports 
 - for 
anomaly:- supports 
direction=both,direction=above,direction=below - [optional] supports 
threshold=#, where#is an integer or decimal number used to set the threshold 
 - supports 
 
- for 
 operator- for 
thresholdsupports<,<=,>,>=,==, or!= - for 
changesupports>,< - for 
anomalysupports>= - for 
forecastsupports> 
- for 
 #an integer or decimal number used to set the threshold.
Sourcepub async fn delete_monitor(
    &self,
    monitor_id: i64,
    params: DeleteMonitorOptionalParams,
) -> Result<DeletedMonitor, Error<DeleteMonitorError>>
 
pub async fn delete_monitor( &self, monitor_id: i64, params: DeleteMonitorOptionalParams, ) -> Result<DeletedMonitor, Error<DeleteMonitorError>>
Delete the specified monitor
Examples found in repository?
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}Sourcepub async fn delete_monitor_with_http_info(
    &self,
    monitor_id: i64,
    params: DeleteMonitorOptionalParams,
) -> Result<ResponseContent<DeletedMonitor>, Error<DeleteMonitorError>>
 
pub async fn delete_monitor_with_http_info( &self, monitor_id: i64, params: DeleteMonitorOptionalParams, ) -> Result<ResponseContent<DeletedMonitor>, Error<DeleteMonitorError>>
Delete the specified monitor
Sourcepub async fn get_monitor(
    &self,
    monitor_id: i64,
    params: GetMonitorOptionalParams,
) -> Result<Monitor, Error<GetMonitorError>>
 
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?
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
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}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}Sourcepub async fn get_monitor_with_http_info(
    &self,
    monitor_id: i64,
    params: GetMonitorOptionalParams,
) -> Result<ResponseContent<Monitor>, Error<GetMonitorError>>
 
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.
Sourcepub async fn list_monitors(
    &self,
    params: ListMonitorsOptionalParams,
) -> Result<Vec<Monitor>, Error<ListMonitorsError>>
 
pub async fn list_monitors( &self, params: ListMonitorsOptionalParams, ) -> Result<Vec<Monitor>, Error<ListMonitorsError>>
Get all monitors from your organization.
Examples found in repository?
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
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}Sourcepub fn list_monitors_with_pagination(
    &self,
    params: ListMonitorsOptionalParams,
) -> impl Stream<Item = Result<Monitor, Error<ListMonitorsError>>> + '_
 
pub fn list_monitors_with_pagination( &self, params: ListMonitorsOptionalParams, ) -> impl Stream<Item = Result<Monitor, Error<ListMonitorsError>>> + '_
Examples found in repository?
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}Sourcepub async fn list_monitors_with_http_info(
    &self,
    params: ListMonitorsOptionalParams,
) -> Result<ResponseContent<Vec<Monitor>>, Error<ListMonitorsError>>
 
pub async fn list_monitors_with_http_info( &self, params: ListMonitorsOptionalParams, ) -> Result<ResponseContent<Vec<Monitor>>, Error<ListMonitorsError>>
Get all monitors from your organization.
Sourcepub async fn search_monitor_groups(
    &self,
    params: SearchMonitorGroupsOptionalParams,
) -> Result<MonitorGroupSearchResponse, Error<SearchMonitorGroupsError>>
 
pub async fn search_monitor_groups( &self, params: SearchMonitorGroupsOptionalParams, ) -> Result<MonitorGroupSearchResponse, Error<SearchMonitorGroupsError>>
Search and filter your monitor groups details.
Examples found in repository?
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}Sourcepub async fn search_monitor_groups_with_http_info(
    &self,
    params: SearchMonitorGroupsOptionalParams,
) -> Result<ResponseContent<MonitorGroupSearchResponse>, Error<SearchMonitorGroupsError>>
 
pub async fn search_monitor_groups_with_http_info( &self, params: SearchMonitorGroupsOptionalParams, ) -> Result<ResponseContent<MonitorGroupSearchResponse>, Error<SearchMonitorGroupsError>>
Search and filter your monitor groups details.
Sourcepub async fn search_monitors(
    &self,
    params: SearchMonitorsOptionalParams,
) -> Result<MonitorSearchResponse, Error<SearchMonitorsError>>
 
pub async fn search_monitors( &self, params: SearchMonitorsOptionalParams, ) -> Result<MonitorSearchResponse, Error<SearchMonitorsError>>
Search and filter your monitors details.
Examples found in repository?
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}Sourcepub async fn search_monitors_with_http_info(
    &self,
    params: SearchMonitorsOptionalParams,
) -> Result<ResponseContent<MonitorSearchResponse>, Error<SearchMonitorsError>>
 
pub async fn search_monitors_with_http_info( &self, params: SearchMonitorsOptionalParams, ) -> Result<ResponseContent<MonitorSearchResponse>, Error<SearchMonitorsError>>
Search and filter your monitors details.
Sourcepub async fn update_monitor(
    &self,
    monitor_id: i64,
    body: MonitorUpdateRequest,
) -> Result<Monitor, Error<UpdateMonitorError>>
 
pub async fn update_monitor( &self, monitor_id: i64, body: MonitorUpdateRequest, ) -> Result<Monitor, Error<UpdateMonitorError>>
Edit the specified monitor.
Examples found in repository?
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}Sourcepub async fn update_monitor_with_http_info(
    &self,
    monitor_id: i64,
    body: MonitorUpdateRequest,
) -> Result<ResponseContent<Monitor>, Error<UpdateMonitorError>>
 
pub async fn update_monitor_with_http_info( &self, monitor_id: i64, body: MonitorUpdateRequest, ) -> Result<ResponseContent<Monitor>, Error<UpdateMonitorError>>
Edit the specified monitor.
Sourcepub async fn validate_existing_monitor(
    &self,
    monitor_id: i64,
    body: Monitor,
) -> Result<BTreeMap<String, Value>, Error<ValidateExistingMonitorError>>
 
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?
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}Sourcepub async fn validate_existing_monitor_with_http_info(
    &self,
    monitor_id: i64,
    body: Monitor,
) -> Result<ResponseContent<BTreeMap<String, Value>>, Error<ValidateExistingMonitorError>>
 
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.
Sourcepub async fn validate_monitor(
    &self,
    body: Monitor,
) -> Result<BTreeMap<String, Value>, Error<ValidateMonitorError>>
 
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?
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
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}Sourcepub async fn validate_monitor_with_http_info(
    &self,
    body: Monitor,
) -> Result<ResponseContent<BTreeMap<String, Value>>, Error<ValidateMonitorError>>
 
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
 
impl Clone for MonitorsAPI
Source§fn clone(&self) -> MonitorsAPI
 
fn clone(&self) -> MonitorsAPI
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read more