v2_logs_metrics_CreateLogsMetric/
v2_logs-metrics_CreateLogsMetric.rs

1// Create a log-based metric returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_logs_metrics::LogsMetricsAPI;
4use datadog_api_client::datadogV2::model::LogsMetricCompute;
5use datadog_api_client::datadogV2::model::LogsMetricComputeAggregationType;
6use datadog_api_client::datadogV2::model::LogsMetricCreateAttributes;
7use datadog_api_client::datadogV2::model::LogsMetricCreateData;
8use datadog_api_client::datadogV2::model::LogsMetricCreateRequest;
9use datadog_api_client::datadogV2::model::LogsMetricType;
10
11#[tokio::main]
12async fn main() {
13    let body = LogsMetricCreateRequest::new(LogsMetricCreateData::new(
14        LogsMetricCreateAttributes::new(
15            LogsMetricCompute::new(LogsMetricComputeAggregationType::DISTRIBUTION)
16                .include_percentiles(true)
17                .path("@duration".to_string()),
18        ),
19        "ExampleLogsMetric".to_string(),
20        LogsMetricType::LOGS_METRICS,
21    ));
22    let configuration = datadog::Configuration::new();
23    let api = LogsMetricsAPI::with_config(configuration);
24    let resp = api.create_logs_metric(body).await;
25    if let Ok(value) = resp {
26        println!("{:#?}", value);
27    } else {
28        println!("{:#?}", resp.unwrap_err());
29    }
30}