cloudwatch-metrics-dl

Very simple dev CLI for repetitive tasks of gathering metrics across many AWS accounts.

This is likely only actually useful if you have +30 accounts to fetch some metrics from.

Currently only CloudWatch metric widget image API is supported.

Accounts Config

The accounts are defined in TOML. The file should be a list of tables containing namespace, account_id, and region for each account.

Example (from the repo's accounts.toml):

[[account]]
namespace = "SomeDataProcessingProgram"
account_id = "111111111111"
region = "us-east-1"

To validate accounts config is parsed properly:

cargo run -- config <ACCOUNT.TOML FILE>

# example
cargo run -- config accounts.toml
AccountConfig { namespace: "SomeDataProcessingProgram", account_id: "111111111111", region: "us-east-1" }
AccountConfig { namespace: "SomeDataProcessingProgram", account_id: "222222222222", region: "eu-west-1" }
AccountConfig { namespace: "SomeDataProcessingProgram", account_id: "222222222222", region: "us-west-2" }
...

Commands

You can use cargo run -- to build and pass commands to the CLI.

# run retry counts, replace START_TIME in retry-counts graph to start 6 months ago
cargo run -- images --period 3600 --pattern ItemDPP -s 4320H ./resources/traffic.json ./accounts.toml

# omit the pattern to run this command for all accounts
cargo run -- images --period 3600  -s 7200H ./resources/traffic.json ./accounts.toml

Future work

Development

Prerequisites

  1. Install earthly: https://earthly.dev/get-earthly
  2. Fork/create template
  3. Set DOCKERHUB_USERNAME and DOCKERHUB_TOKEN Github environment secrets

Run Locally

Run these tests locally with:

earthly --ci +ci

Run scheduled jobs with:

earthly --ci +scheduled-ci

TODO