0
0

More than 1 year has passed since last update.

on-demand-dashboardで気楽にDashboard

Posted at

はじめに

Cloudwatch Dashboardを気楽にたくさん使っていたら、いつの間にか料金が無視できないものになった経験はありませんか? 不要なDashboardを削除した結果、Cloud Watch Insightで同じクエリを何度も何度も作ったりしていませんか?

コストを気にすることなく必要に応じてDashboardをS3に退避、復帰することができる、on-demand-dashboardをCDKスタックとして公開しました。
https://github.com/tomohisaota/on-demand-dashboard

基本的な構成

  • Dashboard Lambda
    • Cloudwatch Dashboardに表示するカスタムウィジェットで、Dashboard管理を行うUIを提供する
  • Redirect Lambda
    • 退避されているCloudwatch Dashboardをストレスなく利用するために、復帰後にリダイレクトを行うLambda Function URLを提供する
  • S3
    • CloudWatch DashboardのJSON定義を保存しておくストレージ

on-demand-dashboard.png

ルール設定

どのDashboardを退避可能にするのか、いつ退避可能にするのか等は、ルールによって詳細に設定することができます。すべて手動で設定することも、すべてCDKから固定で設定することも可能です。
ルールにはプリセットを用意しているので、通常のユースケースであればプリセットで対応可能です。

const PresetRules: { [key in PresetRuleName]: TOnDemandDashboardRule[] } = {
    Demo1: [
        {
            ruleName: "Manual",
            archive: "Manual",
            matchByName: [
                "OnDemandDashboardAdmin",
                "Dummy1",
            ],
            allowActivate: true,
            allowDeactivate: true,
            allowDelete: true,
            ttl: Duration.minutes(3).toMilliseconds()
        },
    ],
    Demo2: [
        {
            ruleName: "Enabled without control",
            archive: "Enabled",
            matchByName: [
                "OnDemandDashboardAdmin",
                "Dummy1",
            ],
            allowActivate: false,
            allowDeactivate: false,
            allowDelete: false,
            ttl: Duration.minutes(3).toMilliseconds()
        },
    ],
    AllManualExceptODD: [
        {
            ruleName: "Protect ODD",
            matchODD: true,
            archive: "Disabled",
        },
        {
            ruleName: "All Manual",
            matchAll: true,
            archive: "Manual",
            allowActivate: true,
            allowDeactivate: true,
            allowDelete: true,
            ttl: Duration.days(3).toMilliseconds()
        },
    ],
    AllEnabledExceptODD: [
        {
            ruleName: "Protect ODD",
            matchODD: true,
            archive: "Disabled",
        },
        {
            ruleName: "All Enabled",
            matchAll: true,
            archive: "Enabled",
            allowActivate: true,
            allowDeactivate: true,
            allowDelete: true,
            ttl: Duration.days(3).toMilliseconds()
        },
    ],
    AllEnabled: [
        {
            ruleName: "All Enabled",
            matchAll: true,
            archive: "Enabled",
            allowActivate: true,
            allowDeactivate: true,
            allowDelete: true,
            ttl: Duration.days(3).toMilliseconds()
        },
    ],
    AllDisabled: [], // Default behavior
}

さいごに

感想等コメントでいただけると励みになります。
https://github.com/tomohisaota/on-demand-dashboard

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