Skip to content

Commit

Permalink
fix(DMVP-1232): Added widgets for Request Count, Response Time, Exter…
Browse files Browse the repository at this point in the history
…nal Health Check
  • Loading branch information
viktoryathegreat committed Oct 18, 2023
1 parent 2b64d95 commit fd3b02b
Show file tree
Hide file tree
Showing 18 changed files with 500 additions and 41 deletions.
3 changes: 3 additions & 0 deletions modules/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@
| <a name="module_container_balancer_4xx_widget"></a> [container\_balancer\_4xx\_widget](#module\_container\_balancer\_4xx\_widget) | ./modules/widgets/balancer/4xx | n/a |
| <a name="module_container_balancer_5xx_widget"></a> [container\_balancer\_5xx\_widget](#module\_container\_balancer\_5xx\_widget) | ./modules/widgets/balancer/5xx | n/a |
| <a name="module_container_cpu_widget"></a> [container\_cpu\_widget](#module\_container\_cpu\_widget) | ./modules/widgets/container/cpu | n/a |
| <a name="module_container_external_health_check_widget"></a> [container\_external\_health\_check\_widget](#module\_container\_external\_health\_check\_widget) | ./modules/widgets/container/external-health-check | n/a |
| <a name="module_container_memory_widget"></a> [container\_memory\_widget](#module\_container\_memory\_widget) | ./modules/widgets/container/memory | n/a |
| <a name="module_container_network_in_widget"></a> [container\_network\_in\_widget](#module\_container\_network\_in\_widget) | ./modules/widgets/container/network-in | n/a |
| <a name="module_container_network_out_widget"></a> [container\_network\_out\_widget](#module\_container\_network\_out\_widget) | ./modules/widgets/container/network-out | n/a |
| <a name="module_container_network_widget"></a> [container\_network\_widget](#module\_container\_network\_widget) | ./modules/widgets/container/network | n/a |
| <a name="module_container_replicas_widget"></a> [container\_replicas\_widget](#module\_container\_replicas\_widget) | ./modules/widgets/container/replicas | n/a |
| <a name="module_container_request_count_widget"></a> [container\_request\_count\_widget](#module\_container\_request\_count\_widget) | ./modules/widgets/container/request-count | n/a |
| <a name="module_container_response_time_widget"></a> [container\_response\_time\_widget](#module\_container\_response\_time\_widget) | ./modules/widgets/container/response-time | n/a |
| <a name="module_container_restarts_widget"></a> [container\_restarts\_widget](#module\_container\_restarts\_widget) | ./modules/widgets/container/restarts | n/a |
| <a name="module_text_title"></a> [text\_title](#module\_text\_title) | ./modules/widgets/text/title | n/a |
| <a name="module_widget_alarm_metric"></a> [widget\_alarm\_metric](#module\_widget\_alarm\_metric) | ./modules/widgets/alarm/metric | n/a |
Expand Down
70 changes: 39 additions & 31 deletions modules/dashboard/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,45 @@ locals {

# necessary to always have at least empty list for each widget
widget_defaults = {
"container/cpu" = []
"container/memory" = []
"container/network" = []
"container/network-in" = []
"container/network-out" = []
"container/restarts" = []
"container/replicas" = []
"balancer/2xx" = []
"balancer/4xx" = []
"balancer/5xx" = []
"text/title" = []
"log-based" = []
"custom" = []
"application" = []
"logs-insight/logs" = []
"logs-insight/metric" = []
"alarm/status" = []
"alarm/metric" = []
"sla-slo-sli" = []
"rds/cpu" = []
"rds/memory" = []
"rds/disk" = []
"rds/connections" = []
"container/cpu" = []
"container/memory" = []
"container/network" = []
"container/network-in" = []
"container/network-out" = []
"container/restarts" = []
"container/replicas" = []
"contaner/request-count" = []
"contaner/response-time" = []
"contaner/external-health-check" = []
"balancer/2xx" = []
"balancer/4xx" = []
"balancer/5xx" = []
"text/title" = []
"log-based" = []
"custom" = []
"application" = []
"logs-insight/logs" = []
"logs-insight/metric" = []
"alarm/status" = []
"alarm/metric" = []
"sla-slo-sli" = []
"rds/cpu" = []
"rds/memory" = []
"rds/disk" = []
"rds/connections" = []
}

# widget aliases
container_cpu = local.widget_config["container/cpu"]
container_memory = local.widget_config["container/memory"]
container_network = local.widget_config["container/network"]
container_network_in = local.widget_config["container/network-in"]
container_network_out = local.widget_config["container/network-out"]
container_restarts = local.widget_config["container/restarts"]
container_replicas = local.widget_config["container/replicas"]
container_cpu = local.widget_config["container/cpu"]
container_memory = local.widget_config["container/memory"]
container_network = local.widget_config["container/network"]
container_network_in = local.widget_config["container/network-in"]
container_network_out = local.widget_config["container/network-out"]
container_restarts = local.widget_config["container/restarts"]
container_replicas = local.widget_config["container/replicas"]
container_request_count = local.widget_config["container/request-count"]
container_response_time = local.widget_config["container/response-time"]
container_external_health_check = local.widget_config["container/external-health-check"]

balancer_2xx = local.widget_config["balancer/2xx"]
balancer_4xx = local.widget_config["balancer/4xx"]
Expand Down Expand Up @@ -120,6 +126,9 @@ locals {
module.container_network_out_widget[*].data,
module.container_restarts_widget[*].data,
module.container_replicas_widget[*].data,
module.container_request_count_widget[*].data,
module.container_response_time_widget[*].data,
module.container_external_health_check_widget[*].data,

// Widget/Traffic
module.container_balancer_2xx_widget[*].data,
Expand Down Expand Up @@ -152,7 +161,6 @@ locals {
module.widget_alarm_status[*].data,
module.widget_alarm_metric[*].data,


module.widget_sla_slo_sli[*].data
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../../base | n/a |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | n/a | `string` | `null` | no |
| <a name="input_anomaly_detection"></a> [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no |
| <a name="input_cluster"></a> [cluster](#input\_cluster) | n/a | `string` | n/a | yes |
| <a name="input_container"></a> [container](#input\_container) | n/a | `string` | n/a | yes |
| <a name="input_coordinates"></a> [coordinates](#input\_coordinates) | position | <pre>object({<br> x : number<br> y : number<br> width : number<br> height : number<br> })</pre> | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | n/a | `string` | `"default"` | no |
| <a name="input_period"></a> [period](#input\_period) | stats | `number` | `300` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_data"></a> [data](#output\_data) | n/a |
<!-- END_TF_DOCS -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

No requirements.

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../../base | n/a |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_anomaly_detection"></a> [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no |
| <a name="input_coordinates"></a> [coordinates](#input\_coordinates) | position | <pre>object({<br> x : number<br> y : number<br> width : number<br> height : number<br> })</pre> | n/a | yes |
| <a name="input_healthcheck_id"></a> [healthcheck\_id](#input\_healthcheck\_id) | n/a | `string` | `""` | no |
| <a name="input_period"></a> [period](#input\_period) | stats | `number` | `300` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_data"></a> [data](#output\_data) | n/a |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module "base" {
source = "../../base"

coordinates = var.coordinates

name = "External Health Check"

defaults = {
MetricNamespace = "AWS/Route53"
HealthCheckId = var.healthcheck_id
}

period = var.period
region = "us-east-1"

metrics = [
{ MetricName = "HealthCheckPercentageHealthy", anomaly_detection = var.anomaly_detection },
{ MetricName = "HealthCheckStatus", anomaly_detection = var.anomaly_detection }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "data" {
value = module.base.data
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# position
variable "coordinates" {
type = object({
x : number
y : number
width : number
height : number
})
}

# stats
variable "period" {
type = number
default = 300
}

variable "healthcheck_id" {
type = string
default = ""
}

variable "anomaly_detection" {
type = bool
default = false
description = "Allow to enable anomaly detection on widget metrics"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../../base | n/a |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | n/a | `string` | `null` | no |
| <a name="input_anomaly_detection"></a> [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no |
| <a name="input_cluster"></a> [cluster](#input\_cluster) | n/a | `string` | n/a | yes |
| <a name="input_container"></a> [container](#input\_container) | n/a | `string` | n/a | yes |
| <a name="input_coordinates"></a> [coordinates](#input\_coordinates) | position | <pre>object({<br> x : number<br> y : number<br> width : number<br> height : number<br> })</pre> | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | n/a | `string` | `"default"` | no |
| <a name="input_period"></a> [period](#input\_period) | stats | `number` | `300` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_data"></a> [data](#output\_data) | n/a |
<!-- END_TF_DOCS -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../../base | n/a |

## Resources

| Name | Type |
|------|------|
| [aws_lb_target_group.target_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lb_target_group) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_anomaly_detection"></a> [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no |
| <a name="input_coordinates"></a> [coordinates](#input\_coordinates) | position | <pre>object({<br> x : number<br> y : number<br> width : number<br> height : number<br> })</pre> | n/a | yes |
| <a name="input_period"></a> [period](#input\_period) | stats | `number` | `300` | no |
| <a name="input_target_group_arn"></a> [target\_group\_arn](#input\_target\_group\_arn) | n/a | `string` | `null` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_data"></a> [data](#output\_data) | n/a |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
18 changes: 18 additions & 0 deletions modules/dashboard/modules/widgets/container/request-count/base.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module "base" {
source = "../../base"

coordinates = var.coordinates

name = "Request Count"

defaults = {
MetricNamespace = "AWS/ApplicationELB"
TargetGroup = local.target_group
}

period = var.period

metrics = [
{ MetricName = "RequestCountPerTarget", anomaly_detection = var.anomaly_detection }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "data" {
value = module.base.data
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "aws_lb_target_group" "target_group" {
count = var.target_group_arn == null ? 1 : 0
}

locals {
target_group = "targetgroup/${split("targetgroup/", var.target_group_arn == null ? data.aws_lb_target_group.target_group[0].arn : var.target_group_arn)[1]}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
variable "target_group_arn" {
type = string
default = null
}

# position
variable "coordinates" {
type = object({
x : number
y : number
width : number
height : number
})
}

# stats
variable "period" {
type = number
default = 300
}

variable "anomaly_detection" {
type = bool
default = false
description = "Allow to enable anomaly detection on widget metrics"
}
Loading

0 comments on commit fd3b02b

Please sign in to comment.