Unverified Commit c54b3ba1 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Add cloudwatch metrics (cloudwatch) & example (#554)

* Add cloudwatch metrics (cloudwatch)

* remove unused dependencies
parent 082d05f0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ val tier1Services = setOf(
    "sqs",
    "ssm",
    "sts",
    "cloudwatch",
    "ecr",
    "eks"
)
+12 −0
Original line number Diff line number Diff line
[package]
name = "cloudwatch-code-examples"
version = "0.1.0"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>", "Russell Cohen <rcoh@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cloudwatch = { package = "aws-sdk-cloudwatch", path = "../../build/aws-sdk/cloudwatch" }
tokio = { version = "1", features = ["full"] }
tracing-subscriber = { version = "0.2", features = ["fmt"] }
+20 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

use cloudwatch::Client;

#[tokio::main]
async fn main() -> Result<(), cloudwatch::Error> {
    tracing_subscriber::fmt::init();

    let client = Client::from_env();
    let rsp = client.list_metrics().send().await?;
    let metrics = rsp.metrics.unwrap_or_default();
    println!("found {} metric(s)", metrics.len());
    for metric in metrics {
        println!("metric: {:?}", metric);
    }
    Ok(())
}