Struct datadog_api_client::datadogV1::api::api_monitors::MonitorsAPI
source · pub struct MonitorsAPI { /* private fields */ }Expand description
Monitors allow you to watch a metric or check that you care about and notifies your team when a defined threshold has exceeded.
For more information, see Creating Monitors.
Implementations§
source§impl MonitorsAPI
impl MonitorsAPI
pub fn new() -> Self
sourcepub fn with_config(config: Configuration) -> Self
pub fn with_config(config: Configuration) -> Self
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.list_monitors(ListMonitorsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
7 8 9 10 11 12 13 14 15 16 17 18
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.search_monitors(SearchMonitorsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}7 8 9 10 11 12 13 14 15 16 17 18
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.search_monitor_groups(SearchMonitorGroupsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}6 7 8 9 10 11 12 13 14 15 16 17
async fn main() {
// there is a valid "monitor" in the system
let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.check_can_delete_monitor(vec![monitor_id.clone()]).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.list_monitors(
ListMonitorsOptionalParams::default()
.tags("test:examplemonitor".to_string())
.page_size(1),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let response =
api.list_monitors_with_pagination(ListMonitorsOptionalParams::default().page_size(2));
pin_mut!(response);
while let Some(resp) = response.next().await {
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
}- examples/v1_monitors_DeleteMonitor.rs
- examples/v1_monitors_GetMonitor.rs
- examples/v1_monitors_GetMonitor_2200114573.rs
- examples/v1_monitors_GetMonitor_3691711704.rs
- examples/v1_monitors_CreateMonitor_440013737.rs
- examples/v1_monitors_CreateMonitor_2520912138.rs
- examples/v1_monitors_CreateMonitor_3790803616.rs
- examples/v1_monitors_UpdateMonitor.rs
- examples/v1_monitors_CreateMonitor.rs
- examples/v1_monitors_CreateMonitor_2012680290.rs
- examples/v1_monitors_CreateMonitor_1539578087.rs
- examples/v1_monitors_ValidateMonitor.rs
- examples/v1_monitors_ValidateMonitor_4247196452.rs
- examples/v1_monitors_ValidateExistingMonitor.rs
- examples/v1_monitors_CreateMonitor_3883669300.rs
- examples/v1_monitors_CreateMonitor_1969035628.rs
- examples/v1_monitors_CreateMonitor_3824294658.rs
pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self
sourcepub async fn check_can_delete_monitor(
&self,
monitor_ids: Vec<i64>,
) -> Result<CheckCanDeleteMonitorResponse, Error<CheckCanDeleteMonitorError>>
pub async fn check_can_delete_monitor( &self, monitor_ids: Vec<i64>, ) -> Result<CheckCanDeleteMonitorResponse, Error<CheckCanDeleteMonitorError>>
Check if the given monitors can be deleted.
Examples found in repository?
6 7 8 9 10 11 12 13 14 15 16 17
async fn main() {
// there is a valid "monitor" in the system
let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.check_can_delete_monitor(vec![monitor_id.clone()]).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub async fn check_can_delete_monitor_with_http_info(
&self,
monitor_ids: Vec<i64>,
) -> Result<ResponseContent<CheckCanDeleteMonitorResponse>, Error<CheckCanDeleteMonitorError>>
pub async fn check_can_delete_monitor_with_http_info( &self, monitor_ids: Vec<i64>, ) -> Result<ResponseContent<CheckCanDeleteMonitorResponse>, Error<CheckCanDeleteMonitorError>>
Check if the given monitors can be deleted.
sourcepub async fn create_monitor(
&self,
body: Monitor,
) -> Result<Monitor, Error<CreateMonitorError>>
pub async fn create_monitor( &self, body: Monitor, ) -> Result<Monitor, Error<CreateMonitorError>>
Create a monitor using the specified options.
§Monitor Types
The type of monitor chosen from:
- anomaly:
query alert - APM:
query alertortrace-analytics alert - composite:
composite - custom:
service check - forecast:
query alert - host:
service check - integration:
query alertorservice check - live process:
process alert - logs:
log alert - metric:
query alert - network:
service check - outlier:
query alert - process:
service check - rum:
rum alert - SLO:
slo alert - watchdog:
event-v2 alert - event-v2:
event-v2 alert - audit:
audit alert - error-tracking:
error-tracking alert - database-monitoring:
database-monitoring alert - network-performance:
network-performance alert
Notes:
- Synthetic monitors are created through the Synthetics API. See the Synthetics API documentation for more information.
- Log monitors require an unscoped App Key.
§Query Types
§Metric Alert Query
Example: time_aggr(time_window):space_aggr:metric{tags} [by {key}] operator #
time_aggr: avg, sum, max, min, change, or pct_changetime_window:last_#m(with#between 1 and 10080 depending on the monitor type) orlast_#h(with#between 1 and 168 depending on the monitor type) orlast_1d, orlast_1wspace_aggr: avg, sum, min, or maxtags: one or more tags (comma-separated), or *key: a ‘key’ in key:value tag syntax; defines a separate alert for each tag in the group (multi-alert)operator: <, <=, >, >=, ==, or !=#: an integer or decimal number used to set the threshold
If you are using the _change_ or _pct_change_ time aggregator, instead use change_aggr(time_aggr(time_window), timeshift):space_aggr:metric{tags} [by {key}] operator # with:
change_aggrchange, pct_changetime_aggravg, sum, max, min Learn moretime_windowlast_#m (between 1 and 2880 depending on the monitor type), last_#h (between 1 and 48 depending on the monitor type), or last_#d (1 or 2)timeshift#m_ago (5, 10, 15, or 30), #h_ago (1, 2, or 4), or 1d_ago
Use this to create an outlier monitor using the following query:
avg(last_30m):outliers(avg:system.cpu.user{role:es-events-data} by {host}, 'dbscan', 7) > 0
§Service Check Query
Example: "check".over(tags).last(count).by(group).count_by_status()
checkname of the check, for exampledatadog.agent.uptagsone or more quoted tags (comma-separated), or “*”. for example:.over("env:prod", "role:db");overcannot be blank.countmust be at greater than or equal to your max threshold (defined in theoptions). It is limited to 100. For example, if you’ve specified to notify on 1 critical, 3 ok, and 2 warn statuses,countshould be at least 3.groupmust be specified for check monitors. Per-check grouping is already explicitly known for some service checks. For example, Postgres integration monitors are tagged bydb,host, andport, and Network monitors byhost,instance, andurl. See Service Checks documentation for more information.
§Event Alert Query
Note: The Event Alert Query has been replaced by the Event V2 Alert Query. For more information, see the Event Migration guide.
§Event V2 Alert Query
Example: events(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§Process Alert Query
Example: processes(search).over(tags).rollup('count').last(timeframe) operator #
searchfree text search string for querying processes. Matching processes match results on the Live Processes page.tagsone or more tags (comma-separated)timeframethe timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and doperator<, <=, >, >=, ==, or !=#an integer or decimal number used to set the threshold
§Logs Alert Query
Example: logs(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.index_nameFor multi-index organizations, the log index in which the request is performed.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§Composite Query
Example: 12345 && 67890, where 12345 and 67890 are the IDs of non-composite monitors
name[required, default = dynamic, based on query]: The name of the alert.message[required, default = dynamic, based on query]: A message to include with notifications for this monitor. Email notifications can be sent to specific users by using the same ‘@username’ notation as events.tags[optional, default = empty list]: A list of tags to associate with your monitor. When getting all monitor details via the API, use themonitor_tagsargument to filter results by these tags. It is only available via the API and isn’t visible or editable in the Datadog UI.
§SLO Alert Query
Example: error_budget("slo_id").over("time_window") operator #
slo_id: The alphanumeric SLO ID of the SLO you are configuring the alert for.time_window: The time window of the SLO target you wish to alert on. Valid options:7d,30d,90d.operator:>=or>
§Audit Alert Query
Example: audits(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§CI Pipelines Alert Query
Example: ci-pipelines(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§CI Tests Alert Query
Example: ci-tests(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§Error Tracking Alert Query
Example(RUM): error-tracking-rum(query).rollup(rollup_method[, measure]).last(time_window) operator #
Example(APM Traces): error-tracking-traces(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
Database Monitoring Alert Query
Example: database-monitoring(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
Network Performance Alert Query
Example: network-performance(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
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 async fn create_monitor_with_http_info(
&self,
body: Monitor,
) -> Result<ResponseContent<Monitor>, Error<CreateMonitorError>>
pub async fn create_monitor_with_http_info( &self, body: Monitor, ) -> Result<ResponseContent<Monitor>, Error<CreateMonitorError>>
Create a monitor using the specified options.
§Monitor Types
The type of monitor chosen from:
- anomaly:
query alert - APM:
query alertortrace-analytics alert - composite:
composite - custom:
service check - forecast:
query alert - host:
service check - integration:
query alertorservice check - live process:
process alert - logs:
log alert - metric:
query alert - network:
service check - outlier:
query alert - process:
service check - rum:
rum alert - SLO:
slo alert - watchdog:
event-v2 alert - event-v2:
event-v2 alert - audit:
audit alert - error-tracking:
error-tracking alert - database-monitoring:
database-monitoring alert - network-performance:
network-performance alert
Notes:
- Synthetic monitors are created through the Synthetics API. See the Synthetics API documentation for more information.
- Log monitors require an unscoped App Key.
§Query Types
§Metric Alert Query
Example: time_aggr(time_window):space_aggr:metric{tags} [by {key}] operator #
time_aggr: avg, sum, max, min, change, or pct_changetime_window:last_#m(with#between 1 and 10080 depending on the monitor type) orlast_#h(with#between 1 and 168 depending on the monitor type) orlast_1d, orlast_1wspace_aggr: avg, sum, min, or maxtags: one or more tags (comma-separated), or *key: a ‘key’ in key:value tag syntax; defines a separate alert for each tag in the group (multi-alert)operator: <, <=, >, >=, ==, or !=#: an integer or decimal number used to set the threshold
If you are using the _change_ or _pct_change_ time aggregator, instead use change_aggr(time_aggr(time_window), timeshift):space_aggr:metric{tags} [by {key}] operator # with:
change_aggrchange, pct_changetime_aggravg, sum, max, min Learn moretime_windowlast_#m (between 1 and 2880 depending on the monitor type), last_#h (between 1 and 48 depending on the monitor type), or last_#d (1 or 2)timeshift#m_ago (5, 10, 15, or 30), #h_ago (1, 2, or 4), or 1d_ago
Use this to create an outlier monitor using the following query:
avg(last_30m):outliers(avg:system.cpu.user{role:es-events-data} by {host}, 'dbscan', 7) > 0
§Service Check Query
Example: "check".over(tags).last(count).by(group).count_by_status()
checkname of the check, for exampledatadog.agent.uptagsone or more quoted tags (comma-separated), or “*”. for example:.over("env:prod", "role:db");overcannot be blank.countmust be at greater than or equal to your max threshold (defined in theoptions). It is limited to 100. For example, if you’ve specified to notify on 1 critical, 3 ok, and 2 warn statuses,countshould be at least 3.groupmust be specified for check monitors. Per-check grouping is already explicitly known for some service checks. For example, Postgres integration monitors are tagged bydb,host, andport, and Network monitors byhost,instance, andurl. See Service Checks documentation for more information.
§Event Alert Query
Note: The Event Alert Query has been replaced by the Event V2 Alert Query. For more information, see the Event Migration guide.
§Event V2 Alert Query
Example: events(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§Process Alert Query
Example: processes(search).over(tags).rollup('count').last(timeframe) operator #
searchfree text search string for querying processes. Matching processes match results on the Live Processes page.tagsone or more tags (comma-separated)timeframethe timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and doperator<, <=, >, >=, ==, or !=#an integer or decimal number used to set the threshold
§Logs Alert Query
Example: logs(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.index_nameFor multi-index organizations, the log index in which the request is performed.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§Composite Query
Example: 12345 && 67890, where 12345 and 67890 are the IDs of non-composite monitors
name[required, default = dynamic, based on query]: The name of the alert.message[required, default = dynamic, based on query]: A message to include with notifications for this monitor. Email notifications can be sent to specific users by using the same ‘@username’ notation as events.tags[optional, default = empty list]: A list of tags to associate with your monitor. When getting all monitor details via the API, use themonitor_tagsargument to filter results by these tags. It is only available via the API and isn’t visible or editable in the Datadog UI.
§SLO Alert Query
Example: error_budget("slo_id").over("time_window") operator #
slo_id: The alphanumeric SLO ID of the SLO you are configuring the alert for.time_window: The time window of the SLO target you wish to alert on. Valid options:7d,30d,90d.operator:>=or>
§Audit Alert Query
Example: audits(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avgandcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§CI Pipelines Alert Query
Example: ci-pipelines(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§CI Tests Alert Query
Example: ci-tests(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
§Error Tracking Alert Query
Example(RUM): error-tracking-rum(query).rollup(rollup_method[, measure]).last(time_window) operator #
Example(APM Traces): error-tracking-traces(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
Database Monitoring Alert Query
Example: database-monitoring(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
Network Performance Alert Query
Example: network-performance(query).rollup(rollup_method[, measure]).last(time_window) operator #
queryThe search query - following the Log search syntax.rollup_methodThe stats roll-up method - supportscount,avg, andcardinality.measureForavgand cardinalityrollup_method- specify the measure or the facet name you want to use.time_window#m (between 1 and 2880), #h (between 1 and 48).operator<,<=,>,>=,==, or!=.#an integer or decimal number used to set the threshold.
sourcepub async fn delete_monitor(
&self,
monitor_id: i64,
params: DeleteMonitorOptionalParams,
) -> Result<DeletedMonitor, Error<DeleteMonitorError>>
pub async fn delete_monitor( &self, monitor_id: i64, params: DeleteMonitorOptionalParams, ) -> Result<DeletedMonitor, Error<DeleteMonitorError>>
Delete the specified monitor
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20
async fn main() {
// there is a valid "monitor" in the system
let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.delete_monitor(monitor_id.clone(), DeleteMonitorOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub async fn delete_monitor_with_http_info(
&self,
monitor_id: i64,
params: DeleteMonitorOptionalParams,
) -> Result<ResponseContent<DeletedMonitor>, Error<DeleteMonitorError>>
pub async fn delete_monitor_with_http_info( &self, monitor_id: i64, params: DeleteMonitorOptionalParams, ) -> Result<ResponseContent<DeletedMonitor>, Error<DeleteMonitorError>>
Delete the specified monitor
sourcepub async fn get_monitor(
&self,
monitor_id: i64,
params: GetMonitorOptionalParams,
) -> Result<Monitor, Error<GetMonitorError>>
pub async fn get_monitor( &self, monitor_id: i64, params: GetMonitorOptionalParams, ) -> Result<Monitor, Error<GetMonitorError>>
Get details about the specified monitor from your organization.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
async fn main() {
// there is a valid "monitor" in the system
let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.get_monitor(
monitor_id.clone(),
GetMonitorOptionalParams::default().with_downtimes(true),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
async fn main() {
// there is a valid "monitor" in the system
let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.get_monitor(
monitor_id.clone(),
GetMonitorOptionalParams::default().with_downtimes(true),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn main() {
// there is a valid "synthetics_api_test" in the system
let synthetics_api_test_monitor_id: i64 = std::env::var("SYNTHETICS_API_TEST_MONITOR_ID")
.unwrap()
.parse()
.unwrap();
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.get_monitor(
synthetics_api_test_monitor_id.clone(),
GetMonitorOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub async fn get_monitor_with_http_info(
&self,
monitor_id: i64,
params: GetMonitorOptionalParams,
) -> Result<ResponseContent<Monitor>, Error<GetMonitorError>>
pub async fn get_monitor_with_http_info( &self, monitor_id: i64, params: GetMonitorOptionalParams, ) -> Result<ResponseContent<Monitor>, Error<GetMonitorError>>
Get details about the specified monitor from your organization.
sourcepub async fn list_monitors(
&self,
params: ListMonitorsOptionalParams,
) -> Result<Vec<Monitor>, Error<ListMonitorsError>>
pub async fn list_monitors( &self, params: ListMonitorsOptionalParams, ) -> Result<Vec<Monitor>, Error<ListMonitorsError>>
Get details about the specified monitor from your organization.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.list_monitors(ListMonitorsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.list_monitors(
ListMonitorsOptionalParams::default()
.tags("test:examplemonitor".to_string())
.page_size(1),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub fn list_monitors_with_pagination(
&self,
params: ListMonitorsOptionalParams,
) -> impl Stream<Item = Result<Monitor, Error<ListMonitorsError>>> + '_
pub fn list_monitors_with_pagination( &self, params: ListMonitorsOptionalParams, ) -> impl Stream<Item = Result<Monitor, Error<ListMonitorsError>>> + '_
Examples found in repository?
9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let response =
api.list_monitors_with_pagination(ListMonitorsOptionalParams::default().page_size(2));
pin_mut!(response);
while let Some(resp) = response.next().await {
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
}sourcepub async fn list_monitors_with_http_info(
&self,
params: ListMonitorsOptionalParams,
) -> Result<ResponseContent<Vec<Monitor>>, Error<ListMonitorsError>>
pub async fn list_monitors_with_http_info( &self, params: ListMonitorsOptionalParams, ) -> Result<ResponseContent<Vec<Monitor>>, Error<ListMonitorsError>>
Get details about the specified monitor from your organization.
sourcepub async fn search_monitor_groups(
&self,
params: SearchMonitorGroupsOptionalParams,
) -> Result<MonitorGroupSearchResponse, Error<SearchMonitorGroupsError>>
pub async fn search_monitor_groups( &self, params: SearchMonitorGroupsOptionalParams, ) -> Result<MonitorGroupSearchResponse, Error<SearchMonitorGroupsError>>
Search and filter your monitor groups details.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.search_monitor_groups(SearchMonitorGroupsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub async fn search_monitor_groups_with_http_info(
&self,
params: SearchMonitorGroupsOptionalParams,
) -> Result<ResponseContent<MonitorGroupSearchResponse>, Error<SearchMonitorGroupsError>>
pub async fn search_monitor_groups_with_http_info( &self, params: SearchMonitorGroupsOptionalParams, ) -> Result<ResponseContent<MonitorGroupSearchResponse>, Error<SearchMonitorGroupsError>>
Search and filter your monitor groups details.
sourcepub async fn search_monitors(
&self,
params: SearchMonitorsOptionalParams,
) -> Result<MonitorSearchResponse, Error<SearchMonitorsError>>
pub async fn search_monitors( &self, params: SearchMonitorsOptionalParams, ) -> Result<MonitorSearchResponse, Error<SearchMonitorsError>>
Search and filter your monitors details.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18
async fn main() {
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api
.search_monitors(SearchMonitorsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub async fn search_monitors_with_http_info(
&self,
params: SearchMonitorsOptionalParams,
) -> Result<ResponseContent<MonitorSearchResponse>, Error<SearchMonitorsError>>
pub async fn search_monitors_with_http_info( &self, params: SearchMonitorsOptionalParams, ) -> Result<ResponseContent<MonitorSearchResponse>, Error<SearchMonitorsError>>
Search and filter your monitors details.
sourcepub async fn update_monitor(
&self,
monitor_id: i64,
body: MonitorUpdateRequest,
) -> Result<Monitor, Error<UpdateMonitorError>>
pub async fn update_monitor( &self, monitor_id: i64, body: MonitorUpdateRequest, ) -> Result<Monitor, Error<UpdateMonitorError>>
Edit the specified monitor.
Examples found in repository?
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
async fn main() {
// there is a valid "monitor" in the system
let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().unwrap();
let body = MonitorUpdateRequest::new()
.name("My monitor-updated".to_string())
.options(
MonitorOptions::new()
.evaluation_delay(None)
.new_group_delay(Some(600))
.new_host_delay(None)
.renotify_interval(None)
.thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(None))
.timeout_h(None),
)
.priority(None);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.update_monitor(monitor_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub async fn update_monitor_with_http_info(
&self,
monitor_id: i64,
body: MonitorUpdateRequest,
) -> Result<ResponseContent<Monitor>, Error<UpdateMonitorError>>
pub async fn update_monitor_with_http_info( &self, monitor_id: i64, body: MonitorUpdateRequest, ) -> Result<ResponseContent<Monitor>, Error<UpdateMonitorError>>
Edit the specified monitor.
sourcepub async fn validate_existing_monitor(
&self,
monitor_id: i64,
body: Monitor,
) -> Result<BTreeMap<String, Value>, Error<ValidateExistingMonitorError>>
pub async fn validate_existing_monitor( &self, monitor_id: i64, body: Monitor, ) -> Result<BTreeMap<String, Value>, Error<ValidateExistingMonitorError>>
Validate the monitor provided in the request.
Examples found in repository?
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 50 51 52 53
async fn main() {
// there is a valid "monitor" in the system
let monitor_id: i64 = std::env::var("MONITOR_ID").unwrap().parse().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())
.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_existing_monitor(monitor_id.clone(), body)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}sourcepub async fn validate_existing_monitor_with_http_info(
&self,
monitor_id: i64,
body: Monitor,
) -> Result<ResponseContent<BTreeMap<String, Value>>, Error<ValidateExistingMonitorError>>
pub async fn validate_existing_monitor_with_http_info( &self, monitor_id: i64, body: Monitor, ) -> Result<ResponseContent<BTreeMap<String, Value>>, Error<ValidateExistingMonitorError>>
Validate the monitor provided in the request.
sourcepub async fn validate_monitor(
&self,
body: Monitor,
) -> Result<BTreeMap<String, Value>, Error<ValidateMonitorError>>
pub async fn validate_monitor( &self, body: Monitor, ) -> Result<BTreeMap<String, Value>, Error<ValidateMonitorError>>
Validate the monitor provided in the request.
Note: Log monitors require an unscoped App Key.
Examples found in repository?
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());
}
}More examples
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 async fn validate_monitor_with_http_info(
&self,
body: Monitor,
) -> Result<ResponseContent<BTreeMap<String, Value>>, Error<ValidateMonitorError>>
pub async fn validate_monitor_with_http_info( &self, body: Monitor, ) -> Result<ResponseContent<BTreeMap<String, Value>>, Error<ValidateMonitorError>>
Validate the monitor provided in the request.
Note: Log monitors require an unscoped App Key.
Trait Implementations§
source§impl Clone for MonitorsAPI
impl Clone for MonitorsAPI
source§fn clone(&self) -> MonitorsAPI
fn clone(&self) -> MonitorsAPI
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for MonitorsAPI
impl Debug for MonitorsAPI
Auto Trait Implementations§
impl Freeze for MonitorsAPI
impl !RefUnwindSafe for MonitorsAPI
impl Send for MonitorsAPI
impl Sync for MonitorsAPI
impl Unpin for MonitorsAPI
impl !UnwindSafe for MonitorsAPI
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)