Struct datadog_api_client::datadogV1::model::model_monitor::Monitor
source · #[non_exhaustive]pub struct Monitor {Show 18 fields
pub created: Option<DateTime<Utc>>,
pub creator: Option<Creator>,
pub deleted: Option<Option<DateTime<Utc>>>,
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)
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: StringThe 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_: MonitorTypeThe 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?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
MonitorType::ERROR_TRACKING_ALERT,
)
.message("some message".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"ci-tests("type:test @git.branch:staging* @test.status:fail").rollup("count").by("@test.name").last("5m") >= 1"#.to_string(),
MonitorType::CI_TESTS_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
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(),
MonitorType::CI_PIPELINES_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.priority(Some(3))
.restricted_roles(Some(vec![role_data_id.clone()]))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::METRIC_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.scheduling_options(
MonitorOptionsSchedulingOptions::new().evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::QUERY_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.include_tags(false)
.notify_audit(false)
.scheduling_options(
MonitorOptionsSchedulingOptions::new()
.custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
MonitorOptionsCustomScheduleRecurrence::new()
.rrule("FREQ=DAILY;INTERVAL=1".to_string())
.start("2024-10-26T09:13:00".to_string())
.timezone("America/Los_Angeles".to_string())
]))
.evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
)
.tags(vec![]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}pub fn created(self, value: DateTime<Utc>) -> Self
pub fn creator(self, value: Creator) -> Self
pub fn deleted(self, value: Option<DateTime<Utc>>) -> Self
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?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
MonitorType::ERROR_TRACKING_ALERT,
)
.message("some message".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"ci-tests("type:test @git.branch:staging* @test.status:fail").rollup("count").by("@test.name").last("5m") >= 1"#.to_string(),
MonitorType::CI_TESTS_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
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(),
MonitorType::CI_PIPELINES_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.priority(Some(3))
.restricted_roles(Some(vec![role_data_id.clone()]))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::METRIC_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.scheduling_options(
MonitorOptionsSchedulingOptions::new().evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::QUERY_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.include_tags(false)
.notify_audit(false)
.scheduling_options(
MonitorOptionsSchedulingOptions::new()
.custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
MonitorOptionsCustomScheduleRecurrence::new()
.rrule("FREQ=DAILY;INTERVAL=1".to_string())
.start("2024-10-26T09:13:00".to_string())
.timezone("America/Los_Angeles".to_string())
]))
.evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
)
.tags(vec![]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}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?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
MonitorType::ERROR_TRACKING_ALERT,
)
.message("some message".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"ci-tests("type:test @git.branch:staging* @test.status:fail").rollup("count").by("@test.name").last("5m") >= 1"#.to_string(),
MonitorType::CI_TESTS_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
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(),
MonitorType::CI_PIPELINES_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.priority(Some(3))
.restricted_roles(Some(vec![role_data_id.clone()]))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::METRIC_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.scheduling_options(
MonitorOptionsSchedulingOptions::new().evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::QUERY_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.include_tags(false)
.notify_audit(false)
.scheduling_options(
MonitorOptionsSchedulingOptions::new()
.custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
MonitorOptionsCustomScheduleRecurrence::new()
.rrule("FREQ=DAILY;INTERVAL=1".to_string())
.start("2024-10-26T09:13:00".to_string())
.timezone("America/Los_Angeles".to_string())
]))
.evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
)
.tags(vec![]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub fn options(self, value: MonitorOptions) -> Self
pub fn options(self, value: MonitorOptions) -> Self
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
MonitorType::ERROR_TRACKING_ALERT,
)
.message("some message".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"ci-tests("type:test @git.branch:staging* @test.status:fail").rollup("count").by("@test.name").last("5m") >= 1"#.to_string(),
MonitorType::CI_TESTS_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
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(),
MonitorType::CI_PIPELINES_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::METRIC_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.scheduling_options(
MonitorOptionsSchedulingOptions::new().evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::QUERY_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.include_tags(false)
.notify_audit(false)
.scheduling_options(
MonitorOptionsSchedulingOptions::new()
.custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
MonitorOptionsCustomScheduleRecurrence::new()
.rrule("FREQ=DAILY;INTERVAL=1".to_string())
.start("2024-10-26T09:13:00".to_string())
.timezone("America/Los_Angeles".to_string())
]))
.evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
)
.tags(vec![]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
async fn main() {
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.enable_logs_sample(true)
.escalation_message("the situation has escalated".to_string())
.evaluation_delay(Some(700))
.groupby_simple_monitor(true)
.include_tags(true)
.locked(false)
.new_host_delay(Some(600))
.no_data_timeframe(None)
.notification_preset_name(MonitorOptionsNotificationPresets::HIDE_HANDLES)
.notify_audit(false)
.notify_no_data(false)
.on_missing_data(OnMissingDataOption::SHOW_AND_NOTIFY_NO_DATA)
.renotify_interval(Some(60))
.require_full_window(true)
.thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(Some(1.0 as f64)))
.timeout_h(Some(24)),
)
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.validate_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}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?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
MonitorType::ERROR_TRACKING_ALERT,
)
.message("some message".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"ci-tests("type:test @git.branch:staging* @test.status:fail").rollup("count").by("@test.name").last("5m") >= 1"#.to_string(),
MonitorType::CI_TESTS_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
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(),
MonitorType::CI_PIPELINES_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.priority(Some(3))
.restricted_roles(Some(vec![role_data_id.clone()]))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
async fn main() {
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.enable_logs_sample(true)
.escalation_message("the situation has escalated".to_string())
.evaluation_delay(Some(700))
.groupby_simple_monitor(true)
.include_tags(true)
.locked(false)
.new_host_delay(Some(600))
.no_data_timeframe(None)
.notification_preset_name(MonitorOptionsNotificationPresets::HIDE_HANDLES)
.notify_audit(false)
.notify_no_data(false)
.on_missing_data(OnMissingDataOption::SHOW_AND_NOTIFY_NO_DATA)
.renotify_interval(Some(60))
.require_full_window(true)
.thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(Some(1.0 as f64)))
.timeout_h(Some(24)),
)
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.validate_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
async fn main() {
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source,status").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.enable_logs_sample(true)
.escalation_message("the situation has escalated".to_string())
.evaluation_delay(Some(700))
.group_retention_duration("2d".to_string())
.groupby_simple_monitor(false)
.include_tags(true)
.locked(false)
.new_host_delay(Some(600))
.no_data_timeframe(None)
.notify_audit(false)
.notify_by(vec!["status".to_string()])
.notify_no_data(false)
.on_missing_data(OnMissingDataOption::SHOW_AND_NOTIFY_NO_DATA)
.renotify_interval(Some(60))
.require_full_window(true)
.thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(Some(1.0 as f64)))
.timeout_h(Some(24)),
)
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.validate_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub fn restricted_roles(self, value: Option<Vec<String>>) -> Self
pub fn restricted_roles(self, value: Option<Vec<String>>) -> Self
Examples found in repository?
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.priority(Some(3))
.restricted_roles(Some(vec![role_data_id.clone()]))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}pub fn state(self, value: MonitorState) -> Self
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
MonitorType::ERROR_TRACKING_ALERT,
)
.message("some message".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
r#"ci-tests("type:test @git.branch:staging* @test.status:fail").rollup("count").by("@test.name").last("5m") >= 1"#.to_string(),
MonitorType::CI_TESTS_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
let body =
Monitor::new(
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(),
MonitorType::CI_PIPELINES_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.priority(Some(3))
.restricted_roles(Some(vec![role_data_id.clone()]))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
async fn main() {
let body = Monitor::new(
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
MonitorType::QUERY_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.include_tags(false)
.notify_audit(false)
.scheduling_options(
MonitorOptionsSchedulingOptions::new()
.custom_schedule(MonitorOptionsCustomSchedule::new().recurrences(vec![
MonitorOptionsCustomScheduleRecurrence::new()
.rrule("FREQ=DAILY;INTERVAL=1".to_string())
.start("2024-10-26T09:13:00".to_string())
.timezone("America/Los_Angeles".to_string())
]))
.evaluation_window(
MonitorOptionsSchedulingOptionsEvaluationWindow::new()
.day_starts("04:00".to_string())
.month_starts(1),
),
)
.thresholds(MonitorThresholds::new().critical(0.5 as f64)),
)
.tags(vec![]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
async fn main() {
let body =
Monitor::new(
r#"logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2"#.to_string(),
MonitorType::LOG_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.enable_logs_sample(true)
.escalation_message("the situation has escalated".to_string())
.evaluation_delay(Some(700))
.groupby_simple_monitor(true)
.include_tags(true)
.locked(false)
.new_host_delay(Some(600))
.no_data_timeframe(None)
.notification_preset_name(MonitorOptionsNotificationPresets::HIDE_HANDLES)
.notify_audit(false)
.notify_no_data(false)
.on_missing_data(OnMissingDataOption::SHOW_AND_NOTIFY_NO_DATA)
.renotify_interval(Some(60))
.require_full_window(true)
.thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(Some(1.0 as f64)))
.timeout_h(Some(24)),
)
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.validate_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}pub fn additional_properties(self, value: BTreeMap<String, Value>) -> Self
Trait Implementations§
source§impl<'de> Deserialize<'de> for Monitor
impl<'de> Deserialize<'de> for Monitor
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl StructuralPartialEq for Monitor
Auto Trait Implementations§
impl Freeze for Monitor
impl RefUnwindSafe for Monitor
impl Send for Monitor
impl Sync for Monitor
impl Unpin for Monitor
impl UnwindSafe for Monitor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)