#[non_exhaustive]pub struct Monitor {Show 19 fields
pub created: Option<DateTime<Utc>>,
pub creator: Option<Creator>,
pub deleted: Option<Option<DateTime<Utc>>>,
pub draft_status: Option<MonitorDraftStatus>,
pub id: Option<i64>,
pub matching_downtimes: Option<Vec<MatchingDowntime>>,
pub message: Option<String>,
pub modified: Option<DateTime<Utc>>,
pub multi: Option<bool>,
pub name: Option<String>,
pub options: Option<MonitorOptions>,
pub overall_state: Option<MonitorOverallStates>,
pub priority: Option<Option<i64>>,
pub query: String,
pub restricted_roles: Option<Option<Vec<String>>>,
pub state: Option<MonitorState>,
pub tags: Option<Vec<String>>,
pub type_: MonitorType,
pub additional_properties: BTreeMap<String, Value>,
/* private fields */
}
Expand description
Object describing a 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.created: Option<DateTime<Utc>>
Timestamp of the monitor creation.
creator: Option<Creator>
Object describing the creator of the shared element.
deleted: Option<Option<DateTime<Utc>>>
Whether or not the monitor is deleted. (Always null
)
draft_status: Option<MonitorDraftStatus>
Indicates whether the monitor is in a draft or published state.
draft
: The monitor appears as Draft and does not send notifications.
published
: The monitor is active and evaluates conditions and notify as configured.
This field is in preview. The draft value is only available to customers with the feature enabled.
id: Option<i64>
ID of this monitor.
matching_downtimes: Option<Vec<MatchingDowntime>>
A list of active v1 downtimes that match this monitor.
message: Option<String>
A message to include with notifications for this monitor.
modified: Option<DateTime<Utc>>
Last timestamp when the monitor was edited.
multi: Option<bool>
Whether or not the monitor is broken down on different groups.
name: Option<String>
The monitor name.
options: Option<MonitorOptions>
List of options associated with your monitor.
overall_state: Option<MonitorOverallStates>
The different states your monitor can be in.
priority: Option<Option<i64>>
Integer from 1 (high) to 5 (low) indicating alert severity.
query: String
The monitor query.
restricted_roles: Option<Option<Vec<String>>>
A list of unique role identifiers to define which roles are allowed to edit the monitor. The unique identifiers for all roles can be pulled from the Roles API and are located in the data.id
field. Editing a monitor includes any updates to the monitor configuration, monitor deletion, and muting of the monitor for any amount of time. You can use the Restriction Policies API to manage write authorization for individual monitors by teams and users, in addition to roles.
state: Option<MonitorState>
Wrapper object with the different monitor states.
Tags associated to your monitor.
type_: MonitorType
The type of the monitor. For more information about type
, see the monitor options docs.
additional_properties: BTreeMap<String, Value>
Implementations§
Source§impl Monitor
impl Monitor
Sourcepub fn new(query: String, type_: MonitorType) -> Monitor
pub fn new(query: String, type_: MonitorType) -> Monitor
Examples found in repository?
10async fn main() {
11 let body =
12 Monitor::new(
13 r#"ci-tests("type:test @git.branch:staging* @test.status:fail").rollup("count").by("@test.name").last("5m") >= 1"#.to_string(),
14 MonitorType::CI_TESTS_ALERT,
15 )
16 .message("some message Notify: @hipchat-channel".to_string())
17 .name("Example-Monitor".to_string())
18 .options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
19 .priority(Some(3))
20 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21 let configuration = datadog::Configuration::new();
22 let api = MonitorsAPI::with_config(configuration);
23 let resp = api.create_monitor(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
More examples
11async fn main() {
12 let body =
13 Monitor::new(
14 r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
15 MonitorType::ERROR_TRACKING_ALERT,
16 )
17 .draft_status(MonitorDraftStatus::DRAFT)
18 .message("some message".to_string())
19 .name("Example-Monitor".to_string())
20 .options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
21 .priority(Some(3))
22 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
23 let configuration = datadog::Configuration::new();
24 let api = MonitorsAPI::with_config(configuration);
25 let resp = api.create_monitor(body).await;
26 if let Ok(value) = resp {
27 println!("{:#?}", value);
28 } else {
29 println!("{:#?}", resp.unwrap_err());
30 }
31}
10async fn main() {
11 let body =
12 Monitor::new(
13 r#"ci-pipelines("ci_level:pipeline @git.branch:staging* @ci.status:error").rollup("count").by("@git.branch,@ci.pipeline.name").last("5m") >= 1"#.to_string(),
14 MonitorType::CI_PIPELINES_ALERT,
15 )
16 .message("some message Notify: @hipchat-channel".to_string())
17 .name("Example-Monitor".to_string())
18 .options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
19 .priority(Some(3))
20 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21 let configuration = datadog::Configuration::new();
22 let api = MonitorsAPI::with_config(configuration);
23 let resp = api.create_monitor(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
8async fn main() {
9 // there is a valid "role" in the system
10 let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
11 let body =
12 Monitor::new(
13 r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
14 MonitorType::LOG_ALERT,
15 )
16 .message("some message Notify: @hipchat-channel".to_string())
17 .name("Example-Monitor".to_string())
18 .priority(Some(3))
19 .restricted_roles(Some(vec![role_data_id.clone()]))
20 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21 let configuration = datadog::Configuration::new();
22 let api = MonitorsAPI::with_config(configuration);
23 let resp = api.create_monitor(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
12async fn main() {
13 let body = Monitor::new(
14 "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
15 MonitorType::METRIC_ALERT,
16 )
17 .message("some message Notify: @hipchat-channel".to_string())
18 .name("Example-Monitor".to_string())
19 .options(
20 MonitorOptions::new()
21 .scheduling_options(
22 MonitorOptionsSchedulingOptions::new().evaluation_window(
23 MonitorOptionsSchedulingOptionsEvaluationWindow::new()
24 .day_starts("04:00".to_string())
25 .month_starts(1),
26 ),
27 )
28 .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
29 );
30 let configuration = datadog::Configuration::new();
31 let api = MonitorsAPI::with_config(configuration);
32 let resp = api.create_monitor(body).await;
33 if let Ok(value) = resp {
34 println!("{:#?}", value);
35 } else {
36 println!("{:#?}", resp.unwrap_err());
37 }
38}
15async fn main() {
16 let body = Monitor::new(
17 "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
18 MonitorType::QUERY_ALERT,
19 )
20 .draft_status(MonitorDraftStatus::PUBLISHED)
21 .message("some message Notify: @hipchat-channel".to_string())
22 .name("Example-Monitor".to_string())
23 .options(
24 MonitorOptions::new()
25 .include_tags(false)
26 .notify_audit(false)
27 .scheduling_options(
28 MonitorOptionsSchedulingOptions::new()
29 .custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
30 MonitorOptionsCustomScheduleRecurrence::new()
31 .rrule("FREQ=DAILY;INTERVAL=1".to_string())
32 .start("2024-10-26T09:13:00".to_string())
33 .timezone("America/Los_Angeles".to_string())
34 ]))
35 .evaluation_window(
36 MonitorOptionsSchedulingOptionsEvaluationWindow::new()
37 .day_starts("04:00".to_string())
38 .month_starts(1),
39 ),
40 )
41 .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
42 )
43 .tags(vec![]);
44 let configuration = datadog::Configuration::new();
45 let api = MonitorsAPI::with_config(configuration);
46 let resp = api.create_monitor(body).await;
47 if let Ok(value) = resp {
48 println!("{:#?}", value);
49 } else {
50 println!("{:#?}", resp.unwrap_err());
51 }
52}
- 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 created(self, value: DateTime<Utc>) -> Self
pub fn creator(self, value: Creator) -> Self
pub fn deleted(self, value: Option<DateTime<Utc>>) -> Self
Sourcepub fn draft_status(self, value: MonitorDraftStatus) -> Self
pub fn draft_status(self, value: MonitorDraftStatus) -> Self
Examples found in repository?
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}
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 id(self, value: i64) -> Self
pub fn matching_downtimes(self, value: Vec<MatchingDowntime>) -> Self
Sourcepub fn message(self, value: String) -> Self
pub fn message(self, value: String) -> 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}
8async fn main() {
9 // there is a valid "role" in the system
10 let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
11 let body =
12 Monitor::new(
13 r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
14 MonitorType::LOG_ALERT,
15 )
16 .message("some message Notify: @hipchat-channel".to_string())
17 .name("Example-Monitor".to_string())
18 .priority(Some(3))
19 .restricted_roles(Some(vec![role_data_id.clone()]))
20 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21 let configuration = datadog::Configuration::new();
22 let api = MonitorsAPI::with_config(configuration);
23 let resp = api.create_monitor(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
12async fn main() {
13 let body = Monitor::new(
14 "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
15 MonitorType::METRIC_ALERT,
16 )
17 .message("some message Notify: @hipchat-channel".to_string())
18 .name("Example-Monitor".to_string())
19 .options(
20 MonitorOptions::new()
21 .scheduling_options(
22 MonitorOptionsSchedulingOptions::new().evaluation_window(
23 MonitorOptionsSchedulingOptionsEvaluationWindow::new()
24 .day_starts("04:00".to_string())
25 .month_starts(1),
26 ),
27 )
28 .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
29 );
30 let configuration = datadog::Configuration::new();
31 let api = MonitorsAPI::with_config(configuration);
32 let resp = api.create_monitor(body).await;
33 if let Ok(value) = resp {
34 println!("{:#?}", value);
35 } else {
36 println!("{:#?}", resp.unwrap_err());
37 }
38}
15async fn main() {
16 let body = Monitor::new(
17 "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
18 MonitorType::QUERY_ALERT,
19 )
20 .draft_status(MonitorDraftStatus::PUBLISHED)
21 .message("some message Notify: @hipchat-channel".to_string())
22 .name("Example-Monitor".to_string())
23 .options(
24 MonitorOptions::new()
25 .include_tags(false)
26 .notify_audit(false)
27 .scheduling_options(
28 MonitorOptionsSchedulingOptions::new()
29 .custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
30 MonitorOptionsCustomScheduleRecurrence::new()
31 .rrule("FREQ=DAILY;INTERVAL=1".to_string())
32 .start("2024-10-26T09:13:00".to_string())
33 .timezone("America/Los_Angeles".to_string())
34 ]))
35 .evaluation_window(
36 MonitorOptionsSchedulingOptionsEvaluationWindow::new()
37 .day_starts("04:00".to_string())
38 .month_starts(1),
39 ),
40 )
41 .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
42 )
43 .tags(vec![]);
44 let configuration = datadog::Configuration::new();
45 let api = MonitorsAPI::with_config(configuration);
46 let resp = api.create_monitor(body).await;
47 if let Ok(value) = resp {
48 println!("{:#?}", value);
49 } else {
50 println!("{:#?}", resp.unwrap_err());
51 }
52}
- 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 modified(self, value: DateTime<Utc>) -> Self
pub fn multi(self, value: bool) -> Self
Sourcepub fn name(self, value: String) -> Self
pub fn name(self, value: String) -> 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}
8async fn main() {
9 // there is a valid "role" in the system
10 let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
11 let body =
12 Monitor::new(
13 r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
14 MonitorType::LOG_ALERT,
15 )
16 .message("some message Notify: @hipchat-channel".to_string())
17 .name("Example-Monitor".to_string())
18 .priority(Some(3))
19 .restricted_roles(Some(vec![role_data_id.clone()]))
20 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21 let configuration = datadog::Configuration::new();
22 let api = MonitorsAPI::with_config(configuration);
23 let resp = api.create_monitor(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
12async fn main() {
13 let body = Monitor::new(
14 "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
15 MonitorType::METRIC_ALERT,
16 )
17 .message("some message Notify: @hipchat-channel".to_string())
18 .name("Example-Monitor".to_string())
19 .options(
20 MonitorOptions::new()
21 .scheduling_options(
22 MonitorOptionsSchedulingOptions::new().evaluation_window(
23 MonitorOptionsSchedulingOptionsEvaluationWindow::new()
24 .day_starts("04:00".to_string())
25 .month_starts(1),
26 ),
27 )
28 .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
29 );
30 let configuration = datadog::Configuration::new();
31 let api = MonitorsAPI::with_config(configuration);
32 let resp = api.create_monitor(body).await;
33 if let Ok(value) = resp {
34 println!("{:#?}", value);
35 } else {
36 println!("{:#?}", resp.unwrap_err());
37 }
38}
15async fn main() {
16 let body = Monitor::new(
17 "avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
18 MonitorType::QUERY_ALERT,
19 )
20 .draft_status(MonitorDraftStatus::PUBLISHED)
21 .message("some message Notify: @hipchat-channel".to_string())
22 .name("Example-Monitor".to_string())
23 .options(
24 MonitorOptions::new()
25 .include_tags(false)
26 .notify_audit(false)
27 .scheduling_options(
28 MonitorOptionsSchedulingOptions::new()
29 .custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
30 MonitorOptionsCustomScheduleRecurrence::new()
31 .rrule("FREQ=DAILY;INTERVAL=1".to_string())
32 .start("2024-10-26T09:13:00".to_string())
33 .timezone("America/Los_Angeles".to_string())
34 ]))
35 .evaluation_window(
36 MonitorOptionsSchedulingOptionsEvaluationWindow::new()
37 .day_starts("04:00".to_string())
38 .month_starts(1),
39 ),
40 )
41 .thresholds(MonitorThresholds::new().critical(0.5 as f64)),
42 )
43 .tags(vec![]);
44 let configuration = datadog::Configuration::new();
45 let api = MonitorsAPI::with_config(configuration);
46 let resp = api.create_monitor(body).await;
47 if let Ok(value) = resp {
48 println!("{:#?}", value);
49 } else {
50 println!("{:#?}", resp.unwrap_err());
51 }
52}
- 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 options(self, value: MonitorOptions) -> Self
pub fn options(self, value: MonitorOptions) -> 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}
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}
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}
pub fn overall_state(self, value: MonitorOverallStates) -> Self
Sourcepub fn priority(self, value: Option<i64>) -> Self
pub fn priority(self, value: Option<i64>) -> 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}
8async fn main() {
9 // there is a valid "role" in the system
10 let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
11 let body =
12 Monitor::new(
13 r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
14 MonitorType::LOG_ALERT,
15 )
16 .message("some message Notify: @hipchat-channel".to_string())
17 .name("Example-Monitor".to_string())
18 .priority(Some(3))
19 .restricted_roles(Some(vec![role_data_id.clone()]))
20 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21 let configuration = datadog::Configuration::new();
22 let api = MonitorsAPI::with_config(configuration);
23 let resp = api.create_monitor(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
12async fn main() {
13 let body =
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}
Sourcepub fn restricted_roles(self, value: Option<Vec<String>>) -> Self
pub fn restricted_roles(self, value: Option<Vec<String>>) -> Self
Examples found in repository?
8async fn main() {
9 // there is a valid "role" in the system
10 let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
11 let body =
12 Monitor::new(
13 r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
14 MonitorType::LOG_ALERT,
15 )
16 .message("some message Notify: @hipchat-channel".to_string())
17 .name("Example-Monitor".to_string())
18 .priority(Some(3))
19 .restricted_roles(Some(vec![role_data_id.clone()]))
20 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21 let configuration = datadog::Configuration::new();
22 let api = MonitorsAPI::with_config(configuration);
23 let resp = api.create_monitor(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
pub fn state(self, value: MonitorState) -> 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}
8async fn main() {
9 // there is a valid "role" in the system
10 let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
11 let body =
12 Monitor::new(
13 r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
14 MonitorType::LOG_ALERT,
15 )
16 .message("some message Notify: @hipchat-channel".to_string())
17 .name("Example-Monitor".to_string())
18 .priority(Some(3))
19 .restricted_roles(Some(vec![role_data_id.clone()]))
20 .tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
21 let configuration = datadog::Configuration::new();
22 let api = MonitorsAPI::with_config(configuration);
23 let resp = api.create_monitor(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
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}
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}