Skip to content

Commit

Permalink
fix: adjust network widget and add two additional for in and out
Browse files Browse the repository at this point in the history
  • Loading branch information
aramkarapetian committed Oct 5, 2023
1 parent 1f2e51c commit 121c1b1
Show file tree
Hide file tree
Showing 15 changed files with 424 additions and 58 deletions.
2 changes: 2 additions & 0 deletions modules/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
| <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_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_restarts_widget"></a> [container\_restarts\_widget](#module\_container\_restarts\_widget) | ./modules/widgets/container/restarts | n/a |
Expand Down
58 changes: 32 additions & 26 deletions modules/dashboard/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,39 @@ locals {

# necessary to always have at least empty list for each widget
widget_defaults = {
"container/cpu" = []
"container/memory" = []
"container/network" = []
"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" = []
"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_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"]

balancer_2xx = local.widget_config["balancer/2xx"]
balancer_4xx = local.widget_config["balancer/4xx"]
Expand Down Expand Up @@ -112,6 +116,8 @@ locals {
module.container_cpu_widget[*].data,
module.container_memory_widget[*].data,
module.container_network_widget[*].data,
module.container_network_in_widget[*].data,
module.container_network_out_widget[*].data,
module.container_restarts_widget[*].data,
module.container_replicas_widget[*].data,

Expand Down
76 changes: 76 additions & 0 deletions modules/dashboard/modules/widgets/container/network-in/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!-- 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_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` | `true` | 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_data_source_uid"></a> [data\_source\_uid](#input\_data\_source\_uid) | The grafana dashboard widget item data source id | `string` | 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 |
| <a name="input_platform"></a> [platform](#input\_platform) | The platform/service/adapter to create dashboard on. for now only cloudwatch and grafana supported | `string` | `"cloudwatch"` | no |

## Outputs

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

platform = var.platform
data_source_uid = var.data_source_uid

coordinates = var.coordinates

name = "Network < In"

defaults = {
MetricNamespace = "ContainerInsights"
ClusterName = var.cluster
Namespace = var.namespace
PodName = var.container
accountId = var.account_id
anomaly_detection = var.anomaly_detection
}

period = var.period

metrics = [
{ MetricName = "pod_network_rx_bytes", color = "#17becf", label = "In", 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,50 @@
variable "platform" {
type = string
default = "cloudwatch"
description = "The platform/service/adapter to create dashboard on. for now only cloudwatch and grafana supported"
}

variable "data_source_uid" {
type = string
description = "The grafana dashboard widget item data source id"
}

variable "container" {
type = string
}

variable "cluster" {
type = string
}

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

variable "account_id" {
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 = true
description = "Allow to enable anomaly detection on widget metrics"
}
76 changes: 76 additions & 0 deletions modules/dashboard/modules/widgets/container/network-out/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!-- 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_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` | `true` | 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_data_source_uid"></a> [data\_source\_uid](#input\_data\_source\_uid) | The grafana dashboard widget item data source id | `string` | 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 |
| <a name="input_platform"></a> [platform](#input\_platform) | The platform/service/adapter to create dashboard on. for now only cloudwatch and grafana supported | `string` | `"cloudwatch"` | no |

## Outputs

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

platform = var.platform
data_source_uid = var.data_source_uid

coordinates = var.coordinates

name = "Network > Out"

defaults = {
MetricNamespace = "ContainerInsights"
ClusterName = var.cluster
Namespace = var.namespace
PodName = var.container
accountId = var.account_id
anomaly_detection = var.anomaly_detection
}

period = var.period

metrics = [
{ MetricName = "pod_network_tx_bytes", color = "#e377c2", label = "Out", 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,50 @@
variable "platform" {
type = string
default = "cloudwatch"
description = "The platform/service/adapter to create dashboard on. for now only cloudwatch and grafana supported"
}

variable "data_source_uid" {
type = string
description = "The grafana dashboard widget item data source id"
}

variable "container" {
type = string
}

variable "cluster" {
type = string
}

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

variable "account_id" {
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 = true
description = "Allow to enable anomaly detection on widget metrics"
}
Loading

0 comments on commit 121c1b1

Please sign in to comment.