Skip to content

Commit

Permalink
fix: anomaly detection was off by default and was for all charts
Browse files Browse the repository at this point in the history
  • Loading branch information
aramkarapetian committed Oct 6, 2023
1 parent 121c1b1 commit c055750
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion modules/dashboard/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ locals {
namespace = "default"
width = 6
height = 6
anomaly_detection = false
anomaly_detection = true
expressions = []
yAxis = { left = { min = 0 } }
},
Expand Down
2 changes: 1 addition & 1 deletion modules/dashboard/modules/widgets/container/cpu/base.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ module "base" {

metrics = [
{ MetricName = "pod_cpu_limit", color = "#FF0F3C", label = "Limit" },
{ MetricName = "pod_cpu_usage_total", color = "#007CEF", label = "Current", anomaly_detection = true }
{ MetricName = "pod_cpu_usage_total", color = "#007CEF", label = "Current", anomaly_detection = var.anomaly_detection }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ No resources.
| 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_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 |
Expand Down
2 changes: 1 addition & 1 deletion modules/dashboard/modules/widgets/container/memory/base.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ module "base" {

metrics = [
{ MetricName = "pod_memory_limit", color = "#FF0F3C", label = "Limit" },
{ MetricName = "pod_memory_working_set", color = "#007CEF", label = "Current", anomaly_detection = true }
{ MetricName = "pod_memory_working_set", color = "#007CEF", label = "Current", anomaly_detection = var.anomaly_detection }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ variable "period" {

variable "anomaly_detection" {
type = bool
default = false
default = true
description = "Allow to enable anomaly detection on widget metrics"
}
11 changes: 5 additions & 6 deletions modules/dashboard/modules/widgets/container/restarts/base.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ module "base" {
stat = "Maximum"

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
Expand Down
1 change: 1 addition & 0 deletions modules/dashboard/tests/widgets-container/1-example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module "dashboard-with-container-metrics" {
name = "dashboard-with-container-metrics-test"
defaults = {
cluster : local.cluster
anomaly_detection : false
}
rows = [
[
Expand Down
13 changes: 7 additions & 6 deletions modules/dashboard/widgets-container.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ 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)
account_id = try(local.container_cpu[count.index].accountId, data.aws_caller_identity.project.account_id)
anomaly_detection = try(local.container_memory[count.index].anomaly_detection, true)
}

module "container_memory_widget" {
Expand All @@ -43,7 +44,7 @@ module "container_memory_widget" {
namespace = local.container_memory[count.index].namespace

account_id = try(local.container_memory[count.index].accountId, data.aws_caller_identity.project.account_id)
anomaly_detection = try(local.container_memory[count.index].anomaly_detection, false)
anomaly_detection = try(local.container_memory[count.index].anomaly_detection, true)
}

module "container_network_widget" {
Expand All @@ -67,7 +68,7 @@ module "container_network_widget" {
namespace = local.container_network[count.index].namespace

account_id = try(local.container_network[count.index].accountId, data.aws_caller_identity.project.account_id)
anomaly_detection = try(local.container_network[count.index].anomaly_detection, false)
anomaly_detection = try(local.container_network[count.index].anomaly_detection, true)
}

module "container_network_in_widget" {
Expand All @@ -91,7 +92,7 @@ module "container_network_in_widget" {
namespace = local.container_network_in[count.index].namespace

account_id = try(local.container_network_in[count.index].accountId, data.aws_caller_identity.project.account_id)
anomaly_detection = try(local.container_network_in[count.index].anomaly_detection, false)
anomaly_detection = try(local.container_network_in[count.index].anomaly_detection, true)
}

module "container_network_out_widget" {
Expand All @@ -115,7 +116,7 @@ module "container_network_out_widget" {
namespace = local.container_network_out[count.index].namespace

account_id = try(local.container_network_out[count.index].accountId, data.aws_caller_identity.project.account_id)
anomaly_detection = try(local.container_network_out[count.index].anomaly_detection, false)
anomaly_detection = try(local.container_network_out[count.index].anomaly_detection, true)
}

module "container_replicas_widget" {
Expand Down Expand Up @@ -156,5 +157,5 @@ module "container_restarts_widget" {
namespace = local.container_restarts[count.index].namespace

account_id = try(local.container_restarts[count.index].accountId, data.aws_caller_identity.project.account_id)
anomaly_detection = try(local.container_restarts[count.index].anomaly_detection, false)
anomaly_detection = try(local.container_restarts[count.index].anomaly_detection, true)
}

0 comments on commit c055750

Please sign in to comment.