Skip to content

Commit

Permalink
feat(DMVP-1232): Added container widgets for all requests, error rate…
Browse files Browse the repository at this point in the history
…, health check
  • Loading branch information
viktoryathegreat committed Oct 23, 2023
1 parent 824a1e8 commit b8654cf
Show file tree
Hide file tree
Showing 19 changed files with 553 additions and 4 deletions.
3 changes: 3 additions & 0 deletions modules/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

| Name | Source | Version |
|------|--------|---------|
| <a name="module_container_all_requests"></a> [container\_all\_requests](#module\_container\_all\_requests) | ./modules/widgets/container/all-requests | n/a |
| <a name="module_container_balancer_2xx_widget"></a> [container\_balancer\_2xx\_widget](#module\_container\_balancer\_2xx\_widget) | ./modules/widgets/balancer/2xx | n/a |
| <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 |
Expand All @@ -75,7 +76,9 @@
| <a name="module_container_balancer_traffic_widget"></a> [container\_balancer\_traffic\_widget](#module\_container\_balancer\_traffic\_widget) | ./modules/widgets/balancer/traffic | n/a |
| <a name="module_container_balancer_unhealthy_request_count_widget"></a> [container\_balancer\_unhealthy\_request\_count\_widget](#module\_container\_balancer\_unhealthy\_request\_count\_widget) | ./modules/widgets/balancer/unhealthy-request-count | 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_error_rate"></a> [container\_error\_rate](#module\_container\_error\_rate) | ./modules/widgets/container/error-rate | 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_health_check"></a> [container\_health\_check](#module\_container\_health\_check) | ./modules/widgets/container/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 |
Expand Down
9 changes: 9 additions & 0 deletions modules/dashboard/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ locals {
"container/request-count" = []
"container/response-time" = []
"container/external-health-check" = []
"container/error-rate" = []
"container/all-requests" = []
"container/health-check" = []
"balancer/2xx" = []
"balancer/4xx" = []
"balancer/5xx" = []
Expand Down Expand Up @@ -109,6 +112,9 @@ locals {
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"]
container_error_rate = local.widget_config["container/error-rate"]
container_all_requests = local.widget_config["container/all-requests"]
container_health_check = local.widget_config["container/health-check"]

balancer_2xx = local.widget_config["balancer/2xx"]
balancer_4xx = local.widget_config["balancer/4xx"]
Expand Down Expand Up @@ -165,6 +171,9 @@ locals {
module.container_request_count_widget[*].data,
module.container_response_time_widget[*].data,
module.container_external_health_check_widget[*].data,
module.container_error_rate[*].data,
module.container_all_requests[*].data,
module.container_health_check[*].data,

// Widget/Traffic
module.container_balancer_2xx_widget[*].data,
Expand Down
78 changes: 78 additions & 0 deletions modules/dashboard/modules/widgets/container/all-requests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!-- 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.balancer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lb) | data source |
| [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_balancer_arn"></a> [balancer\_arn](#input\_balancer\_arn) | n/a | `string` | `null` | no |
| <a name="input_balancer_name"></a> [balancer\_name](#input\_balancer\_name) | n/a | `string` | `null` | 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 -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
data "aws_lb_target_group" "target_group" {
count = var.target_group_arn == null ? 1 : 0
}

data "aws_lb" "balancer" {
count = var.balancer_arn == null ? 1 : 0

name = var.balancer_name
}

locals {
balancer = split("loadbalancer/", var.balancer_arn == null ? data.aws_lb.balancer[0].arn : var.balancer_arn)[1]
balancer_name = split("/", local.balancer)[1]
target_group = "targetgroup/${split("targetgroup/", var.target_group_arn == null ? data.aws_lb_target_group.target_group[0].arn : var.target_group_arn)[1]}"
}
24 changes: 24 additions & 0 deletions modules/dashboard/modules/widgets/container/all-requests/base.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module "base" {
source = "../../base"

coordinates = var.coordinates

name = "All Requests"

stat = "Sum"

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

period = var.period

metrics = [
{ MetricName = "HTTPCode_Target_2XX_Count", color = "#3ECE76" },
{ MetricName = "HTTPCode_Target_3XX_Count", color = "#FFC300" },
{ MetricName = "HTTPCode_Target_4XX_Count", color = "#FF774D" },
{ MetricName = "HTTPCode_Target_5XX_Count", color = "#FF0F3C" },
]
}
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,36 @@
variable "target_group_arn" {
type = string
default = null
}

variable "balancer_name" {
type = string
default = null
}

variable "balancer_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"
}
78 changes: 78 additions & 0 deletions modules/dashboard/modules/widgets/container/error-rate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!-- 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.balancer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lb) | data source |
| [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_balancer_arn"></a> [balancer\_arn](#input\_balancer\_arn) | n/a | `string` | `null` | no |
| <a name="input_balancer_name"></a> [balancer\_name](#input\_balancer\_name) | n/a | `string` | `null` | 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 -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
data "aws_lb_target_group" "target_group" {
count = var.target_group_arn == null ? 1 : 0
}

data "aws_lb" "balancer" {
count = var.balancer_arn == null ? 1 : 0

name = var.balancer_name
}

locals {
balancer = split("loadbalancer/", var.balancer_arn == null ? data.aws_lb.balancer[0].arn : var.balancer_arn)[1]
balancer_name = split("/", local.balancer)[1]
target_group = "targetgroup/${split("targetgroup/", var.target_group_arn == null ? data.aws_lb_target_group.target_group[0].arn : var.target_group_arn)[1]}"
}
30 changes: 30 additions & 0 deletions modules/dashboard/modules/widgets/container/error-rate/base.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module "base" {
source = "../../base"

coordinates = var.coordinates

name = "Error Rate"

stat = "Sum"

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

period = var.period

metrics = [
{ id = "m2", MetricName = "HTTPCode_Target_2XX_Count", visible = false },
{ id = "m5", MetricName = "HTTPCode_Target_5XX_Count", visible = false },
]

expressions = [
{
expression = "m5/m2*100"
label = "Percentage"
color = "#FF103B"
}
]
}
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,36 @@
variable "target_group_arn" {
type = string
default = null
}

variable "balancer_name" {
type = string
default = null
}

variable "balancer_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 b8654cf

Please sign in to comment.