Struct EventsAPI

Source
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

Source

pub fn new() -> Self

Source

pub fn with_config(config: Configuration) -> Self

Examples found in repository?
examples/v2_events_ListEvents.rs (line 9)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = EventsAPI::with_config(configuration);
10    let resp = api.list_events(ListEventsOptionalParams::default()).await;
11    if let Ok(value) = resp {
12        println!("{:#?}", value);
13    } else {
14        println!("{:#?}", resp.unwrap_err());
15    }
16}
More examples
Hide additional examples
examples/v2_events_ListEvents_1527584014.rs (line 11)
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}
examples/v2_events_ListEvents_2663715109.rs (line 9)
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}
examples/v2_events_SearchEvents.rs (line 22)
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}
examples/v2_events_SearchEvents_3856995058.rs (line 25)
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}
examples/v2_events_CreateEvent.rs (line 63)
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}
Source

pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self

Source

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?
examples/v2_events_CreateEvent.rs (line 64)
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}
Source

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.

Source

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?
examples/v2_events_ListEvents.rs (line 10)
7async fn main() {
8    let configuration = datadog::Configuration::new();
9    let api = EventsAPI::with_config(configuration);
10    let resp = api.list_events(ListEventsOptionalParams::default()).await;
11    if let Ok(value) = resp {
12        println!("{:#?}", value);
13    } else {
14        println!("{:#?}", resp.unwrap_err());
15    }
16}
More examples
Hide additional examples
examples/v2_events_ListEvents_2663715109.rs (lines 11-17)
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}
Source

pub fn list_events_with_pagination( &self, params: ListEventsOptionalParams, ) -> impl Stream<Item = Result<EventResponse, Error<ListEventsError>>> + '_

Examples found in repository?
examples/v2_events_ListEvents_1527584014.rs (lines 12-17)
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}
Source

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.

Source

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?
examples/v2_events_SearchEvents.rs (line 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}
Source

pub fn search_events_with_pagination( &self, params: SearchEventsOptionalParams, ) -> impl Stream<Item = Result<EventResponse, Error<SearchEventsError>>> + '_

Examples found in repository?
examples/v2_events_SearchEvents_3856995058.rs (line 27)
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}
Source

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.

Trait Implementations§

Source§

impl Clone for EventsAPI

Source§

fn clone(&self) -> EventsAPI

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventsAPI

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EventsAPI

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,