From 3fedbd98217fc46ff784f980ae1b3db759cd0144 Mon Sep 17 00:00:00 2001 From: "Karapetyan, Aram" Date: Thu, 5 Oct 2023 18:52:45 +0400 Subject: [PATCH] fix: adjust cpu widget --- .gitignore | 9 +++++---- modules/dashboard/locals.tf | 2 +- .../widgets/base/platforms/cloudwatch/widget.tf | 2 +- .../modules/widgets/container/cpu/README.md | 4 ++-- .../modules/widgets/container/cpu/base.tf | 17 ++++++++--------- .../modules/widgets/container/cpu/variables.tf | 4 ++-- modules/dashboard/widgets-container.tf | 3 +-- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index caff1ac..45329c9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ **/builds/* # .tfstate files -*.tfstate -*.tfstate.* +**/*.tfstate +**/*.tfstate.* # Crash log files crash.log @@ -29,6 +29,7 @@ override.tf.json # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* -.DS_Store +**/.DS_Store -.terraform.lock.hcl +**/.terraform.lock.hcl +**/.terraform diff --git a/modules/dashboard/locals.tf b/modules/dashboard/locals.tf index 52e3eb0..414225c 100644 --- a/modules/dashboard/locals.tf +++ b/modules/dashboard/locals.tf @@ -39,7 +39,7 @@ locals { widget_default_values = merge( { region = "eu-central-1" - period = 300 + period = 60 stat = "Sum" namespace = "default" width = 6 diff --git a/modules/dashboard/modules/widgets/base/platforms/cloudwatch/widget.tf b/modules/dashboard/modules/widgets/base/platforms/cloudwatch/widget.tf index ddbed45..a518757 100644 --- a/modules/dashboard/modules/widgets/base/platforms/cloudwatch/widget.tf +++ b/modules/dashboard/modules/widgets/base/platforms/cloudwatch/widget.tf @@ -24,7 +24,7 @@ locals { anomaly_detection_metrics = [for index, row in local.metrics_with_defaults : try(row.anomaly_detection, false) ? [{ expression = "ANOMALY_DETECTION_BAND(m${index + 1}, 2)" id = "ad${index + 1}" - label = "anomaly_detection (${row.MetricName})" + label = "Anomaly Band" }] : [] if try(row.anomaly_detection, false)] diff --git a/modules/dashboard/modules/widgets/container/cpu/README.md b/modules/dashboard/modules/widgets/container/cpu/README.md index ba1f4b5..9ef56b0 100644 --- a/modules/dashboard/modules/widgets/container/cpu/README.md +++ b/modules/dashboard/modules/widgets/container/cpu/README.md @@ -67,13 +67,13 @@ No requirements. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [account\_id](#input\_account\_id) | n/a | `string` | `null` | no | -| [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no | +| [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `true` | no | | [cluster](#input\_cluster) | n/a | `string` | n/a | yes | | [container](#input\_container) | n/a | `string` | n/a | yes | | [coordinates](#input\_coordinates) | position |
object({
x : number
y : number
width : number
height : number
})
| n/a | yes | | [data\_source\_uid](#input\_data\_source\_uid) | The grafana dashboard widget item data source id | `string` | n/a | yes | | [namespace](#input\_namespace) | n/a | `string` | `"default"` | no | -| [period](#input\_period) | stats | `number` | `300` | no | +| [period](#input\_period) | stats | `number` | `60` | no | | [platform](#input\_platform) | The platform/service/adapter to create dashboard on. for now only cloudwatch and grafana supported | `string` | `"cloudwatch"` | no | ## Outputs diff --git a/modules/dashboard/modules/widgets/container/cpu/base.tf b/modules/dashboard/modules/widgets/container/cpu/base.tf index be9542b..f17b96a 100644 --- a/modules/dashboard/modules/widgets/container/cpu/base.tf +++ b/modules/dashboard/modules/widgets/container/cpu/base.tf @@ -14,21 +14,20 @@ module "base" { coordinates = var.coordinates - name = "CPU / ${var.container}" + name = "CPU" defaults = { - MetricNamespace = "ContainerInsights" - ClusterName = var.cluster - Namespace = var.namespace - PodName = var.container - accountId = var.account_id - anomaly_detection = var.anomaly_detection + MetricNamespace = "ContainerInsights" + ClusterName = var.cluster + Namespace = var.namespace + PodName = var.container + accountId = var.account_id } period = var.period metrics = [ - { MetricName = "pod_cpu_usage_total", label = "Current" }, - { MetricName = "pod_cpu_limit", color = "#d62728", label = "Limit" } + { MetricName = "pod_cpu_limit", color = "#FF0F3C", label = "Limit" }, + { MetricName = "pod_cpu_usage_total", color = "#007CEF", label = "Current", anomaly_detection = true } ] } diff --git a/modules/dashboard/modules/widgets/container/cpu/variables.tf b/modules/dashboard/modules/widgets/container/cpu/variables.tf index ff3cfdf..94b759e 100644 --- a/modules/dashboard/modules/widgets/container/cpu/variables.tf +++ b/modules/dashboard/modules/widgets/container/cpu/variables.tf @@ -40,11 +40,11 @@ variable "coordinates" { # stats variable "period" { type = number - default = 300 + default = 60 } variable "anomaly_detection" { type = bool - default = false + default = true description = "Allow to enable anomaly detection on widget metrics" } diff --git a/modules/dashboard/widgets-container.tf b/modules/dashboard/widgets-container.tf index af4100f..59b83d6 100644 --- a/modules/dashboard/widgets-container.tf +++ b/modules/dashboard/widgets-container.tf @@ -19,8 +19,7 @@ module "container_cpu_widget" { cluster = local.container_cpu[count.index].cluster namespace = local.container_cpu[count.index].namespace - account_id = try(local.container_cpu[count.index].accountId, data.aws_caller_identity.project.account_id) - anomaly_detection = try(local.container_cpu[count.index].anomaly_detection, false) + account_id = try(local.container_cpu[count.index].accountId, data.aws_caller_identity.project.account_id) } module "container_memory_widget" {