Skip to content

Commit

Permalink
Add cloudwatch metrics (cloudwatch) & example (#554)
Browse files Browse the repository at this point in the history
* Add cloudwatch metrics (cloudwatch)

* remove unused dependencies
  • Loading branch information
rcoh authored Jun 29, 2021
1 parent 082d05f commit c54b3ba
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions aws/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ val tier1Services = setOf(
"sqs",
"ssm",
"sts",
"cloudwatch",
"ecr",
"eks"
)
Expand Down
12 changes: 12 additions & 0 deletions aws/sdk/examples/cloudwatch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[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 changes: 20 additions & 0 deletions aws/sdk/examples/cloudwatch/src/bin/list-metrics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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(())
}

0 comments on commit c54b3ba

Please sign in to comment.