0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【小ネタ】CloudWatchメトリクスのグラフ画像を簡単に取得する方法

0
Posted at

はじめに

CloudWatchメトリクスのグラフ画像を取得したいときは
AWS CLIのget-metric-widget-imageを使うと便利です。

実行例

~ $ aws cloudwatch get-metric-widget-image \
--metric-widget '{
    "view": "timeSeries",
    "stacked": false,
    "metrics": [
        [ "AWS/S3", "BucketSizeBytes", "BucketName", "xxx", "StorageType", "StandardStorage", { "period": 86400, "id": "m1" } ]
    ],
    "width": 1742,
    "height": 260,
    "start": "-PT336H",
    "end": "P0D"
}' \
 --output-format png \
 --output text | base64 --decode > image.png

このコマンドを実行すると、メトリクスの画像を image.png として保存できます。

取得した画像はこんな感じ

image (1).png

metric-widgetのjsonを確認する方法

対象メトリクスのグラフを選択したときに「発信元」のタブから確認できます。
このjsonをそのまま引数として利用できます。

image.png

まとめ

地味だけど、結構便利ではないでしょうか?
手動でスクリーンショットを撮る代わりに、CLIで自動化してみてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?