#[non_exhaustive]pub struct MonitorOptions {Show 32 fields
pub aggregation: Option<MonitorOptionsAggregation>,
pub device_ids: Option<Vec<MonitorDeviceID>>,
pub enable_logs_sample: Option<bool>,
pub enable_samples: Option<bool>,
pub escalation_message: Option<String>,
pub evaluation_delay: Option<Option<i64>>,
pub group_retention_duration: Option<String>,
pub groupby_simple_monitor: Option<bool>,
pub include_tags: Option<bool>,
pub locked: Option<bool>,
pub min_failure_duration: Option<Option<i64>>,
pub min_location_failed: Option<Option<i64>>,
pub new_group_delay: Option<Option<i64>>,
pub new_host_delay: Option<Option<i64>>,
pub no_data_timeframe: Option<Option<i64>>,
pub notification_preset_name: Option<MonitorOptionsNotificationPresets>,
pub notify_audit: Option<bool>,
pub notify_by: Option<Vec<String>>,
pub notify_no_data: Option<bool>,
pub on_missing_data: Option<OnMissingDataOption>,
pub renotify_interval: Option<Option<i64>>,
pub renotify_occurrences: Option<Option<i64>>,
pub renotify_statuses: Option<Option<Vec<MonitorRenotifyStatusType>>>,
pub require_full_window: Option<bool>,
pub scheduling_options: Option<MonitorOptionsSchedulingOptions>,
pub silenced: Option<BTreeMap<String, Option<i64>>>,
pub synthetics_check_id: Option<Option<String>>,
pub threshold_windows: Option<MonitorThresholdWindowOptions>,
pub thresholds: Option<MonitorThresholds>,
pub timeout_h: Option<Option<i64>>,
pub variables: Option<Vec<MonitorFormulaAndFunctionQueryDefinition>>,
pub additional_properties: BTreeMap<String, Value>,
/* private fields */
}
Expand description
List of options associated with your monitor.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.aggregation: Option<MonitorOptionsAggregation>
Type of aggregation performed in the monitor query.
device_ids: Option<Vec<MonitorDeviceID>>
IDs of the device the Synthetics monitor is running on.
enable_logs_sample: Option<bool>
Whether or not to send a log sample when the log monitor triggers.
enable_samples: Option<bool>
Whether or not to send a list of samples when the monitor triggers. This is only used by CI Test and Pipeline monitors.
escalation_message: Option<String>
We recommend using the is_renotify,
block in the original message instead.
A message to include with a re-notification. Supports the @username
notification we allow elsewhere.
Not applicable if renotify_interval
is None
.
evaluation_delay: Option<Option<i64>>
Time (in seconds) to delay evaluation, as a non-negative integer. For example, if the value is set to 300
(5min),
the timeframe is set to last_5m
and the time is 7:00, the monitor evaluates data from 6:50 to 6:55.
This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.
group_retention_duration: Option<String>
The time span after which groups with missing data are dropped from the monitor state. The minimum value is one hour, and the maximum value is 72 hours. Example values are: “60m”, “1h”, and “2d”. This option is only available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors.
groupby_simple_monitor: Option<bool>
Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold. Use notify_by
instead.
A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.
Examples
- If
True
,[Triggered on {host:h1}] Monitor Title
- If
False
,[Triggered] Monitor Title
locked: Option<bool>
Whether or not the monitor is locked (only editable by creator and admins). Use restricted_roles
instead.
min_failure_duration: Option<Option<i64>>
How long the test should be in failure before alerting (integer, number of seconds, max 7200).
min_location_failed: Option<Option<i64>>
The minimum number of locations in failure at the same time during
at least one moment in the min_failure_duration
period (min_location_failed
and min_failure_duration
are part of the advanced alerting rules - integer, >= 1).
new_group_delay: Option<Option<i64>>
Time (in seconds) to skip evaluations for new groups.
For example, this option can be used to skip evaluations for new hosts while they initialize.
Must be a non negative integer.
new_host_delay: Option<Option<i64>>
Time (in seconds) to allow a host to boot and applications to fully start before starting the evaluation of monitor results. Should be a non negative integer.
Use new_group_delay instead.
no_data_timeframe: Option<Option<i64>>
The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.
notification_preset_name: Option<MonitorOptionsNotificationPresets>
Toggles the display of additional content sent in the monitor notification.
notify_audit: Option<bool>
A Boolean indicating whether tagged users is notified on changes to this monitor.
notify_by: Option<Vec<String>>
Controls what granularity a monitor alerts on. Only available for monitors with groupings.
For instance, a monitor grouped by cluster
, namespace
, and pod
can be configured to only notify on each
new cluster
violating the alert conditions by setting notify_by
to ["cluster"]
. Tags mentioned
in notify_by
must be a subset of the grouping tags in the query.
For example, a query grouped by cluster
and namespace
cannot notify on region
.
Setting notify_by
to ["*"]
configures the monitor to notify as a simple-alert.
notify_no_data: Option<bool>
A Boolean indicating whether this monitor notifies when data stops reporting. Defaults to false
.
on_missing_data: Option<OnMissingDataOption>
Controls how groups or monitors are treated if an evaluation does not return any data points. The default option results in different behavior depending on the monitor query type. For monitors using Count queries, an empty monitor evaluation is treated as 0 and is compared to the threshold conditions. For monitors using any query type other than Count, for example Gauge, Measure, or Rate, the monitor shows the last known status. This option is only available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors.
renotify_interval: Option<Option<i64>>
The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.
renotify_occurrences: Option<Option<i64>>
The number of times re-notification messages should be sent on the current status at the provided re-notification interval.
renotify_statuses: Option<Option<Vec<MonitorRenotifyStatusType>>>
The types of monitor statuses for which re-notification messages are sent.
Default: null if renotify_interval
is null.
If renotify_interval
is set, defaults to renotify on Alert
and No Data
.
require_full_window: Option<bool>
A Boolean indicating whether this monitor needs a full window of data before it’s evaluated.
We highly recommend you set this to false
for sparse metrics,
otherwise some evaluations are skipped. Default is false. This setting only applies to
metric monitors.
scheduling_options: Option<MonitorOptionsSchedulingOptions>
Configuration options for scheduling.
silenced: Option<BTreeMap<String, Option<i64>>>
Information about the downtime applied to the monitor. Only shows v1 downtimes.
synthetics_check_id: Option<Option<String>>
ID of the corresponding Synthetic check.
threshold_windows: Option<MonitorThresholdWindowOptions>
Alerting time window options.
thresholds: Option<MonitorThresholds>
List of the different monitor threshold available.
timeout_h: Option<Option<i64>>
The number of hours of the monitor not reporting data before it automatically resolves from a triggered state. The minimum allowed value is 0 hours. The maximum allowed value is 24 hours.
variables: Option<Vec<MonitorFormulaAndFunctionQueryDefinition>>
List of requests that can be used in the monitor query. This feature is currently in beta.
additional_properties: BTreeMap<String, Value>
Implementations§
Source§impl MonitorOptions
impl MonitorOptions
Sourcepub fn new() -> MonitorOptions
pub fn new() -> MonitorOptions
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}
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}
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}
- 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 aggregation(self, value: MonitorOptionsAggregation) -> Self
pub fn device_ids(self, value: Vec<MonitorDeviceID>) -> Self
Sourcepub fn enable_logs_sample(self, value: bool) -> Self
pub fn enable_logs_sample(self, value: bool) -> Self
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}
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}
pub fn enable_samples(self, value: bool) -> Self
Sourcepub fn escalation_message(self, value: String) -> Self
pub fn escalation_message(self, value: String) -> Self
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}
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 fn evaluation_delay(self, value: Option<i64>) -> Self
pub fn evaluation_delay(self, value: Option<i64>) -> Self
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}
More examples
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}
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}
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 fn group_retention_duration(self, value: String) -> Self
pub fn group_retention_duration(self, value: String) -> Self
Examples found in repository?
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}
pub fn groupby_simple_monitor(self, value: bool) -> Self
Examples found in repository?
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}
More examples
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}
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}
14async fn main() {
15 let body =
16 Monitor::new(
17 r#"formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5"#.to_string(),
18 MonitorType::COST_ALERT,
19 )
20 .message("some message Notify: @hipchat-channel".to_string())
21 .name("Example Monitor".to_string())
22 .options(
23 MonitorOptions::new()
24 .include_tags(true)
25 .thresholds(MonitorThresholds::new().critical(5.0 as f64).warning(Some(3.0 as f64)))
26 .variables(
27 vec![
28 MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionCostQueryDefinition(
29 Box::new(
30 MonitorFormulaAndFunctionCostQueryDefinition::new(
31 MonitorFormulaAndFunctionCostDataSource::CLOUD_COST,
32 "query1".to_string(),
33 "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)".to_string(),
34 ).aggregator(MonitorFormulaAndFunctionCostAggregator::SUM),
35 ),
36 )
37 ],
38 ),
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.create_monitor(body).await;
45 if let Ok(value) = resp {
46 println!("{:#?}", value);
47 } else {
48 println!("{:#?}", resp.unwrap_err());
49 }
50}
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 fn locked(self, value: bool) -> Self
pub fn locked(self, value: bool) -> Self
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}
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}
pub fn min_failure_duration(self, value: Option<i64>) -> Self
pub fn min_location_failed(self, value: Option<i64>) -> Self
Sourcepub fn new_group_delay(self, value: Option<i64>) -> Self
pub fn new_group_delay(self, value: Option<i64>) -> Self
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 fn new_host_delay(self, value: Option<i64>) -> Self
pub fn new_host_delay(self, value: Option<i64>) -> Self
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}
More examples
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}
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}
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 fn no_data_timeframe(self, value: Option<i64>) -> Self
pub fn no_data_timeframe(self, value: Option<i64>) -> Self
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}
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 fn notification_preset_name(
self,
value: MonitorOptionsNotificationPresets,
) -> Self
pub fn notification_preset_name( self, value: MonitorOptionsNotificationPresets, ) -> Self
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
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 fn notify_audit(self, value: bool) -> Self
pub fn notify_audit(self, value: bool) -> Self
Examples found in repository?
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}
More examples
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}
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}
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 fn notify_by(self, value: Vec<String>) -> Self
pub fn notify_by(self, value: Vec<String>) -> Self
Examples found in repository?
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 fn notify_no_data(self, value: bool) -> Self
pub fn notify_no_data(self, value: bool) -> Self
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}
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 fn on_missing_data(self, value: OnMissingDataOption) -> Self
pub fn on_missing_data(self, value: OnMissingDataOption) -> Self
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}
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 fn renotify_interval(self, value: Option<i64>) -> Self
pub fn renotify_interval(self, value: Option<i64>) -> Self
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}
More examples
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}
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}
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}
pub fn renotify_occurrences(self, value: Option<i64>) -> Self
pub fn renotify_statuses( self, value: Option<Vec<MonitorRenotifyStatusType>>, ) -> Self
Sourcepub fn require_full_window(self, value: bool) -> Self
pub fn require_full_window(self, value: bool) -> Self
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}
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 fn scheduling_options(self, value: MonitorOptionsSchedulingOptions) -> Self
pub fn scheduling_options(self, value: MonitorOptionsSchedulingOptions) -> Self
Examples found in repository?
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}
More examples
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}
pub fn silenced(self, value: BTreeMap<String, Option<i64>>) -> Self
pub fn synthetics_check_id(self, value: Option<String>) -> Self
pub fn threshold_windows(self, value: MonitorThresholdWindowOptions) -> Self
Sourcepub fn thresholds(self, value: MonitorThresholds) -> Self
pub fn thresholds(self, value: MonitorThresholds) -> Self
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}
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}
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}
- 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
Sourcepub fn timeout_h(self, value: Option<i64>) -> Self
pub fn timeout_h(self, value: Option<i64>) -> Self
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}
More examples
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}
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}
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 fn variables(
self,
value: Vec<MonitorFormulaAndFunctionQueryDefinition>,
) -> Self
pub fn variables( self, value: Vec<MonitorFormulaAndFunctionQueryDefinition>, ) -> Self
Examples found in repository?
14async fn main() {
15 let body =
16 Monitor::new(
17 r#"formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5"#.to_string(),
18 MonitorType::COST_ALERT,
19 )
20 .message("some message Notify: @hipchat-channel".to_string())
21 .name("Example Monitor".to_string())
22 .options(
23 MonitorOptions::new()
24 .include_tags(true)
25 .thresholds(MonitorThresholds::new().critical(5.0 as f64).warning(Some(3.0 as f64)))
26 .variables(
27 vec![
28 MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionCostQueryDefinition(
29 Box::new(
30 MonitorFormulaAndFunctionCostQueryDefinition::new(
31 MonitorFormulaAndFunctionCostDataSource::CLOUD_COST,
32 "query1".to_string(),
33 "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)".to_string(),
34 ).aggregator(MonitorFormulaAndFunctionCostAggregator::SUM),
35 ),
36 )
37 ],
38 ),
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.create_monitor(body).await;
45 if let Ok(value) = resp {
46 println!("{:#?}", value);
47 } else {
48 println!("{:#?}", resp.unwrap_err());
49 }
50}
More examples
16async fn main() {
17 let body =
18 Monitor::new(r#"formula("query2 / query1 * 100").last("15m") >= 0.8"#.to_string(), MonitorType::RUM_ALERT)
19 .message("some message Notify: @hipchat-channel".to_string())
20 .name("Example-Monitor".to_string())
21 .options(
22 MonitorOptions::new()
23 .thresholds(MonitorThresholds::new().critical(0.8 as f64))
24 .variables(
25 vec![
26 MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionEventQueryDefinition(
27 Box::new(
28 MonitorFormulaAndFunctionEventQueryDefinition::new(
29 MonitorFormulaAndFunctionEventQueryDefinitionCompute::new(
30 MonitorFormulaAndFunctionEventAggregation::COUNT,
31 ),
32 MonitorFormulaAndFunctionEventsDataSource::RUM,
33 "query2".to_string(),
34 )
35 .group_by(vec![])
36 .indexes(vec!["*".to_string()])
37 .search(
38 MonitorFormulaAndFunctionEventQueryDefinitionSearch::new("".to_string()),
39 ),
40 ),
41 ),
42 MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionEventQueryDefinition(
43 Box::new(
44 MonitorFormulaAndFunctionEventQueryDefinition::new(
45 MonitorFormulaAndFunctionEventQueryDefinitionCompute::new(
46 MonitorFormulaAndFunctionEventAggregation::COUNT,
47 ),
48 MonitorFormulaAndFunctionEventsDataSource::RUM,
49 "query1".to_string(),
50 )
51 .group_by(vec![])
52 .indexes(vec!["*".to_string()])
53 .search(
54 MonitorFormulaAndFunctionEventQueryDefinitionSearch::new(
55 "status:error".to_string(),
56 ),
57 ),
58 ),
59 )
60 ],
61 ),
62 )
63 .priority(Some(3))
64 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
65 let configuration = datadog::Configuration::new();
66 let api = MonitorsAPI::with_config(configuration);
67 let resp = api.create_monitor(body).await;
68 if let Ok(value) = resp {
69 println!("{:#?}", value);
70 } else {
71 println!("{:#?}", resp.unwrap_err());
72 }
73}
16async fn main() {
17 let body =
18 Monitor::new(
19 r#"formula("query1 / query2 * 100").last("15m") >= 0.8"#.to_string(),
20 MonitorType::CI_TESTS_ALERT,
21 )
22 .message("some message Notify: @hipchat-channel".to_string())
23 .name("Example-Monitor".to_string())
24 .options(
25 MonitorOptions::new()
26 .thresholds(MonitorThresholds::new().critical(0.8 as f64))
27 .variables(
28 vec![
29 MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionEventQueryDefinition(
30 Box::new(
31 MonitorFormulaAndFunctionEventQueryDefinition::new(
32 MonitorFormulaAndFunctionEventQueryDefinitionCompute::new(
33 MonitorFormulaAndFunctionEventAggregation::COUNT,
34 ),
35 MonitorFormulaAndFunctionEventsDataSource::CI_TESTS,
36 "query1".to_string(),
37 )
38 .group_by(vec![])
39 .indexes(vec!["*".to_string()])
40 .search(
41 MonitorFormulaAndFunctionEventQueryDefinitionSearch::new(
42 "@test.status:fail".to_string(),
43 ),
44 ),
45 ),
46 ),
47 MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionEventQueryDefinition(
48 Box::new(
49 MonitorFormulaAndFunctionEventQueryDefinition::new(
50 MonitorFormulaAndFunctionEventQueryDefinitionCompute::new(
51 MonitorFormulaAndFunctionEventAggregation::COUNT,
52 ),
53 MonitorFormulaAndFunctionEventsDataSource::CI_TESTS,
54 "query2".to_string(),
55 )
56 .group_by(vec![])
57 .indexes(vec!["*".to_string()])
58 .search(
59 MonitorFormulaAndFunctionEventQueryDefinitionSearch::new("".to_string()),
60 ),
61 ),
62 )
63 ],
64 ),
65 )
66 .priority(Some(3))
67 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
68 let configuration = datadog::Configuration::new();
69 let api = MonitorsAPI::with_config(configuration);
70 let resp = api.create_monitor(body).await;
71 if let Ok(value) = resp {
72 println!("{:#?}", value);
73 } else {
74 println!("{:#?}", resp.unwrap_err());
75 }
76}
16async fn main() {
17 let body =
18 Monitor::new(
19 r#"formula("query1 / query2 * 100").last("15m") >= 0.8"#.to_string(),
20 MonitorType::CI_PIPELINES_ALERT,
21 )
22 .message("some message Notify: @hipchat-channel".to_string())
23 .name("Example-Monitor".to_string())
24 .options(
25 MonitorOptions::new()
26 .thresholds(MonitorThresholds::new().critical(0.8 as f64))
27 .variables(
28 vec![
29 MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionEventQueryDefinition(
30 Box::new(
31 MonitorFormulaAndFunctionEventQueryDefinition::new(
32 MonitorFormulaAndFunctionEventQueryDefinitionCompute::new(
33 MonitorFormulaAndFunctionEventAggregation::COUNT,
34 ),
35 MonitorFormulaAndFunctionEventsDataSource::CI_PIPELINES,
36 "query1".to_string(),
37 )
38 .group_by(vec![])
39 .indexes(vec!["*".to_string()])
40 .search(
41 MonitorFormulaAndFunctionEventQueryDefinitionSearch::new(
42 "@ci.status:error".to_string(),
43 ),
44 ),
45 ),
46 ),
47 MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionEventQueryDefinition(
48 Box::new(
49 MonitorFormulaAndFunctionEventQueryDefinition::new(
50 MonitorFormulaAndFunctionEventQueryDefinitionCompute::new(
51 MonitorFormulaAndFunctionEventAggregation::COUNT,
52 ),
53 MonitorFormulaAndFunctionEventsDataSource::CI_PIPELINES,
54 "query2".to_string(),
55 )
56 .group_by(vec![])
57 .indexes(vec!["*".to_string()])
58 .search(
59 MonitorFormulaAndFunctionEventQueryDefinitionSearch::new("".to_string()),
60 ),
61 ),
62 )
63 ],
64 ),
65 )
66 .priority(Some(3))
67 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
68 let configuration = datadog::Configuration::new();
69 let api = MonitorsAPI::with_config(configuration);
70 let resp = api.create_monitor(body).await;
71 if let Ok(value) = resp {
72 println!("{:#?}", value);
73 } else {
74 println!("{:#?}", resp.unwrap_err());
75 }
76}
pub fn additional_properties(self, value: BTreeMap<String, Value>) -> Self
Trait Implementations§
Source§impl Clone for MonitorOptions
impl Clone for MonitorOptions
Source§fn clone(&self) -> MonitorOptions
fn clone(&self) -> MonitorOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more