diff --git a/modules/dashboard/README.md b/modules/dashboard/README.md index 81ee5d5..c0ef7d8 100644 --- a/modules/dashboard/README.md +++ b/modules/dashboard/README.md @@ -77,15 +77,23 @@ module "this" { | [block\_sla](#module\_block\_sla) | ./modules/blocks/sla | n/a | | [container\_cpu\_widget](#module\_container\_cpu\_widget) | ./modules/widgets/container/cpu | n/a | | [container\_memory\_widget](#module\_container\_memory\_widget) | ./modules/widgets/container/memory | n/a | +| [container\_network\_traffic\_widget](#module\_container\_network\_traffic\_widget) | ./modules/widgets/container/network-traffic | n/a | +| [container\_network\_transmit\_widget](#module\_container\_network\_transmit\_widget) | ./modules/widgets/container/network-transmit | n/a | | [container\_network\_widget](#module\_container\_network\_widget) | ./modules/widgets/container/network | n/a | | [container\_replicas\_widget](#module\_container\_replicas\_widget) | ./modules/widgets/container/replicas | n/a | | [container\_request\_count\_widget](#module\_container\_request\_count\_widget) | ./modules/widgets/container/request-count | n/a | | [container\_response\_time\_widget](#module\_container\_response\_time\_widget) | ./modules/widgets/container/response-time | n/a | | [container\_restarts\_widget](#module\_container\_restarts\_widget) | ./modules/widgets/container/restarts | n/a | | [ingress\_connections\_widget](#module\_ingress\_connections\_widget) | ./modules/widgets/ingress/connections | n/a | +| [ingress\_cpu\_widget](#module\_ingress\_cpu\_widget) | ./modules/widgets/ingress/cpu | n/a | +| [ingress\_latency\_widget](#module\_ingress\_latency\_widget) | ./modules/widgets/ingress/latency | n/a | +| [ingress\_memory\_widget](#module\_ingress\_memory\_widget) | ./modules/widgets/ingress/memory | n/a | | [ingress\_request\_count\_widget](#module\_ingress\_request\_count\_widget) | ./modules/widgets/ingress/request-count | n/a | | [ingress\_request\_rate\_widget](#module\_ingress\_request\_rate\_widget) | ./modules/widgets/ingress/request-rate | n/a | -| [ingress\_response\_time\_widget](#module\_ingress\_response\_time\_widget) | ./modules/widgets/ingress/response-time | n/a | +| [logs\_count\_widget](#module\_logs\_count\_widget) | ./modules/widgets/logs/count | n/a | +| [logs\_error\_rate\_widget](#module\_logs\_error\_rate\_widget) | ./modules/widgets/logs/error-rate | n/a | +| [logs\_warning\_rate\_widget](#module\_logs\_warning\_rate\_widget) | ./modules/widgets/logs/warning-rate | n/a | +| [pod\_cpu\_widget](#module\_pod\_cpu\_widget) | ./modules/widgets/pod/cpu | n/a | | [text\_title](#module\_text\_title) | ./modules/widgets/text/title | n/a | | [text\_title\_with\_collapse](#module\_text\_title\_with\_collapse) | ./modules/widgets/text/title-with-collapse | n/a | | [text\_title\_with\_link](#module\_text\_title\_with\_link) | ./modules/widgets/text/title-with-link | n/a | diff --git a/modules/dashboard/locals.tf b/modules/dashboard/locals.tf index 3f1952b..0ca36d8 100644 --- a/modules/dashboard/locals.tf +++ b/modules/dashboard/locals.tf @@ -53,10 +53,10 @@ locals { # default values from module and provided from outside widget_default_values = merge( { - period = 3 # in minutes + period = 5 # in minutes stat = "Sum" width = 6 - height = 8 + height = 5 expressions = [] yAxis = { left = { min = 0 } } data_source = var.data_source @@ -112,12 +112,19 @@ locals { values(module.container_replicas_widget).*.data, values(module.container_request_count_widget).*.data, values(module.container_response_time_widget).*.data, + values(module.container_network_traffic_widget).*.data, + values(module.container_network_transmit_widget).*.data, + + # Pod widgets + values(module.pod_cpu_widget).*.data, # Ingress widgets values(module.ingress_connections_widget).*.data, values(module.ingress_request_rate_widget).*.data, values(module.ingress_request_count_widget).*.data, - values(module.ingress_response_time_widget).*.data, + values(module.ingress_latency_widget).*.data, + values(module.ingress_cpu_widget).*.data, + values(module.ingress_memory_widget).*.data, # Text widgets values(module.text_title).*.data, @@ -130,5 +137,10 @@ locals { # single widgets values(module.widget_custom).*.data, + + # Logs widgets + values(module.logs_count_widget).*.data, + values(module.logs_error_rate_widget).*.data, + values(module.logs_warning_rate_widget).*.data, ) } diff --git a/modules/dashboard/modules/blocks/ingress/output.tf b/modules/dashboard/modules/blocks/ingress/output.tf index 37dd137..449f5dc 100644 --- a/modules/dashboard/modules/blocks/ingress/output.tf +++ b/modules/dashboard/modules/blocks/ingress/output.tf @@ -7,18 +7,23 @@ output "result" { [ { type : "ingress/request-rate" }, { type : "ingress/connections" }, - { type : "ingress/response-time" }, - { type : "ingress/request-count" } + { type : "ingress/latency" }, + { type : "ingress/latency", by_host : true }, ], [ - { type : "ingress/request-rate", by_host : true }, - { type : "ingress/response-time", by_host : true }, - { type : "ingress/request-count", by_host : true }, - { type : "ingress/request-count", by_host : true, only_5xx : true } + { type : "ingress/request-count" }, + { type : "ingress/request-count", only_5xx : true }, + { type : "ingress/request-count", only_5xx : true, by_path : true }, + { type : "ingress/request-count", only_5xx : true, by_status_path : true }, ], [ - { type : "container/cpu", container : "controller", namespace : "ingress-nginx", width : 12 }, - { type : "container/memory", container : "controller", namespace : "ingress-nginx", width : 12 } + { type : "ingress/cpu", pod : "nginx-ingress", namespace : "ingress-nginx", width : 4, }, + { type : "ingress/memory", pod : "nginx-ingress", namespace : "ingress-nginx", width : 4, }, + { type : "container/network-traffic", pod : "nginx-ingress", width : 4 }, + { type : "container/network-transmit", pod : "nginx-ingress", width : 4 }, + # { type : "logs/count", aggregated_metric : "controller"}, + # { type : "logs/error-rate", aggregated_metric : "controller"}, + # { type : "logs/warning-rate", aggregated_metric : "controller"}, ], ] } diff --git a/modules/dashboard/modules/widgets/base/README.md b/modules/dashboard/modules/widgets/base/README.md index f64f848..f1afe53 100644 --- a/modules/dashboard/modules/widgets/base/README.md +++ b/modules/dashboard/modules/widgets/base/README.md @@ -31,11 +31,13 @@ No resources. | [data\_source](#input\_data\_source) | The custom datasource for widget item |
object({| n/a | yes | | [decimals](#input\_decimals) | The decimals to enable on numbers | `number` | `0` | no | | [defaults](#input\_defaults) | Default values that will be passed to all metrics. | `any` | `{}` | no | +| [description](#input\_description) | Description for the widget | `string` | `""` | no | | [end](#input\_end) | end of widget | `string` | `null` | no | | [expressions](#input\_expressions) | Custom metric expressions over metrics, note that metrics have auto generated m1,m2,..., m{n} ids |
uid = optional(string, null)
type = optional(string, "prometheus")
})
list(object({| `[]` | no | | [fillOpacity](#input\_fillOpacity) | The fillOpacity value | `number` | `0` | no | | [metrics](#input\_metrics) | Metrics to be displayed on the widget. | `any` | `[]` | no | | [name](#input\_name) | n/a | `string` | n/a | yes | +| [options](#input\_options) | Configuration options for widget legend and tooltip. |
expression = string
label = optional(string, null)
accountId = optional(string, null)
visible = optional(bool, null)
color = optional(string, null)
yAxis = optional(string, null)
region = optional(string, null)
id = optional(string, null)
}))
object({|
legend = object({
calcs = optional(list(string), [])
displayMode = optional(string, "list")
placement = optional(string, "bottom")
show_legend = optional(bool, true)
})
tooltip = optional(object({
mode = optional(string, "single")
sort = optional(string, "none")
}), {})
})
{| no | | [period](#input\_period) | n/a | `number` | `3` | no | | [properties\_type](#input\_properties\_type) | The properties->type option for alarm widgets | `string` | `null` | no | | [query](#input\_query) | The Logs Insights complete build query without sources and other options(in case of metric) query | `string` | `null` | no | @@ -49,6 +51,7 @@ No resources. | [stat](#input\_stat) | n/a | `string` | `"Average"` | no | | [trend](#input\_trend) | trend of widget | `bool` | `null` | no | | [type](#input\_type) | The type of widget to be prepared | `string` | `"metric"` | no | +| [unit](#input\_unit) | Unit used for widget metric | `string` | `""` | no | | [view](#input\_view) | The view for log insights and alarm widgets | `string` | `null` | no | | [yAxis](#input\_yAxis) | Widget Item common yAxis option (applied only metric type widgets). | `any` |
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"show_legend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
}
{| no | diff --git a/modules/dashboard/modules/widgets/base/main.tf b/modules/dashboard/modules/widgets/base/main.tf index 4233a89..976a9a4 100644 --- a/modules/dashboard/modules/widgets/base/main.tf +++ b/modules/dashboard/modules/widgets/base/main.tf @@ -2,6 +2,7 @@ module "base_grafana" { source = "./platforms/grafana" name = var.name + description = var.description data_source = var.data_source coordinates = var.coordinates metrics = var.metrics @@ -19,5 +20,7 @@ module "base_grafana" { alarms = var.alarms properties_type = var.properties_type decimals = var.decimals + unit = var.unit fillOpacity = var.fillOpacity + options = var.options } diff --git a/modules/dashboard/modules/widgets/base/platforms/grafana/README.md b/modules/dashboard/modules/widgets/base/platforms/grafana/README.md index 2b068ad..8083586 100644 --- a/modules/dashboard/modules/widgets/base/platforms/grafana/README.md +++ b/modules/dashboard/modules/widgets/base/platforms/grafana/README.md @@ -29,9 +29,11 @@ No resources. | [data\_source](#input\_data\_source) | The custom datasource for widget item |
"left": {}
}
object({| n/a | yes | | [decimals](#input\_decimals) | The decimals to enable on numbers | `number` | `0` | no | | [defaults](#input\_defaults) | Default values that will be passed to all metrics. | `any` | `{}` | no | +| [description](#input\_description) | Description for the widget | `string` | `""` | no | | [fillOpacity](#input\_fillOpacity) | The fillOpacity value | `number` | `0` | no | | [metrics](#input\_metrics) | Metrics to be displayed on the widget. | `any` | `[]` | no | | [name](#input\_name) | n/a | `string` | n/a | yes | +| [options](#input\_options) | Configuration options for widget legend and tooltip. |
uid = optional(string, null)
type = optional(string, "prometheus")
})
object({|
legend = object({
calcs = optional(list(string), [])
displayMode = optional(string, "list")
placement = optional(string, "bottom")
show_legend = optional(bool, true)
})
tooltip = optional(object({
mode = optional(string, "single")
sort = optional(string, "none")
}), {})
})
{| no | | [period](#input\_period) | n/a | `number` | `3` | no | | [properties\_type](#input\_properties\_type) | The properties->type option for alarm widgets | `string` | `null` | no | | [query](#input\_query) | The Logs Insights complete build query without sources and other options(in case of metric) query | `string` | `null` | no | @@ -39,6 +41,7 @@ No resources. | [stacked](#input\_stacked) | The stacked option for log insights and alarm widgets | `bool` | `null` | no | | [stat](#input\_stat) | n/a | `string` | `"Average"` | no | | [type](#input\_type) | The type of widget to be prepared | `string` | `"metric"` | no | +| [unit](#input\_unit) | Unit used for widget metric | `string` | `""` | no | | [view](#input\_view) | The view for log insights and alarm widgets | `string` | `null` | no | ## Outputs diff --git a/modules/dashboard/modules/widgets/base/platforms/grafana/variables.tf b/modules/dashboard/modules/widgets/base/platforms/grafana/variables.tf index 15d27db..446e387 100644 --- a/modules/dashboard/modules/widgets/base/platforms/grafana/variables.tf +++ b/modules/dashboard/modules/widgets/base/platforms/grafana/variables.tf @@ -112,8 +112,48 @@ variable "decimals" { description = "The decimals to enable on numbers" } +variable "unit" { + type = string + default = "" + description = "Unit used for widget metric" +} + variable "fillOpacity" { type = number default = 0 description = "The fillOpacity value" } + +variable "options" { + type = object({ + legend = object({ + calcs = optional(list(string), []) + displayMode = optional(string, "list") + placement = optional(string, "bottom") + show_legend = optional(bool, true) + }) + tooltip = optional(object({ + mode = optional(string, "single") + sort = optional(string, "none") + }), {}) + }) + default = { + legend = { + calcs = [] + displayMode = "list" + placement = "bottom" + show_legend = true + } + tooltip = { + mode = "single" + sort = "none" + } + } + description = "Configuration options for widget legend and tooltip." +} + +variable "description" { + type = string + description = "Description for the widget" + default = "" +} diff --git a/modules/dashboard/modules/widgets/base/platforms/grafana/widget.tf b/modules/dashboard/modules/widgets/base/platforms/grafana/widget.tf index 74ee9ae..b5c251c 100644 --- a/modules/dashboard/modules/widgets/base/platforms/grafana/widget.tf +++ b/modules/dashboard/modules/widgets/base/platforms/grafana/widget.tf @@ -46,15 +46,37 @@ locals { }, ] } + unit = var.unit } + field_config_overrides = [ + for metric in local.metrics_with_defaults : { + matcher = { + id = "byName" + options = metric.label + } + properties = [ + { + id = "color" + value = { + mode = "fixed" + fixedColor = format("#%s", metric.color) + } + } + ] + } if metric.color != null + ] + + common_fields = ["MetricNamespace", "MetricName"] attribute_fields = ["accountId", "period", "stat", "label", "visible", "color", "yAxis"] custom_fields = ["anomaly_detection", "anomaly_deviation"] metrics_local = var.metrics == null ? [] : var.metrics # merge metrics with defaults - metrics_with_defaults = [for metric in local.metrics_local : merge(var.defaults, metric)] + metrics_with_defaults = [for metric in local.metrics_local : merge(var.defaults, metric, { + color = lookup(metric, "color", null) + })] type_map = { timeSeries = "timeseries" @@ -95,10 +117,11 @@ locals { }] data = { - datasource = var.data_source + datasource = var.data_source + description = var.description fieldConfig = { defaults = local.field_config_defaults - overrides = [] + overrides = local.field_config_overrides } gridPos = { h = var.coordinates.height @@ -110,13 +133,14 @@ locals { type = try(local.type_map[var.view], local.type_map.timeSeries) options = { legend = { - calcs = [] - displayMode = "list" - placement = "bottom" + calcs = lookup(var.options.legend, "calcs", []) + displayMode = lookup(var.options.legend, "displayMode", "list") + placement = lookup(var.options.legend, "placement", "bottom") + showLegend = lookup(var.options.legend, "show_legend", true) } tooltip = { - mode = "single" - sort = "none" + mode = lookup(var.options.tooltip, "mode", "single") + sort = lookup(var.options.tooltip, "sort", "none") } } targets = concat(local.query_targets, local.metric_targets) diff --git a/modules/dashboard/modules/widgets/base/variables.tf b/modules/dashboard/modules/widgets/base/variables.tf index 7128400..e6ee6af 100644 --- a/modules/dashboard/modules/widgets/base/variables.tf +++ b/modules/dashboard/modules/widgets/base/variables.tf @@ -174,3 +174,43 @@ variable "fillOpacity" { default = 0 description = "The fillOpacity value" } + +variable "options" { + type = object({ + legend = object({ + calcs = optional(list(string), []) + displayMode = optional(string, "list") + placement = optional(string, "bottom") + show_legend = optional(bool, true) + }) + tooltip = optional(object({ + mode = optional(string, "single") + sort = optional(string, "none") + }), {}) + }) + default = { + legend = { + calcs = [] + displayMode = "list" + placement = "bottom" + show_legend = true + } + tooltip = { + mode = "single" + sort = "none" + } + } + description = "Configuration options for widget legend and tooltip." +} + +variable "unit" { + type = string + default = "" + description = "Unit used for widget metric" +} + +variable "description" { + type = string + description = "Description for the widget" + default = "" +} diff --git a/modules/dashboard/modules/widgets/container/network-traffic/README.md b/modules/dashboard/modules/widgets/container/network-traffic/README.md new file mode 100644 index 0000000..ffae5e8 --- /dev/null +++ b/modules/dashboard/modules/widgets/container/network-traffic/README.md @@ -0,0 +1,42 @@ +# connections + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| 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\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [coordinates](#input\_coordinates) | position |
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"show_legend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
}
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [ingress\_type](#input\_ingress\_type) | n/a | `string` | `"nginx"` | no | +| [namespace](#input\_namespace) | n/a | `string` | `"default"` | no | +| [period](#input\_period) | stats | `number` | `3` | no | +| [pod](#input\_pod) | n/a | `string` | n/a | yes | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/container/network-traffic/base.tf b/modules/dashboard/modules/widgets/container/network-traffic/base.tf new file mode 100644 index 0000000..f8edd43 --- /dev/null +++ b/modules/dashboard/modules/widgets/container/network-traffic/base.tf @@ -0,0 +1,24 @@ +module "base" { + source = "../../base" + + name = "Network Traffic (${var.ingress_type}) [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + accountId = var.account_id + } + + fillOpacity = 20 + unit = "bytes" + + metrics = [ + { label : "Received", color : "7AAFF9", expression : "sum(rate(container_network_receive_bytes_total{pod=~\"^${var.pod}-[^-]+-[^-]+$\"}[$__rate_interval]))" }, + { label : "Sent", color : "EF8BBE", expression : "- sum(rate(container_network_transmit_bytes_total{pod=~\"^${var.pod}-[^-]+-[^-]+$\"}[$__rate_interval]))" }, + ] +} diff --git a/modules/dashboard/modules/widgets/ingress/response-time/output.tf b/modules/dashboard/modules/widgets/container/network-traffic/output.tf similarity index 100% rename from modules/dashboard/modules/widgets/ingress/response-time/output.tf rename to modules/dashboard/modules/widgets/container/network-traffic/output.tf diff --git a/modules/dashboard/modules/widgets/container/network-traffic/variables.tf b/modules/dashboard/modules/widgets/container/network-traffic/variables.tf new file mode 100644 index 0000000..5f439ca --- /dev/null +++ b/modules/dashboard/modules/widgets/container/network-traffic/variables.tf @@ -0,0 +1,59 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "prometheus") + }) + description = "The custom datasource for widget item" +} + +variable "ingress_type" { + type = string + default = "nginx" +} + +variable "pod" { + type = string +} + +variable "namespace" { + type = string + default = "default" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 3 +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/modules/widgets/container/network-transmit/README.md b/modules/dashboard/modules/widgets/container/network-transmit/README.md new file mode 100644 index 0000000..ffae5e8 --- /dev/null +++ b/modules/dashboard/modules/widgets/container/network-transmit/README.md @@ -0,0 +1,42 @@ +# connections + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| 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\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "prometheus")
})
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [ingress\_type](#input\_ingress\_type) | n/a | `string` | `"nginx"` | no | +| [namespace](#input\_namespace) | n/a | `string` | `"default"` | no | +| [period](#input\_period) | stats | `number` | `3` | no | +| [pod](#input\_pod) | n/a | `string` | n/a | yes | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/container/network-transmit/base.tf b/modules/dashboard/modules/widgets/container/network-transmit/base.tf new file mode 100644 index 0000000..3720612 --- /dev/null +++ b/modules/dashboard/modules/widgets/container/network-transmit/base.tf @@ -0,0 +1,26 @@ +module "base" { + source = "../../base" + + name = "Network Transmit Errors Per Container (${var.ingress_type}) [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + accountId = var.account_id + } + + options = { + legend = { + show_legend = false + } + } + + metrics = [ + { label : "Received Errors", color : "FF103B", expression : "rate(container_network_transmit_errors_total{pod=~\"^${var.pod}-[^-]+-[^-]+$\"}[$__rate_interval])" }, + ] +} diff --git a/modules/dashboard/modules/widgets/container/network-transmit/output.tf b/modules/dashboard/modules/widgets/container/network-transmit/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/container/network-transmit/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/container/network-transmit/variables.tf b/modules/dashboard/modules/widgets/container/network-transmit/variables.tf new file mode 100644 index 0000000..5f439ca --- /dev/null +++ b/modules/dashboard/modules/widgets/container/network-transmit/variables.tf @@ -0,0 +1,59 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "prometheus") + }) + description = "The custom datasource for widget item" +} + +variable "ingress_type" { + type = string + default = "nginx" +} + +variable "pod" { + type = string +} + +variable "namespace" { + type = string + default = "default" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 3 +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/modules/widgets/ingress/connections/base.tf b/modules/dashboard/modules/widgets/ingress/connections/base.tf index a30c106..7e2ead9 100644 --- a/modules/dashboard/modules/widgets/ingress/connections/base.tf +++ b/modules/dashboard/modules/widgets/ingress/connections/base.tf @@ -1,7 +1,7 @@ module "base" { source = "../../base" - name = "Connections (${var.ingress_type}) [${var.period}m]" + name = "Active Connections (${var.ingress_type}) [${var.period}m]" data_source = var.data_source coordinates = var.coordinates period = var.period @@ -15,7 +15,9 @@ module "base" { } metrics = [ - { label : "1m range", expression : "sum(rate(nginx_ingress_controller_nginx_process_connections[1m]))" }, - { label : "${var.period}m range", expression : "sum(rate(nginx_ingress_controller_nginx_process_connections[${var.period}m]))" }, + { label : "1m", color : "D400BF", expression : "sum(rate(nginx_ingress_controller_nginx_process_connections[1m]))" }, + { label : "5m", color : "007CEF", expression : "sum(rate(nginx_ingress_controller_nginx_process_connections[5m]))" }, + { label : "15m", color : "FFC300", expression : "sum(rate(nginx_ingress_controller_nginx_process_connections[15m]))" }, + { label : "${var.period}m range", color : "7AAFF9", expression : "sum(rate(nginx_ingress_controller_nginx_process_connections[${var.period}m]))" }, ] } diff --git a/modules/dashboard/modules/widgets/ingress/cpu/README.md b/modules/dashboard/modules/widgets/ingress/cpu/README.md new file mode 100644 index 0000000..ffae5e8 --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/cpu/README.md @@ -0,0 +1,42 @@ +# connections + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| 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\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "prometheus")
})
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [ingress\_type](#input\_ingress\_type) | n/a | `string` | `"nginx"` | no | +| [namespace](#input\_namespace) | n/a | `string` | `"default"` | no | +| [period](#input\_period) | stats | `number` | `3` | no | +| [pod](#input\_pod) | n/a | `string` | n/a | yes | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/ingress/cpu/base.tf b/modules/dashboard/modules/widgets/ingress/cpu/base.tf new file mode 100644 index 0000000..7c6ec30 --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/cpu/base.tf @@ -0,0 +1,28 @@ +module "base" { + source = "../../base" + + name = "CPU (${var.ingress_type}) [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + accountId = var.account_id + } + + options = { + legend = { + show_legend = false + } + } + + unit = "percent" + + metrics = [ + { label : "__auto", expression : "rate(container_cpu_usage_seconds_total{pod=~\"${var.pod}-[^-]+-[^-]+$\", namespace=\"${var.namespace}\"}[$__rate_interval]) * 100" }, + ] +} diff --git a/modules/dashboard/modules/widgets/ingress/cpu/output.tf b/modules/dashboard/modules/widgets/ingress/cpu/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/cpu/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/ingress/cpu/variables.tf b/modules/dashboard/modules/widgets/ingress/cpu/variables.tf new file mode 100644 index 0000000..5f439ca --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/cpu/variables.tf @@ -0,0 +1,59 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "prometheus") + }) + description = "The custom datasource for widget item" +} + +variable "ingress_type" { + type = string + default = "nginx" +} + +variable "pod" { + type = string +} + +variable "namespace" { + type = string + default = "default" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 3 +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/modules/widgets/ingress/response-time/README.md b/modules/dashboard/modules/widgets/ingress/latency/README.md similarity index 100% rename from modules/dashboard/modules/widgets/ingress/response-time/README.md rename to modules/dashboard/modules/widgets/ingress/latency/README.md diff --git a/modules/dashboard/modules/widgets/ingress/latency/base.tf b/modules/dashboard/modules/widgets/ingress/latency/base.tf new file mode 100644 index 0000000..6957ce7 --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/latency/base.tf @@ -0,0 +1,26 @@ +module "base" { + source = "../../base" + + name = "Latency (${var.ingress_type})${var.by_host ? " by host" : ""} [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + accountId = var.account_id + } + + metrics = var.by_host ? [ + { label : "Avg", color : "7AAFF9", expression : "avg(increase(nginx_ingress_controller_request_duration_seconds_sum[${var.period}m]))" }, + { label : "__auto", expression : "max by (path) (rate(nginx_ingress_controller_request_duration_seconds_sum[${var.period}m])) > 1" }, + ] : [ + { label = "Avg", color : "FFC300", expression = "avg(rate(nginx_ingress_controller_request_duration_seconds_sum[${var.period}m]))" }, + { label = "Max", color : "7AAFF9", expression = "max(rate(nginx_ingress_controller_request_duration_seconds_sum[${var.period}m]))" }, + { label = "Acceptable", color : "3ECE76", expression = "${var.acceptable}" }, + { label = "Problem", color : "FF0F3C", expression = "${var.problem}" }, + ] +} diff --git a/modules/dashboard/modules/widgets/ingress/latency/output.tf b/modules/dashboard/modules/widgets/ingress/latency/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/latency/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/ingress/response-time/variables.tf b/modules/dashboard/modules/widgets/ingress/latency/variables.tf similarity index 100% rename from modules/dashboard/modules/widgets/ingress/response-time/variables.tf rename to modules/dashboard/modules/widgets/ingress/latency/variables.tf diff --git a/modules/dashboard/modules/widgets/ingress/memory/README.md b/modules/dashboard/modules/widgets/ingress/memory/README.md new file mode 100644 index 0000000..ffae5e8 --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/memory/README.md @@ -0,0 +1,42 @@ +# connections + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| 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\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "prometheus")
})
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [ingress\_type](#input\_ingress\_type) | n/a | `string` | `"nginx"` | no | +| [namespace](#input\_namespace) | n/a | `string` | `"default"` | no | +| [period](#input\_period) | stats | `number` | `3` | no | +| [pod](#input\_pod) | n/a | `string` | n/a | yes | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/ingress/memory/base.tf b/modules/dashboard/modules/widgets/ingress/memory/base.tf new file mode 100644 index 0000000..df2477a --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/memory/base.tf @@ -0,0 +1,28 @@ +module "base" { + source = "../../base" + + name = "Memory (${var.ingress_type}) [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + accountId = var.account_id + } + + options = { + legend = { + show_legend = false + } + } + + unit = "bytes" + + metrics = [ + { label : "__auto", expression : "container_memory_working_set_bytes{pod=~\"${var.pod}-[^-]+-[^-]+$\", namespace=\"${var.namespace}\"}" }, + ] +} diff --git a/modules/dashboard/modules/widgets/ingress/memory/output.tf b/modules/dashboard/modules/widgets/ingress/memory/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/memory/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/ingress/memory/variables.tf b/modules/dashboard/modules/widgets/ingress/memory/variables.tf new file mode 100644 index 0000000..5f439ca --- /dev/null +++ b/modules/dashboard/modules/widgets/ingress/memory/variables.tf @@ -0,0 +1,59 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "prometheus") + }) + description = "The custom datasource for widget item" +} + +variable "ingress_type" { + type = string + default = "nginx" +} + +variable "pod" { + type = string +} + +variable "namespace" { + type = string + default = "default" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 3 +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/modules/widgets/ingress/request-count/README.md b/modules/dashboard/modules/widgets/ingress/request-count/README.md index 2dbe1a0..ee07d2d 100644 --- a/modules/dashboard/modules/widgets/ingress/request-count/README.md +++ b/modules/dashboard/modules/widgets/ingress/request-count/README.md @@ -27,6 +27,8 @@ No resources. | [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no | | [anomaly\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | | [by\_host](#input\_by\_host) | n/a | `bool` | `false` | no | +| [by\_path](#input\_by\_path) | n/a | `bool` | `false` | no | +| [by\_status\_path](#input\_by\_status\_path) | n/a | `bool` | `false` | no | | [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "prometheus")
})
object({| n/a | yes | | [data\_source](#input\_data\_source) | The custom datasource for widget item |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | | [ingress\_type](#input\_ingress\_type) | n/a | `string` | `"nginx"` | no | diff --git a/modules/dashboard/modules/widgets/ingress/request-count/base.tf b/modules/dashboard/modules/widgets/ingress/request-count/base.tf index c13db97..56a01cf 100644 --- a/modules/dashboard/modules/widgets/ingress/request-count/base.tf +++ b/modules/dashboard/modules/widgets/ingress/request-count/base.tf @@ -1,7 +1,7 @@ module "base" { source = "../../base" - name = "Request count ${var.only_5xx ? "5XX" : "All"} (${var.ingress_type})${var.by_host ? " by host" : ""} [${var.period}m]" + name = "${var.by_status_path ? "5XX Rate(5m) by (status, host, path) (> 0.01)" : var.only_5xx && !var.by_path ? "5XX Rate" : var.by_path ? "5XX Rate per Path (0.01)" : "All Requests Rate"} (${var.ingress_type})${var.by_host ? " by host" : ""} [${var.period}m]" data_source = var.data_source coordinates = var.coordinates period = var.period @@ -14,16 +14,22 @@ module "base" { accountId = var.account_id } - metrics = concat(var.only_5xx ? [] : [ - { label = var.by_host ? "{{host}}/Total" : "Total", expression = "sum(rate(nginx_ingress_controller_requests[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - { label = var.by_host ? "{{host}}/2xx" : "2xx", expression = "sum(rate(nginx_ingress_controller_requests{status=~\"2..\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - { label = var.by_host ? "{{host}}/3xx" : "3xx", expression = "sum(rate(nginx_ingress_controller_requests{status=~\"3..\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - { label = var.by_host ? "{{host}}/4xx" : "4xx", expression = "sum(rate(nginx_ingress_controller_requests{status=~\"4..\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - ], [ - { label = var.by_host ? "{{host}}/499" : "499", expression = "sum(rate(nginx_ingress_controller_requests{status=\"499\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - { label = var.by_host ? "{{host}}/5XX" : "5XX", expression = "sum(rate(nginx_ingress_controller_requests{status=~\"5..\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - { label = var.by_host ? "{{host}}/500" : "500", expression = "sum(rate(nginx_ingress_controller_requests{status=\"500\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - { label = var.by_host ? "{{host}}/502" : "502", expression = "sum(rate(nginx_ingress_controller_requests{status=\"502\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - { label = var.by_host ? "{{host}}/503" : "503", expression = "sum(rate(nginx_ingress_controller_requests{status=\"503\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, - ]) + options = { + legend = { + calcs = ["lastNotNull", "max", "mean"] + displayMode = "table" + placement = "right" + } + } + + metrics = var.only_5xx ? [ + { label : "5XX", color : "FF0F3C", expression : "sum(rate(nginx_ingress_controller_requests{status=~\"5..|499\"}[${var.period}m]))" }, + { label : var.by_path ? "{{path}}" : var.by_status_path ? "{{status}},{{path}}" : "__auto", color : "D400BF", expression : "sum(rate(nginx_ingress_controller_requests{status=~\"5..|499\"}[${var.period}m]))${var.by_path ? " by (path) > 0.01" : var.by_status_path ? "by (status, path, host) > 0.01" : " by (status)"}" } + ] : [ + { label = var.by_host ? "{{host}}/Total" : "Total", color : "D400BF", expression = "sum(rate(nginx_ingress_controller_requests[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, + { label = var.by_host ? "{{host}}/2xx" : "2xx", color : "3ECE76", expression = "sum(rate(nginx_ingress_controller_requests{status=~\"2..\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, + { label = var.by_host ? "{{host}}/3xx" : "3xx", color : "FFC300", expression = "sum(rate(nginx_ingress_controller_requests{status=~\"3..\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, + { label = var.by_host ? "{{host}}/4xx" : "4xx", color : "FF774D", expression = "sum(rate(nginx_ingress_controller_requests{status=~\"4..\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, + { label = var.by_host ? "{{host}}/5xx" : "5xx", color : "FF0F3C", display_mode : "table", expression = "sum(rate(nginx_ingress_controller_requests{status=~\"5..\"}[${var.period}m]))${var.by_host ? " by (host)" : ""}" }, + ] } diff --git a/modules/dashboard/modules/widgets/ingress/request-count/variables.tf b/modules/dashboard/modules/widgets/ingress/request-count/variables.tf index 54859da..9017b0d 100644 --- a/modules/dashboard/modules/widgets/ingress/request-count/variables.tf +++ b/modules/dashboard/modules/widgets/ingress/request-count/variables.tf @@ -47,6 +47,16 @@ variable "by_host" { default = false } +variable "by_path" { + type = bool + default = false +} + +variable "by_status_path" { + type = bool + default = false +} + variable "anomaly_detection" { type = bool default = false diff --git a/modules/dashboard/modules/widgets/ingress/request-rate/base.tf b/modules/dashboard/modules/widgets/ingress/request-rate/base.tf index fcd0bb7..2a2a6c8 100644 --- a/modules/dashboard/modules/widgets/ingress/request-rate/base.tf +++ b/modules/dashboard/modules/widgets/ingress/request-rate/base.tf @@ -15,9 +15,11 @@ module "base" { } metrics = var.by_host ? [ - { label : "__auto", expression : "sum(rate(nginx_ingress_controller_requests[${var.period}m])) by (host)" }, + { label : "__auto", color : "3ECE76", expression : "sum(rate(nginx_ingress_controller_requests[${var.period}m])) by (host)" }, ] : [ - { label : "1m range", expression : "sum(rate(nginx_ingress_controller_requests[1m]))" }, - { label : "${var.period}m range", expression : "sum(rate(nginx_ingress_controller_requests[${var.period}m]))" } + { label : "1m", color : "FFC300", expression : "sum(rate(nginx_ingress_controller_requests[1m]))" }, + { label : "5m", color : "FF774D", expression : "sum(rate(nginx_ingress_controller_requests[5m]))" }, + { label : "15m", color : "FF0F3C", expression : "sum(rate(nginx_ingress_controller_requests[15m]))" }, + { label : "${var.period}m range", color : "56F3D7", expression : "sum(rate(nginx_ingress_controller_requests[${var.period}m]))" } ] } diff --git a/modules/dashboard/modules/widgets/ingress/response-time/base.tf b/modules/dashboard/modules/widgets/ingress/response-time/base.tf deleted file mode 100644 index 13be2ce..0000000 --- a/modules/dashboard/modules/widgets/ingress/response-time/base.tf +++ /dev/null @@ -1,26 +0,0 @@ -module "base" { - source = "../../base" - - name = "Response time (${var.ingress_type})${var.by_host ? " by host" : ""} [${var.period}m]" - data_source = var.data_source - coordinates = var.coordinates - period = var.period - region = var.region - anomaly_detection = var.anomaly_detection - anomaly_deviation = var.anomaly_deviation - - defaults = { - MetricNamespace = "ContainerInsights" - accountId = var.account_id - } - - metrics = var.by_host ? [ - { label : "__auto", expression : "avg(increase(nginx_ingress_controller_request_duration_seconds_sum[${var.period}m])) by (host) * 100" }, - { label : "__auto", expression : "max(increase(nginx_ingress_controller_request_duration_seconds_sum[${var.period}m])) by (host)" }, - ] : [ - { label = "Avg", expression = "avg(rate(nginx_ingress_controller_request_duration_seconds_sum[${var.period}m])) / avg(rate(nginx_ingress_controller_request_duration_seconds_count[${var.period}m]))" }, - { label = "Max", expression = "max(rate(nginx_ingress_controller_request_duration_seconds_sum[${var.period}m])) / max(rate(nginx_ingress_controller_request_duration_seconds_count[${var.period}m]))" }, - { label = "Acceptable", expression = "${var.acceptable}" }, - { label = "Problem", expression = "${var.problem}" }, - ] -} diff --git a/modules/dashboard/modules/widgets/logs/count/README.md b/modules/dashboard/modules/widgets/logs/count/README.md new file mode 100644 index 0000000..a2d328d --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/count/README.md @@ -0,0 +1,41 @@ +# cpu + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [account\_id](#input\_account\_id) | n/a | `string` | `null` | no | +| [aggregated\_metric](#input\_aggregated\_metric) | n/a | `string` | n/a | yes | +| [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no | +| [anomaly\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [by\_pod](#input\_by\_pod) | n/a | `bool` | `false` | no | +| [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "prometheus")
})
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item logs |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [period](#input\_period) | stats | `number` | `60` | no | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/logs/count/base.tf b/modules/dashboard/modules/widgets/logs/count/base.tf new file mode 100644 index 0000000..879e87b --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/count/base.tf @@ -0,0 +1,21 @@ +module "base" { + source = "../../base" + + name = "Logs [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + } + + metrics = [ + { label = "error", expression = "count_over_time({__aggregated_metric__=\"${var.aggregated_metric}\",level=~\"error|fatal|exception\"}[$__range])" }, + { label = "error", expression = "count_over_time({__aggregated_metric__=\"${var.aggregated_metric}\",level=~\"error|fatal|exception\"}[$__range])" }, + { label = "error", expression = "count_over_time({__aggregated_metric__=\"${var.aggregated_metric}\",level=~\"error|fatal|exception\"}[$__range])" } + ] +} diff --git a/modules/dashboard/modules/widgets/logs/count/output.tf b/modules/dashboard/modules/widgets/logs/count/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/count/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/logs/count/variables.tf b/modules/dashboard/modules/widgets/logs/count/variables.tf new file mode 100644 index 0000000..84cf627 --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/count/variables.tf @@ -0,0 +1,54 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "loki") + }) + description = "The custom datasource for widget item logs" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +variable "aggregated_metric" { + type = string +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 60 +} + +variable "by_pod" { + type = bool + default = false +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/modules/widgets/logs/error-rate/README.md b/modules/dashboard/modules/widgets/logs/error-rate/README.md new file mode 100644 index 0000000..a2d328d --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/error-rate/README.md @@ -0,0 +1,41 @@ +# cpu + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [account\_id](#input\_account\_id) | n/a | `string` | `null` | no | +| [aggregated\_metric](#input\_aggregated\_metric) | n/a | `string` | n/a | yes | +| [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no | +| [anomaly\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [by\_pod](#input\_by\_pod) | n/a | `bool` | `false` | no | +| [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "loki")
})
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item logs |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [period](#input\_period) | stats | `number` | `60` | no | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/logs/error-rate/base.tf b/modules/dashboard/modules/widgets/logs/error-rate/base.tf new file mode 100644 index 0000000..2b72541 --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/error-rate/base.tf @@ -0,0 +1,19 @@ +module "base" { + source = "../../base" + + name = "Error Rate in Logs [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + } + + metrics = [ + { label = "errors", expression = "sum(count_over_time({__aggregated_metric__=\"${var.aggregated_metric}\", level=~\"error|fatal|exception\"} [$__range])) or vector(0)/(sum(count_over_time({__aggregated_metric__=\"${var.aggregated_metric}\"} [$__range])) or vector(1))" } + ] +} diff --git a/modules/dashboard/modules/widgets/logs/error-rate/output.tf b/modules/dashboard/modules/widgets/logs/error-rate/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/error-rate/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/logs/error-rate/variables.tf b/modules/dashboard/modules/widgets/logs/error-rate/variables.tf new file mode 100644 index 0000000..84cf627 --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/error-rate/variables.tf @@ -0,0 +1,54 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "loki") + }) + description = "The custom datasource for widget item logs" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +variable "aggregated_metric" { + type = string +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 60 +} + +variable "by_pod" { + type = bool + default = false +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/modules/widgets/logs/warning-rate/README.md b/modules/dashboard/modules/widgets/logs/warning-rate/README.md new file mode 100644 index 0000000..a2d328d --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/warning-rate/README.md @@ -0,0 +1,41 @@ +# cpu + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [account\_id](#input\_account\_id) | n/a | `string` | `null` | no | +| [aggregated\_metric](#input\_aggregated\_metric) | n/a | `string` | n/a | yes | +| [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no | +| [anomaly\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [by\_pod](#input\_by\_pod) | n/a | `bool` | `false` | no | +| [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "loki")
})
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item logs |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [period](#input\_period) | stats | `number` | `60` | no | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/logs/warning-rate/base.tf b/modules/dashboard/modules/widgets/logs/warning-rate/base.tf new file mode 100644 index 0000000..5fb21b4 --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/warning-rate/base.tf @@ -0,0 +1,19 @@ +module "base" { + source = "../../base" + + name = "Warning Rate in Logs [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + } + + metrics = [ + { label = "warnings", expression = "sum(count_over_time({__aggregated_metric__=\"${var.aggregated_metric}\", level=~\"warn\"} [$__range])) or vector(0)/(sum(count_over_time({__aggregated_metric__=\"${var.aggregated_metric}\"} [$__range])) or vector(1))" } + ] +} diff --git a/modules/dashboard/modules/widgets/logs/warning-rate/output.tf b/modules/dashboard/modules/widgets/logs/warning-rate/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/warning-rate/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/logs/warning-rate/variables.tf b/modules/dashboard/modules/widgets/logs/warning-rate/variables.tf new file mode 100644 index 0000000..84cf627 --- /dev/null +++ b/modules/dashboard/modules/widgets/logs/warning-rate/variables.tf @@ -0,0 +1,54 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "loki") + }) + description = "The custom datasource for widget item logs" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +variable "aggregated_metric" { + type = string +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 60 +} + +variable "by_pod" { + type = bool + default = false +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/modules/widgets/pod/cpu/README.md b/modules/dashboard/modules/widgets/pod/cpu/README.md new file mode 100644 index 0000000..eae7972 --- /dev/null +++ b/modules/dashboard/modules/widgets/pod/cpu/README.md @@ -0,0 +1,43 @@ +# cpu + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| 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\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [by\_pod](#input\_by\_pod) | n/a | `bool` | `false` | no | +| [cluster](#input\_cluster) | n/a | `string` | n/a | yes | +| [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "loki")
})
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [namespace](#input\_namespace) | n/a | `string` | `"default"` | no | +| [period](#input\_period) | stats | `number` | `60` | no | +| [pod](#input\_pod) | n/a | `string` | n/a | yes | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/pod/cpu/base.tf b/modules/dashboard/modules/widgets/pod/cpu/base.tf new file mode 100644 index 0000000..b86a6e3 --- /dev/null +++ b/modules/dashboard/modules/widgets/pod/cpu/base.tf @@ -0,0 +1,25 @@ +module "base" { + source = "../../base" + + name = "CPU [${var.period}m]" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + ClusterName = var.cluster + Namespace = var.namespace + PodName = var.pod + } + + metrics = [ + { label = "Max", expression = "max(rate(container_cpu_usage_seconds_total{pod=\"${var.pod}-[^-]+-[^-]+$\", namespace=\"${var.namespace}\"}[${var.period}m]))" }, + { label = "Avg", expression = "avg(rate(container_cpu_usage_seconds_total{pod=\"${var.pod}-[^-]+-[^-]+$\", namespace=\"${var.namespace}\"}[${var.period}m]))" }, + { label = "Request", expression = "max(kube_pod_container_resource_requests{pod=\"${var.pod}-[^-]+-[^-]+$\", namespace=\"${var.namespace}\", resource=\"cpu\"})" }, + { label = "Limit", expression = "max(kube_pod_container_resource_limits{pod=\"${var.pod}-[^-]+-[^-]+$\", namespace=\"${var.namespace}\", resource=\"cpu\"})" }, + ] +} diff --git a/modules/dashboard/modules/widgets/pod/cpu/output.tf b/modules/dashboard/modules/widgets/pod/cpu/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/pod/cpu/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/pod/cpu/variables.tf b/modules/dashboard/modules/widgets/pod/cpu/variables.tf new file mode 100644 index 0000000..6c6d927 --- /dev/null +++ b/modules/dashboard/modules/widgets/pod/cpu/variables.tf @@ -0,0 +1,63 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "prometheus") + }) + description = "The custom datasource for widget item" +} + +variable "pod" { + type = string +} + +variable "cluster" { + type = string +} + +variable "namespace" { + type = string + default = "default" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 60 +} + +variable "by_pod" { + type = bool + default = false +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/modules/widgets/pod/memory/README.md b/modules/dashboard/modules/widgets/pod/memory/README.md new file mode 100644 index 0000000..3240ce5 --- /dev/null +++ b/modules/dashboard/modules/widgets/pod/memory/README.md @@ -0,0 +1,42 @@ +# memory + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [base](#module\_base) | ../../base | n/a | + +## Resources + +No resources. + +## Inputs + +| 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\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no | +| [cluster](#input\_cluster) | n/a | `string` | n/a | yes | +| [coordinates](#input\_coordinates) | position |
uid = optional(string, null)
type = optional(string, "prometheus")
})
object({| n/a | yes | +| [data\_source](#input\_data\_source) | The custom datasource for widget item |
x : number
y : number
width : number
height : number
})
object({| n/a | yes | +| [namespace](#input\_namespace) | n/a | `string` | `"default"` | no | +| [period](#input\_period) | stats | `number` | `3` | no | +| [pod](#input\_pod) | n/a | `string` | n/a | yes | +| [region](#input\_region) | n/a | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [data](#output\_data) | n/a | + diff --git a/modules/dashboard/modules/widgets/pod/memory/base.tf b/modules/dashboard/modules/widgets/pod/memory/base.tf new file mode 100644 index 0000000..dee3450 --- /dev/null +++ b/modules/dashboard/modules/widgets/pod/memory/base.tf @@ -0,0 +1,26 @@ +module "base" { + source = "../../base" + + name = "Memory" + data_source = var.data_source + coordinates = var.coordinates + period = var.period + region = var.region + anomaly_detection = var.anomaly_detection + anomaly_deviation = var.anomaly_deviation + + defaults = { + MetricNamespace = "ContainerInsights" + ClusterName = var.cluster + Namespace = var.namespace + PodName = var.pod + accountId = var.account_id + } + + metrics = [ + { label = "AVG", expression = "avg(container_memory_usage_bytes{container=\"${var.container}\", namespace=\"${var.namespace}\"}) by (container) / 1024 / 1024" }, + { label = "Request", expression = "avg(kube_pod_container_resource_requests{container=\"${var.container}\", namespace=\"${var.namespace}\", resource=\"memory\"}) / 1024 / 1024" }, + { label = "Limit", expression = "avg(kube_pod_container_resource_limits{container=\"${var.container}\", namespace=\"${var.namespace}\", resource=\"memory\"}) / 1024 / 1024" }, + { label = "MAX", expression = "max(container_memory_usage_bytes{container=\"${var.container}\", namespace=\"${var.namespace}\"}) by (container) / 1024 / 1024" }, + ] +} diff --git a/modules/dashboard/modules/widgets/pod/memory/output.tf b/modules/dashboard/modules/widgets/pod/memory/output.tf new file mode 100644 index 0000000..37309dc --- /dev/null +++ b/modules/dashboard/modules/widgets/pod/memory/output.tf @@ -0,0 +1,3 @@ +output "data" { + value = module.base.data +} diff --git a/modules/dashboard/modules/widgets/pod/memory/variables.tf b/modules/dashboard/modules/widgets/pod/memory/variables.tf new file mode 100644 index 0000000..760924f --- /dev/null +++ b/modules/dashboard/modules/widgets/pod/memory/variables.tf @@ -0,0 +1,58 @@ +variable "data_source" { + type = object({ + uid = optional(string, null) + type = optional(string, "prometheus") + }) + description = "The custom datasource for widget item" +} + +variable "pod" { + type = string +} + +variable "cluster" { + type = string +} + +variable "namespace" { + type = string + default = "default" +} + +variable "account_id" { + type = string + default = null +} + +variable "region" { + type = string + default = "" +} + +# position +variable "coordinates" { + type = object({ + x : number + y : number + width : number + height : number + }) +} + +# stats +variable "period" { + type = number + default = 3 +} + +variable "anomaly_detection" { + type = bool + default = false + description = "Allow to enable anomaly detection on widget metrics" +} + +variable "anomaly_deviation" { + type = number + default = 6 + description = "Deviation of the anomaly band" +} diff --git a/modules/dashboard/widgets-container.tf b/modules/dashboard/widgets-container.tf index d83c7cc..467b9f9 100644 --- a/modules/dashboard/widgets-container.tf +++ b/modules/dashboard/widgets-container.tf @@ -142,3 +142,37 @@ module "container_response_time_widget" { anomaly_detection = each.value.anomaly_detection anomaly_deviation = each.value.anomaly_deviation } + +module "container_network_traffic_widget" { + source = "./modules/widgets/container/network-traffic" + + for_each = { for index, item in try(local.widget_config["container/network-traffic"], []) : index => item } + + data_source = each.value.data_source + coordinates = each.value.coordinates + period = each.value.period + + pod = each.value.pod + + account_id = each.value.account_id + region = each.value.region + anomaly_detection = each.value.anomaly_detection + anomaly_deviation = each.value.anomaly_deviation +} + +module "container_network_transmit_widget" { + source = "./modules/widgets/container/network-transmit" + + for_each = { for index, item in try(local.widget_config["container/network-transmit"], []) : index => item } + + data_source = each.value.data_source + coordinates = each.value.coordinates + period = each.value.period + + pod = each.value.pod + + account_id = each.value.account_id + region = each.value.region + anomaly_detection = each.value.anomaly_detection + anomaly_deviation = each.value.anomaly_deviation +} diff --git a/modules/dashboard/widgets-ingress.tf b/modules/dashboard/widgets-ingress.tf index 1b50970..89737e5 100644 --- a/modules/dashboard/widgets-ingress.tf +++ b/modules/dashboard/widgets-ingress.tf @@ -36,11 +36,49 @@ module "ingress_request_count_widget" { for_each = { for index, item in try(local.widget_config["ingress/request-count"], []) : index => item } + data_source = each.value.data_source + coordinates = each.value.coordinates + period = each.value.period + by_host = try(each.value.by_host, false) + by_path = try(each.value.by_path, false) + by_status_path = try(each.value.by_status_path, false) + only_5xx = try(each.value.only_5xx, false) + + account_id = each.value.account_id + region = each.value.region + anomaly_detection = each.value.anomaly_detection + anomaly_deviation = each.value.anomaly_deviation +} + +module "ingress_cpu_widget" { + source = "./modules/widgets/ingress/cpu" + + for_each = { for index, item in try(local.widget_config["ingress/cpu"], []) : index => item } + data_source = each.value.data_source coordinates = each.value.coordinates period = each.value.period - by_host = try(each.value.by_host, false) - only_5xx = try(each.value.only_5xx, false) + + pod = each.value.pod + namespace = each.value.namespace + + account_id = each.value.account_id + region = each.value.region + anomaly_detection = each.value.anomaly_detection + anomaly_deviation = each.value.anomaly_deviation +} + +module "ingress_memory_widget" { + source = "./modules/widgets/ingress/memory" + + for_each = { for index, item in try(local.widget_config["ingress/memory"], []) : index => item } + + data_source = each.value.data_source + coordinates = each.value.coordinates + period = each.value.period + + pod = each.value.pod + namespace = each.value.namespace account_id = each.value.account_id region = each.value.region @@ -48,10 +86,10 @@ module "ingress_request_count_widget" { anomaly_deviation = each.value.anomaly_deviation } -module "ingress_response_time_widget" { - source = "./modules/widgets/ingress/response-time" +module "ingress_latency_widget" { + source = "./modules/widgets/ingress/latency" - for_each = { for index, item in try(local.widget_config["ingress/response-time"], []) : index => item } + for_each = { for index, item in try(local.widget_config["ingress/latency"], []) : index => item } data_source = each.value.data_source coordinates = each.value.coordinates diff --git a/modules/dashboard/widgets-logs.tf b/modules/dashboard/widgets-logs.tf new file mode 100644 index 0000000..22572d9 --- /dev/null +++ b/modules/dashboard/widgets-logs.tf @@ -0,0 +1,51 @@ +# Logs widgets +module "logs_count_widget" { + source = "./modules/widgets/logs/count" + + for_each = { for index, item in try(local.widget_config["logs/count"], []) : index => item } + + data_source = each.value.data_source + coordinates = each.value.coordinates + period = each.value.period + + aggregated_metric = each.value.aggregated_metric + + account_id = each.value.account_id + region = each.value.region + anomaly_detection = each.value.anomaly_detection + anomaly_deviation = each.value.anomaly_deviation +} + +module "logs_error_rate_widget" { + source = "./modules/widgets/logs/error-rate" + + for_each = { for index, item in try(local.widget_config["logs/error-rate"], []) : index => item } + + data_source = each.value.data_source + coordinates = each.value.coordinates + period = each.value.period + + aggregated_metric = each.value.aggregated_metric + + account_id = each.value.account_id + region = each.value.region + anomaly_detection = each.value.anomaly_detection + anomaly_deviation = each.value.anomaly_deviation +} + +module "logs_warning_rate_widget" { + source = "./modules/widgets/logs/warning-rate" + + for_each = { for index, item in try(local.widget_config["logs/warning-rate"], []) : index => item } + + data_source = each.value.data_source + coordinates = each.value.coordinates + period = each.value.period + + aggregated_metric = each.value.aggregated_metric + + account_id = each.value.account_id + region = each.value.region + anomaly_detection = each.value.anomaly_detection + anomaly_deviation = each.value.anomaly_deviation +} diff --git a/modules/dashboard/widgets-pod.tf b/modules/dashboard/widgets-pod.tf new file mode 100644 index 0000000..94b8960 --- /dev/null +++ b/modules/dashboard/widgets-pod.tf @@ -0,0 +1,21 @@ +# Pod widgets +module "pod_cpu_widget" { + source = "./modules/widgets/pod/cpu" + + for_each = { for index, item in try(local.widget_config["pod/cpu"], []) : index => item } + + data_source = each.value.data_source + coordinates = each.value.coordinates + period = each.value.period + + # pod + pod = each.value.pod + cluster = try(each.value.cluster, null) + namespace = each.value.namespace + by_pod = try(each.value.by_pod, false) + + account_id = each.value.account_id + region = each.value.region + anomaly_detection = each.value.anomaly_detection + anomaly_deviation = each.value.anomaly_deviation +}
uid = optional(string, null)
type = optional(string, "prometheus")
})