v2_logs_AggregateLogs_2527007002/
v2_logs_AggregateLogs_2527007002.rs

1// Aggregate compute events returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_logs::LogsAPI;
4use datadog_api_client::datadogV2::model::LogsAggregateRequest;
5use datadog_api_client::datadogV2::model::LogsAggregationFunction;
6use datadog_api_client::datadogV2::model::LogsCompute;
7use datadog_api_client::datadogV2::model::LogsComputeType;
8use datadog_api_client::datadogV2::model::LogsQueryFilter;
9
10#[tokio::main]
11async fn main() {
12    let body = LogsAggregateRequest::new()
13        .compute(vec![LogsCompute::new(LogsAggregationFunction::COUNT)
14            .interval("5m".to_string())
15            .type_(LogsComputeType::TIMESERIES)])
16        .filter(
17            LogsQueryFilter::new()
18                .from("now-15m".to_string())
19                .indexes(vec!["main".to_string()])
20                .query("*".to_string())
21                .to("now".to_string()),
22        );
23    let configuration = datadog::Configuration::new();
24    let api = LogsAPI::with_config(configuration);
25    let resp = api.aggregate_logs(body).await;
26    if let Ok(value) = resp {
27        println!("{:#?}", value);
28    } else {
29        println!("{:#?}", resp.unwrap_err());
30    }
31}