-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CloudWatch alarms and alarms forwarding to BetterStack (#131)
* feat: add CloudWatch alarms and alarms forwarding to BetterStack * fix: ignore topic encryption warning
- Loading branch information
Showing
27 changed files
with
653 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* @Xav | ||
* @Elyniss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
formatter: 'markdown table' | ||
|
||
recursive: | ||
enabled: true | ||
path: . | ||
|
||
output: | ||
file: README.md | ||
mode: inject | ||
template: |- | ||
<!-- BEGIN_TF_DOCS --> | ||
{{ .Content }} | ||
<!-- END_TF_DOCS --> | ||
content: | | ||
{{ .Header }} | ||
{{ .Requirements }} | ||
{{ .Providers }} | ||
{{ .Modules }} | ||
## Inputs | ||
{{- $hideInputs := list "namespace" "region" "stage" "name" "delimiter" "attributes" "tags" "regex_replace_chars" "id_length_limit" "label_key_case" "label_value_case" "label_order" }} | ||
{{- $filteredInputs := list -}} | ||
{{- range .Module.Inputs -}} | ||
{{- if not (has .Name $hideInputs) -}} | ||
{{- $filteredInputs = append $filteredInputs . -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{ if not $filteredInputs }} | ||
No inputs. | ||
{{ else }} | ||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
{{- range $filteredInputs }} | ||
| {{ anchorNameMarkdown "input" .Name }} | {{ tostring .Description | sanitizeMarkdownTbl }} | {{ printf " " }}<pre lang="json">{{ tostring .Type | sanitizeMarkdownTbl }}</pre> | {{ printf " " }}<pre lang="json">{{ .GetValue | sanitizeMarkdownTbl }}</pre> | {{ printf " " }}{{ ternary .Required "yes" "no" }} | | ||
{{- end }} | ||
{{- end }} | ||
{{ .Outputs }} | ||
{{/** End of file fixer */}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# `cloudwatch` module | ||
|
||
This module configures the cloudwatch alarms and webhook forwarding. | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
|
||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.0 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.7 | | ||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.7 | | ||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_cloudwatch"></a> [cloudwatch](#module\_cloudwatch) | app.terraform.io/wallet-connect/cloudwatch-constants/aws | 1.0.0 | | ||
| <a name="module_this"></a> [this](#module\_this) | app.terraform.io/wallet-connect/label/null | 0.3.2 | | ||
|
||
## Inputs | ||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes and tags, which are merged. | <pre lang="json">any</pre> | <pre lang="json">n/a</pre> | yes | | ||
| <a name="input_docdb_cluster_id"></a> [docdb\_cluster\_id](#input\_docdb\_cluster\_id) | The DocumentDB cluster ID | <pre lang="json">string</pre> | <pre lang="json">n/a</pre> | yes | | ||
| <a name="input_docdb_cpu_threshold"></a> [docdb\_cpu\_threshold](#input\_docdb\_cpu\_threshold) | The DocumentDB CPU utilization alarm threshold in percents | <pre lang="json">number</pre> | <pre lang="json">80</pre> | no | | ||
| <a name="input_docdb_low_memory_throttling_threshold"></a> [docdb\_low\_memory\_throttling\_threshold](#input\_docdb\_low\_memory\_throttling\_threshold) | The DocumentDB low memory throttling alarm threshold in number of operations per period | <pre lang="json">number</pre> | <pre lang="json">2</pre> | no | | ||
| <a name="input_docdb_memory_threshold"></a> [docdb\_memory\_threshold](#input\_docdb\_memory\_threshold) | The DocumentDB available memory alarm threshold in GiB | <pre lang="json">number</pre> | <pre lang="json">4</pre> | no | | ||
| <a name="input_ecs_cluster_name"></a> [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | The name of the ECS cluster running the application | <pre lang="json">string</pre> | <pre lang="json">n/a</pre> | yes | | ||
| <a name="input_ecs_cpu_threshold"></a> [ecs\_cpu\_threshold](#input\_ecs\_cpu\_threshold) | The ECS CPU utilization alarm threshold in percents | <pre lang="json">number</pre> | <pre lang="json">80</pre> | no | | ||
| <a name="input_ecs_memory_threshold"></a> [ecs\_memory\_threshold](#input\_ecs\_memory\_threshold) | The ECS memory utilization alarm threshold in percents | <pre lang="json">number</pre> | <pre lang="json">80</pre> | no | | ||
| <a name="input_ecs_service_name"></a> [ecs\_service\_name](#input\_ecs\_service\_name) | The name of the ECS service running the application | <pre lang="json">string</pre> | <pre lang="json">n/a</pre> | yes | | ||
| <a name="input_webhook_url"></a> [webhook\_url](#input\_webhook\_url) | The URL of the webhook to be called on alarms | <pre lang="json">string</pre> | <pre lang="json">n/a</pre> | yes | | ||
## Outputs | ||
|
||
No outputs. | ||
|
||
|
||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
resource "aws_cloudwatch_metric_alarm" "docdb_cpu_utilization" { | ||
alarm_name = "${local.alarm_prefix} - DocumentDB CPU Utilization" | ||
alarm_description = "${local.alarm_prefix} - DocumentDB CPU utilization is high (over ${var.docdb_cpu_threshold}%)" | ||
|
||
namespace = module.cloudwatch.namespaces.DocumentDB | ||
dimensions = { | ||
DBClusterIdentifier = var.docdb_cluster_id | ||
} | ||
metric_name = module.cloudwatch.metrics.DocumentDB.CPUUtilization | ||
|
||
evaluation_periods = local.evaluation_periods | ||
period = local.period | ||
|
||
statistic = module.cloudwatch.statistics.Average | ||
comparison_operator = module.cloudwatch.operators.GreaterThanOrEqualToThreshold | ||
threshold = var.docdb_cpu_threshold | ||
treat_missing_data = "breaching" | ||
|
||
alarm_actions = [aws_sns_topic.webhook.arn] | ||
insufficient_data_actions = [aws_sns_topic.webhook.arn] | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "docdb_available_memory" { | ||
alarm_name = "${local.alarm_prefix} - DocumentDB Available Memory" | ||
alarm_description = "${local.alarm_prefix} - DocumentDB available memory is low (less than ${var.docdb_memory_threshold}GiB)" | ||
|
||
namespace = module.cloudwatch.namespaces.DocumentDB | ||
dimensions = { | ||
DBClusterIdentifier = var.docdb_cluster_id | ||
} | ||
metric_name = module.cloudwatch.metrics.DocumentDB.FreeableMemory | ||
|
||
evaluation_periods = local.evaluation_periods | ||
period = local.period | ||
|
||
statistic = module.cloudwatch.statistics.Average | ||
comparison_operator = module.cloudwatch.operators.LessThanOrEqualToThreshold | ||
threshold = var.docdb_memory_threshold * pow(1000, 3) | ||
treat_missing_data = "breaching" | ||
|
||
alarm_actions = [aws_sns_topic.webhook.arn] | ||
insufficient_data_actions = [aws_sns_topic.webhook.arn] | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "docdb_low_memory_throttling" { | ||
alarm_name = "${local.alarm_prefix} - DocumentDB Low Memory Throttling" | ||
alarm_description = "${local.alarm_prefix} - DocumentDB is throttling operations due to low memory" | ||
|
||
namespace = module.cloudwatch.namespaces.DocumentDB | ||
dimensions = { | ||
DBClusterIdentifier = var.docdb_cluster_id | ||
} | ||
metric_name = module.cloudwatch.metrics.DocumentDB.LowMemNumOperationsThrottled | ||
|
||
evaluation_periods = local.evaluation_periods | ||
period = local.period | ||
|
||
statistic = module.cloudwatch.statistics.Maximum | ||
comparison_operator = module.cloudwatch.operators.GreaterThanThreshold | ||
threshold = var.docdb_low_memory_throttling_threshold | ||
treat_missing_data = "breaching" | ||
|
||
alarm_actions = [aws_sns_topic.webhook.arn] | ||
insufficient_data_actions = [aws_sns_topic.webhook.arn] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
resource "aws_cloudwatch_metric_alarm" "ecs_cpu_utilization" { | ||
alarm_name = "${local.alarm_prefix} - ECS CPU Utilization" | ||
alarm_description = "${local.alarm_prefix} - ECS CPU utilization is high (over ${var.ecs_cpu_threshold}%)" | ||
|
||
namespace = module.cloudwatch.namespaces.ECS | ||
dimensions = { | ||
ClusterName = var.ecs_cluster_name | ||
ServiceName = var.ecs_service_name | ||
} | ||
metric_name = module.cloudwatch.metrics.ECS.CPUUtilization | ||
|
||
evaluation_periods = local.evaluation_periods | ||
period = local.period | ||
|
||
statistic = module.cloudwatch.statistics.Average | ||
comparison_operator = module.cloudwatch.operators.GreaterThanOrEqualToThreshold | ||
threshold = var.ecs_cpu_threshold | ||
treat_missing_data = "breaching" | ||
|
||
alarm_actions = [aws_sns_topic.webhook.arn] | ||
insufficient_data_actions = [aws_sns_topic.webhook.arn] | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "ecs_mem_utilization" { | ||
alarm_name = "${local.alarm_prefix} - ECS Memory Utilization" | ||
alarm_description = "${local.alarm_prefix} - ECS Memory utilization is high (over ${var.ecs_memory_threshold}%)" | ||
|
||
namespace = module.cloudwatch.namespaces.ECS | ||
dimensions = { | ||
ClusterName = var.ecs_cluster_name | ||
ServiceName = var.ecs_service_name | ||
} | ||
metric_name = module.cloudwatch.metrics.ECS.MemoryUtilization | ||
|
||
evaluation_periods = local.evaluation_periods | ||
period = local.period | ||
|
||
statistic = module.cloudwatch.statistics.Average | ||
comparison_operator = module.cloudwatch.operators.GreaterThanOrEqualToThreshold | ||
threshold = var.ecs_memory_threshold | ||
treat_missing_data = "breaching" | ||
|
||
alarm_actions = [aws_sns_topic.webhook.arn] | ||
insufficient_data_actions = [aws_sns_topic.webhook.arn] | ||
} |
Oops, something went wrong.