
Infra ဘက်မှာ တစ်ခုခု load တက်လို့ပဲ ဖြစ်ဖြစ် တစ်ခုခု aware ဖြစ်ချင်တာပဲဖြစ်ဖြစ် email alert system တစ်ခုရှိသော်လဲ တစ်ခါတစ်လေ mail မမြင်လိုက်တာပဲဖြစ်ဖြစ် mail တွေရောသွားလို့ပဲဖြစ်ဖြစ် သတိမထားမိတာလူတိုင်းဖြစ်ဖူးကြမယ်ထင်ပါတယ်။ အဲ့လိုမျိုးမဖြစ်ရလေအောင် CloudWatch Alarm + SNS + Lambda တွဲသုံးပြီး internal alert system လေးလုပ်ထားလို့ရပါတယ်။
CloudWatch Alarm တော့ ပုံမှန်အတိုင်း alert တက်ရင် SNS topic ကို route ရမှာဖြစ်ပြီး SNS topic မှာ email subscribe မယ့်အစား Lambda function ကို subscribe ရမှာဖြစ်ပါတယ်။ Lambda function မှာ အောက်ပါပုံက code snippet လေးအတိုင်းဖြစ်ပြီး ကိုယ်တိုင် customize, ပြင်ပြီး အသုံးပြုလို့ရပါတယ်။ ကိုယ့် company က Google Workspace သုံးမယ်ဆို Chat Alert ပို့မယ့် space တစ်ခုရဲ့ Webhook URL လိုပါတယ်။ အကယ်၍ working space ဟာ team တို့ discord တို့ဖြစ်နေနယ်ဆိုရင်လဲ သက်ဆိုင်ရာ app ရဲ့ Webhook URL သုံးရင်ရပါပြီ။ CloudWatch Alarm ကလာတဲ့ metrics ရဲ့ payload ကနေမှ ကိုယ်လိုချင်တဲ့ data ကို Lambda function မှတစ်ဆင့် ဆွဲထုတ် ပြီး မိမိ စိတ်ကြိုက် card အနေနဲ့ format ချပြီး သတ်မှတ်ထားတဲ့ Wedhook URL ဆီ alert ပို့ပေးတာပဲဖြစ်ပါတယ်။ card format ကိုတော့ အောက်က လင့် မှာဖတ်ပြီး စိတ်ကြိုက် customize လုပ်လို့ရပါတယ်။
[https://developers.google.com/workspace/chat/api/reference/rest/v1/cards](https://developers.google.com/workspace/chat/api/reference/rest/v1/cards)
