pub struct EventsAPI { /* private fields */ }
Expand description
The Event Management API allows you to programmatically post events to the Events Explorer and fetch events from the Events Explorer. See the Event Management page for more information.
Update to Datadog monitor events aggregation_key
starting March 1, 2025: The Datadog monitor events aggregation_key
is unique to each Monitor ID. Starting March 1st, this key will also include Monitor Group, making it unique per Monitor ID and Monitor Group. If you’re using monitor events aggregation_key
in dashboard queries or the Event API, you must migrate to use @monitor.id
. Reach out to support if you have any question.
Implementations§
Source§impl EventsAPI
impl EventsAPI
pub fn new() -> Self
Sourcepub fn with_config(config: Configuration) -> Self
pub fn with_config(config: Configuration) -> Self
Examples found in repository?
More examples
9async fn main() {
10 let configuration = datadog::Configuration::new();
11 let api = EventsAPI::with_config(configuration);
12 let response = api.list_events_with_pagination(
13 ListEventsOptionalParams::default()
14 .filter_from("now-15m".to_string())
15 .filter_to("now".to_string())
16 .page_limit(2),
17 );
18 pin_mut!(response);
19 while let Some(resp) = response.next().await {
20 if let Ok(value) = resp {
21 println!("{:#?}", value);
22 } else {
23 println!("{:#?}", resp.unwrap_err());
24 }
25 }
26}
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = EventsAPI::with_config(configuration);
10 let resp = api
11 .list_events(
12 ListEventsOptionalParams::default()
13 .filter_query("datadog-agent".to_string())
14 .filter_from("2020-09-17T11:48:36+01:00".to_string())
15 .filter_to("2020-09-17T12:48:36+01:00".to_string())
16 .page_limit(5),
17 )
18 .await;
19 if let Ok(value) = resp {
20 println!("{:#?}", value);
21 } else {
22 println!("{:#?}", resp.unwrap_err());
23 }
24}
11async fn main() {
12 let body = EventsListRequest::new()
13 .filter(
14 EventsQueryFilter::new()
15 .from("2020-09-17T11:48:36+01:00".to_string())
16 .query("datadog-agent".to_string())
17 .to("2020-09-17T12:48:36+01:00".to_string()),
18 )
19 .page(EventsRequestPage::new().limit(5))
20 .sort(EventsSort::TIMESTAMP_ASCENDING);
21 let configuration = datadog::Configuration::new();
22 let api = EventsAPI::with_config(configuration);
23 let resp = api
24 .search_events(SearchEventsOptionalParams::default().body(body))
25 .await;
26 if let Ok(value) = resp {
27 println!("{:#?}", value);
28 } else {
29 println!("{:#?}", resp.unwrap_err());
30 }
31}
14async fn main() {
15 let body = EventsListRequest::new()
16 .filter(
17 EventsQueryFilter::new()
18 .from("now-15m".to_string())
19 .to("now".to_string()),
20 )
21 .options(EventsQueryOptions::new().timezone("GMT".to_string()))
22 .page(EventsRequestPage::new().limit(2))
23 .sort(EventsSort::TIMESTAMP_ASCENDING);
24 let configuration = datadog::Configuration::new();
25 let api = EventsAPI::with_config(configuration);
26 let response =
27 api.search_events_with_pagination(SearchEventsOptionalParams::default().body(body));
28 pin_mut!(response);
29 while let Some(resp) = response.next().await {
30 if let Ok(value) = resp {
31 println!("{:#?}", value);
32 } else {
33 println!("{:#?}", resp.unwrap_err());
34 }
35 }
36}
22async fn main() {
23 let body = EventCreateRequestPayload::new(EventCreateRequest::new(
24 EventPayload::new(
25 EventPayloadAttributes::ChangeEventCustomAttributes(Box::new(
26 ChangeEventCustomAttributes::new(ChangeEventCustomAttributesChangedResource::new(
27 "fallback_payments_test".to_string(),
28 ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG,
29 ))
30 .author(ChangeEventCustomAttributesAuthor::new(
31 "example@datadog.com".to_string(),
32 ChangeEventCustomAttributesAuthorType::USER,
33 ))
34 .change_metadata(BTreeMap::from([(
35 "resource_link".to_string(),
36 Value::from("datadog.com/feature/fallback_payments_test"),
37 )]))
38 .impacted_resources(vec![
39 ChangeEventCustomAttributesImpactedResourcesItems::new(
40 "payments_api".to_string(),
41 ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE,
42 ),
43 ])
44 .new_value(BTreeMap::from([
45 ("enabled".to_string(), Value::from("True")),
46 ("percentage".to_string(), Value::from("50%")),
47 ]))
48 .prev_value(BTreeMap::from([
49 ("enabled".to_string(), Value::from("True")),
50 ("percentage".to_string(), Value::from("10%")),
51 ])),
52 )),
53 EventCategory::CHANGE,
54 "payment_processed feature flag updated".to_string(),
55 )
56 .aggregation_key("aggregation_key_123".to_string())
57 .integration_id(EventPayloadIntegrationId::CUSTOM_EVENTS)
58 .message("payment_processed feature flag has been enabled".to_string())
59 .tags(vec!["env:api_client_test".to_string()]),
60 EventCreateRequestType::EVENT,
61 ));
62 let configuration = datadog::Configuration::new();
63 let api = EventsAPI::with_config(configuration);
64 let resp = api.create_event(body).await;
65 if let Ok(value) = resp {
66 println!("{:#?}", value);
67 } else {
68 println!("{:#?}", resp.unwrap_err());
69 }
70}
pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self
Sourcepub async fn create_event(
&self,
body: EventCreateRequestPayload,
) -> Result<EventCreateResponsePayload, Error<CreateEventError>>
pub async fn create_event( &self, body: EventCreateRequestPayload, ) -> Result<EventCreateResponsePayload, Error<CreateEventError>>
This endpoint allows you to publish events.
✅ Only events with the change
or alert
category are in General Availability. For change events, see Change Tracking for more details.
❌ For use cases involving other event categories, use the V1 endpoint or reach out to support.
❌ Notifications are not yet supported for events sent to this endpoint. Use the V1 endpoint for notification functionality.
❌ This endpoint is not available for the Government (US1-FED) site. Contact your account representative for more information.
Examples found in repository?
22async fn main() {
23 let body = EventCreateRequestPayload::new(EventCreateRequest::new(
24 EventPayload::new(
25 EventPayloadAttributes::ChangeEventCustomAttributes(Box::new(
26 ChangeEventCustomAttributes::new(ChangeEventCustomAttributesChangedResource::new(
27 "fallback_payments_test".to_string(),
28 ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG,
29 ))
30 .author(ChangeEventCustomAttributesAuthor::new(
31 "example@datadog.com".to_string(),
32 ChangeEventCustomAttributesAuthorType::USER,
33 ))
34 .change_metadata(BTreeMap::from([(
35 "resource_link".to_string(),
36 Value::from("datadog.com/feature/fallback_payments_test"),
37 )]))
38 .impacted_resources(vec![
39 ChangeEventCustomAttributesImpactedResourcesItems::new(
40 "payments_api".to_string(),
41 ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE,
42 ),
43 ])
44 .new_value(BTreeMap::from([
45 ("enabled".to_string(), Value::from("True")),
46 ("percentage".to_string(), Value::from("50%")),
47 ]))
48 .prev_value(BTreeMap::from([
49 ("enabled".to_string(), Value::from("True")),
50 ("percentage".to_string(), Value::from("10%")),
51 ])),
52 )),
53 EventCategory::CHANGE,
54 "payment_processed feature flag updated".to_string(),
55 )
56 .aggregation_key("aggregation_key_123".to_string())
57 .integration_id(EventPayloadIntegrationId::CUSTOM_EVENTS)
58 .message("payment_processed feature flag has been enabled".to_string())
59 .tags(vec!["env:api_client_test".to_string()]),
60 EventCreateRequestType::EVENT,
61 ));
62 let configuration = datadog::Configuration::new();
63 let api = EventsAPI::with_config(configuration);
64 let resp = api.create_event(body).await;
65 if let Ok(value) = resp {
66 println!("{:#?}", value);
67 } else {
68 println!("{:#?}", resp.unwrap_err());
69 }
70}
Sourcepub async fn create_event_with_http_info(
&self,
body: EventCreateRequestPayload,
) -> Result<ResponseContent<EventCreateResponsePayload>, Error<CreateEventError>>
pub async fn create_event_with_http_info( &self, body: EventCreateRequestPayload, ) -> Result<ResponseContent<EventCreateResponsePayload>, Error<CreateEventError>>
This endpoint allows you to publish events.
✅ Only events with the change
or alert
category are in General Availability. For change events, see Change Tracking for more details.
❌ For use cases involving other event categories, use the V1 endpoint or reach out to support.
❌ Notifications are not yet supported for events sent to this endpoint. Use the V1 endpoint for notification functionality.
❌ This endpoint is not available for the Government (US1-FED) site. Contact your account representative for more information.
Sourcepub async fn list_events(
&self,
params: ListEventsOptionalParams,
) -> Result<EventsListResponse, Error<ListEventsError>>
pub async fn list_events( &self, params: ListEventsOptionalParams, ) -> Result<EventsListResponse, Error<ListEventsError>>
List endpoint returns events that match an events search query. Results are paginated similarly to logs.
Use this endpoint to see your latest events.
Examples found in repository?
More examples
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = EventsAPI::with_config(configuration);
10 let resp = api
11 .list_events(
12 ListEventsOptionalParams::default()
13 .filter_query("datadog-agent".to_string())
14 .filter_from("2020-09-17T11:48:36+01:00".to_string())
15 .filter_to("2020-09-17T12:48:36+01:00".to_string())
16 .page_limit(5),
17 )
18 .await;
19 if let Ok(value) = resp {
20 println!("{:#?}", value);
21 } else {
22 println!("{:#?}", resp.unwrap_err());
23 }
24}
Sourcepub fn list_events_with_pagination(
&self,
params: ListEventsOptionalParams,
) -> impl Stream<Item = Result<EventResponse, Error<ListEventsError>>> + '_
pub fn list_events_with_pagination( &self, params: ListEventsOptionalParams, ) -> impl Stream<Item = Result<EventResponse, Error<ListEventsError>>> + '_
Examples found in repository?
9async fn main() {
10 let configuration = datadog::Configuration::new();
11 let api = EventsAPI::with_config(configuration);
12 let response = api.list_events_with_pagination(
13 ListEventsOptionalParams::default()
14 .filter_from("now-15m".to_string())
15 .filter_to("now".to_string())
16 .page_limit(2),
17 );
18 pin_mut!(response);
19 while let Some(resp) = response.next().await {
20 if let Ok(value) = resp {
21 println!("{:#?}", value);
22 } else {
23 println!("{:#?}", resp.unwrap_err());
24 }
25 }
26}
Sourcepub async fn list_events_with_http_info(
&self,
params: ListEventsOptionalParams,
) -> Result<ResponseContent<EventsListResponse>, Error<ListEventsError>>
pub async fn list_events_with_http_info( &self, params: ListEventsOptionalParams, ) -> Result<ResponseContent<EventsListResponse>, Error<ListEventsError>>
List endpoint returns events that match an events search query. Results are paginated similarly to logs.
Use this endpoint to see your latest events.
Sourcepub async fn search_events(
&self,
params: SearchEventsOptionalParams,
) -> Result<EventsListResponse, Error<SearchEventsError>>
pub async fn search_events( &self, params: SearchEventsOptionalParams, ) -> Result<EventsListResponse, Error<SearchEventsError>>
List endpoint returns events that match an events search query. Results are paginated similarly to logs.
Use this endpoint to build complex events filtering and search.
Examples found in repository?
11async fn main() {
12 let body = EventsListRequest::new()
13 .filter(
14 EventsQueryFilter::new()
15 .from("2020-09-17T11:48:36+01:00".to_string())
16 .query("datadog-agent".to_string())
17 .to("2020-09-17T12:48:36+01:00".to_string()),
18 )
19 .page(EventsRequestPage::new().limit(5))
20 .sort(EventsSort::TIMESTAMP_ASCENDING);
21 let configuration = datadog::Configuration::new();
22 let api = EventsAPI::with_config(configuration);
23 let resp = api
24 .search_events(SearchEventsOptionalParams::default().body(body))
25 .await;
26 if let Ok(value) = resp {
27 println!("{:#?}", value);
28 } else {
29 println!("{:#?}", resp.unwrap_err());
30 }
31}
Sourcepub fn search_events_with_pagination(
&self,
params: SearchEventsOptionalParams,
) -> impl Stream<Item = Result<EventResponse, Error<SearchEventsError>>> + '_
pub fn search_events_with_pagination( &self, params: SearchEventsOptionalParams, ) -> impl Stream<Item = Result<EventResponse, Error<SearchEventsError>>> + '_
Examples found in repository?
14async fn main() {
15 let body = EventsListRequest::new()
16 .filter(
17 EventsQueryFilter::new()
18 .from("now-15m".to_string())
19 .to("now".to_string()),
20 )
21 .options(EventsQueryOptions::new().timezone("GMT".to_string()))
22 .page(EventsRequestPage::new().limit(2))
23 .sort(EventsSort::TIMESTAMP_ASCENDING);
24 let configuration = datadog::Configuration::new();
25 let api = EventsAPI::with_config(configuration);
26 let response =
27 api.search_events_with_pagination(SearchEventsOptionalParams::default().body(body));
28 pin_mut!(response);
29 while let Some(resp) = response.next().await {
30 if let Ok(value) = resp {
31 println!("{:#?}", value);
32 } else {
33 println!("{:#?}", resp.unwrap_err());
34 }
35 }
36}
Sourcepub async fn search_events_with_http_info(
&self,
params: SearchEventsOptionalParams,
) -> Result<ResponseContent<EventsListResponse>, Error<SearchEventsError>>
pub async fn search_events_with_http_info( &self, params: SearchEventsOptionalParams, ) -> Result<ResponseContent<EventsListResponse>, Error<SearchEventsError>>
List endpoint returns events that match an events search query. Results are paginated similarly to logs.
Use this endpoint to build complex events filtering and search.