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
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = EventsAPI::with_config(configuration);
10 let resp = api
11 .list_events(
12 9223372036854775807,
13 9223372036854775807,
14 ListEventsOptionalParams::default(),
15 )
16 .await;
17 if let Ok(value) = resp {
18 println!("{:#?}", value);
19 } else {
20 println!("{:#?}", resp.unwrap_err());
21 }
22}
7async fn main() {
8 let body = EventCreateRequest::new("A text message.".to_string(), "Example-Event".to_string())
9 .tags(vec!["test:ExampleEvent".to_string()]);
10 let configuration = datadog::Configuration::new();
11 let api = EventsAPI::with_config(configuration);
12 let resp = api.create_event(body).await;
13 if let Ok(value) = resp {
14 println!("{:#?}", value);
15 } else {
16 println!("{:#?}", resp.unwrap_err());
17 }
18}
7async fn main() {
8 let body =
9 EventCreateRequest::new(
10 "A text message.".to_string(),
11 "Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters".to_string(),
12 ).tags(vec!["test:ExampleEvent".to_string()]);
13 let configuration = datadog::Configuration::new();
14 let api = EventsAPI::with_config(configuration);
15 let resp = api.create_event(body).await;
16 if let Ok(value) = resp {
17 println!("{:#?}", value);
18 } else {
19 println!("{:#?}", resp.unwrap_err());
20 }
21}
pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self
Sourcepub async fn create_event(
&self,
body: EventCreateRequest,
) -> Result<EventCreateResponse, Error<CreateEventError>>
pub async fn create_event( &self, body: EventCreateRequest, ) -> Result<EventCreateResponse, Error<CreateEventError>>
This endpoint allows you to post events to the stream. Tag them, set priority and event aggregate them with other events.
Examples found in repository?
7async fn main() {
8 let body = EventCreateRequest::new("A text message.".to_string(), "Example-Event".to_string())
9 .tags(vec!["test:ExampleEvent".to_string()]);
10 let configuration = datadog::Configuration::new();
11 let api = EventsAPI::with_config(configuration);
12 let resp = api.create_event(body).await;
13 if let Ok(value) = resp {
14 println!("{:#?}", value);
15 } else {
16 println!("{:#?}", resp.unwrap_err());
17 }
18}
More examples
7async fn main() {
8 let body =
9 EventCreateRequest::new(
10 "A text message.".to_string(),
11 "Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters".to_string(),
12 ).tags(vec!["test:ExampleEvent".to_string()]);
13 let configuration = datadog::Configuration::new();
14 let api = EventsAPI::with_config(configuration);
15 let resp = api.create_event(body).await;
16 if let Ok(value) = resp {
17 println!("{:#?}", value);
18 } else {
19 println!("{:#?}", resp.unwrap_err());
20 }
21}
Sourcepub async fn create_event_with_http_info(
&self,
body: EventCreateRequest,
) -> Result<ResponseContent<EventCreateResponse>, Error<CreateEventError>>
pub async fn create_event_with_http_info( &self, body: EventCreateRequest, ) -> Result<ResponseContent<EventCreateResponse>, Error<CreateEventError>>
This endpoint allows you to post events to the stream. Tag them, set priority and event aggregate them with other events.
Sourcepub async fn get_event(
&self,
event_id: i64,
) -> Result<EventResponse, Error<GetEventError>>
pub async fn get_event( &self, event_id: i64, ) -> Result<EventResponse, Error<GetEventError>>
This endpoint allows you to query for event details.
Note: If the event you’re querying contains markdown formatting of any kind,
you may see characters such as %
,\
,n
in your output.
Sourcepub async fn get_event_with_http_info(
&self,
event_id: i64,
) -> Result<ResponseContent<EventResponse>, Error<GetEventError>>
pub async fn get_event_with_http_info( &self, event_id: i64, ) -> Result<ResponseContent<EventResponse>, Error<GetEventError>>
This endpoint allows you to query for event details.
Note: If the event you’re querying contains markdown formatting of any kind,
you may see characters such as %
,\
,n
in your output.
Sourcepub async fn list_events(
&self,
start: i64,
end: i64,
params: ListEventsOptionalParams,
) -> Result<EventListResponse, Error<ListEventsError>>
pub async fn list_events( &self, start: i64, end: i64, params: ListEventsOptionalParams, ) -> Result<EventListResponse, Error<ListEventsError>>
The event stream can be queried and filtered by time, priority, sources and tags.
Notes:
-
If the event you’re querying contains markdown formatting of any kind, you may see characters such as
%
,\
,n
in your output. -
This endpoint returns a maximum of
1000
most recent results. To return additional results, identify the last timestamp of the last result and set that as theend
query time to paginate the results. You can also use the page parameter to specify which set of1000
results to return.
Examples found in repository?
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = EventsAPI::with_config(configuration);
10 let resp = api
11 .list_events(
12 9223372036854775807,
13 9223372036854775807,
14 ListEventsOptionalParams::default(),
15 )
16 .await;
17 if let Ok(value) = resp {
18 println!("{:#?}", value);
19 } else {
20 println!("{:#?}", resp.unwrap_err());
21 }
22}
Sourcepub async fn list_events_with_http_info(
&self,
start: i64,
end: i64,
params: ListEventsOptionalParams,
) -> Result<ResponseContent<EventListResponse>, Error<ListEventsError>>
pub async fn list_events_with_http_info( &self, start: i64, end: i64, params: ListEventsOptionalParams, ) -> Result<ResponseContent<EventListResponse>, Error<ListEventsError>>
The event stream can be queried and filtered by time, priority, sources and tags.
Notes:
-
If the event you’re querying contains markdown formatting of any kind, you may see characters such as
%
,\
,n
in your output. -
This endpoint returns a maximum of
1000
most recent results. To return additional results, identify the last timestamp of the last result and set that as theend
query time to paginate the results. You can also use the page parameter to specify which set of1000
results to return.