Skip to content

Commit ac7a520

Browse files
lingwmpradeepbhadani
authored andcommitted
add CloudWatch and SNS (#57)
* add CloudWatch and SNS * rename as federation * rename dashboard item * fix sns name in alarm_action * update changelog
1 parent 15109ad commit ac7a520

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6+
## [1.1.1] - 2019-04-09
7+
8+
### Added
9+
- Add CloudWatch and SNS - see [#57](https://github.com/ExpediaGroup/apiary-federation/pull/57).
10+
11+
612
## [1.1.0] - 2019-04-05
713

814
### Added

cloudwatch.tf

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,89 @@ resource "aws_cloudwatch_log_group" "waggledance_ecs" {
88
name = "${local.instance_alias}"
99
tags = "${var.tags}"
1010
}
11+
12+
resource "aws_cloudwatch_dashboard" "apiary_federation" {
13+
dashboard_name = "${local.instance_alias}-${var.aws_region}"
14+
15+
dashboard_body = <<EOF
16+
{
17+
"widgets": [
18+
{
19+
"type":"metric",
20+
"width":12,
21+
"height":6,
22+
"properties":{
23+
"metrics":[
24+
[ "AWS/ECS", "CPUUtilization", "ServiceName", "${local.instance_alias}-service", "ClusterName", "${local.instance_alias}" ]
25+
],
26+
"period":300,
27+
"stat":"Average",
28+
"region":"${var.aws_region}",
29+
"title":"WaggleDance ECS CPU Utilization"
30+
}
31+
},
32+
{
33+
"type":"metric",
34+
"width":12,
35+
"height":6,
36+
"properties":{
37+
"metrics":[
38+
[ "AWS/ECS", "MemoryUtilization", "ServiceName", "${local.instance_alias}-service", "ClusterName", "${local.instance_alias}" ]
39+
],
40+
"period":300,
41+
"stat":"Average",
42+
"region":"${var.aws_region}",
43+
"title":"WaggleDance ECS Memory Utilization"
44+
}
45+
}
46+
]
47+
}
48+
EOF
49+
}
50+
51+
52+
locals {
53+
alerts = [
54+
{
55+
alarm_name = "${local.instance_alias}-cpu"
56+
namespace = "AWS/ECS"
57+
metric_name = "CPUUtilization"
58+
threshold = "80"
59+
},
60+
{
61+
alarm_name = "${local.instance_alias}-memory"
62+
namespace = "AWS/ECS"
63+
metric_name = "MemoryUtilization"
64+
threshold = "70"
65+
}
66+
]
67+
68+
dimensions = [
69+
{
70+
ClusterName = "${local.instance_alias}"
71+
ServiceName = "${local.instance_alias}-service"
72+
},
73+
{
74+
ClusterName = "${local.instance_alias}"
75+
ServiceName = "${local.instance_alias}-service"
76+
}
77+
]
78+
}
79+
80+
81+
resource "aws_cloudwatch_metric_alarm" "waggledance_alert" {
82+
count = "${length(local.alerts)}"
83+
alarm_name = "${lookup(local.alerts[count.index],"alarm_name")}"
84+
comparison_operator = "${lookup(local.alerts[count.index],"comparison_operator","GreaterThanOrEqualToThreshold")}"
85+
metric_name = "${lookup(local.alerts[count.index],"metric_name")}"
86+
namespace = "${lookup(local.alerts[count.index],"namespace")}"
87+
period = "${lookup(local.alerts[count.index],"period","120")}"
88+
evaluation_periods = "${lookup(local.alerts[count.index],"evaluation_periods","2")}"
89+
statistic = "Average"
90+
threshold = "${lookup(local.alerts[count.index],"threshold")}"
91+
92+
#alarm_description = ""
93+
insufficient_data_actions = []
94+
dimensions = "${local.dimensions[count.index]}"
95+
alarm_actions = ["${aws_sns_topic.apiary_federation_ops_sns.arn}"]
96+
}

sns.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resource "aws_sns_topic" "apiary_federation_ops_sns" {
2+
name = "${local.instance_alias}-operational-events"
3+
}

0 commit comments

Comments
 (0)