Skip to content

Commit

Permalink
fix: replicas and restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
aramkarapetian committed Oct 6, 2023
1 parent 4d1de87 commit bf99dd2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ No resources.

| 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` | `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
8 changes: 4 additions & 4 deletions modules/dashboard/modules/widgets/container/replicas/base.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module "base" {

coordinates = var.coordinates

name = "Replicas / ${var.container}"
name = "Replicas"

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

period = var.period

metrics = [
{ MetricName = "kube_deployment_spec_replicas", label = "Deployment Spec" },
{ MetricName = "kube_deployment_status_replicas_available", label = "Available" }
{ MetricName = "kube_deployment_spec_replicas", PodName = var.container, label = "Deployment Spec", anomaly_detection = var.anomaly_detection },
{ MetricName = "kube_deployment_status_replicas_available", PodName = var.container, label = "Available", anomaly_detection = var.anomaly_detection },
{ MetricNamespace = "ContainerInsights", Service = var.container, MetricName = "service_number_of_running_pods", label = "Available", anomaly_detection = var.anomaly_detection }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ variable "period" {
type = number
default = 300
}

variable "anomaly_detection" {
type = bool
default = true
description = "Allow to enable anomaly detection on widget metrics"
}
18 changes: 9 additions & 9 deletions modules/dashboard/tests/widgets-container/1-example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module "dashboard-with-container-metrics" {
name = "dashboard-with-container-metrics-test"
defaults = {
cluster : local.cluster
anomaly_detection : false
anomaly_detection : true
}
rows = [
[
Expand All @@ -32,14 +32,14 @@ module "dashboard-with-container-metrics" {
type : "container/network-out",
container : local.container
},
# {
# type : "container/restarts",
# container : local.container,
# },
# {
# type : "container/replicas",
# container : local.container,
# },
{
type : "container/restarts",
container : local.container,
},
{
type : "container/replicas",
container : local.container,
},
]
]
}
2 changes: 2 additions & 0 deletions modules/dashboard/widgets-container.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ module "container_replicas_widget" {
container = local.container_replicas[count.index].container
cluster = local.container_replicas[count.index].cluster
namespace = local.container_replicas[count.index].namespace

anomaly_detection = try(local.container_replicas[count.index].anomaly_detection, true)
}

module "container_restarts_widget" {
Expand Down

0 comments on commit bf99dd2

Please sign in to comment.