Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DMVP-6116): Implemented redis block #24

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions modules/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module "this" {
| Name | Source | Version |
|------|--------|---------|
| <a name="module_block_ingress"></a> [block\_ingress](#module\_block\_ingress) | ./modules/blocks/ingress | n/a |
| <a name="module_block_redis"></a> [block\_redis](#module\_block\_redis) | ./modules/blocks/redis | n/a |
| <a name="module_block_service"></a> [block\_service](#module\_block\_service) | ./modules/blocks/service | n/a |
| <a name="module_block_sla"></a> [block\_sla](#module\_block\_sla) | ./modules/blocks/sla | n/a |
| <a name="module_container_cpu_widget"></a> [container\_cpu\_widget](#module\_container\_cpu\_widget) | ./modules/widgets/container/cpu | n/a |
Expand All @@ -84,6 +85,7 @@ module "this" {
| <a name="module_container_request_count_widget"></a> [container\_request\_count\_widget](#module\_container\_request\_count\_widget) | ./modules/widgets/container/request-count | n/a |
| <a name="module_container_response_time_widget"></a> [container\_response\_time\_widget](#module\_container\_response\_time\_widget) | ./modules/widgets/container/response-time | n/a |
| <a name="module_container_restarts_widget"></a> [container\_restarts\_widget](#module\_container\_restarts\_widget) | ./modules/widgets/container/restarts | n/a |
| <a name="module_deployment_replicas_widget"></a> [deployment\_replicas\_widget](#module\_deployment\_replicas\_widget) | ./modules/widgets/deployment/replicas | n/a |
| <a name="module_ingress_connections_widget"></a> [ingress\_connections\_widget](#module\_ingress\_connections\_widget) | ./modules/widgets/ingress/connections | n/a |
| <a name="module_ingress_cpu_widget"></a> [ingress\_cpu\_widget](#module\_ingress\_cpu\_widget) | ./modules/widgets/ingress/cpu | n/a |
| <a name="module_ingress_latency_widget"></a> [ingress\_latency\_widget](#module\_ingress\_latency\_widget) | ./modules/widgets/ingress/latency | n/a |
Expand All @@ -94,6 +96,24 @@ module "this" {
| <a name="module_logs_error_rate_widget"></a> [logs\_error\_rate\_widget](#module\_logs\_error\_rate\_widget) | ./modules/widgets/logs/error-rate | n/a |
| <a name="module_logs_warning_rate_widget"></a> [logs\_warning\_rate\_widget](#module\_logs\_warning\_rate\_widget) | ./modules/widgets/logs/warning-rate | n/a |
| <a name="module_pod_cpu_widget"></a> [pod\_cpu\_widget](#module\_pod\_cpu\_widget) | ./modules/widgets/pod/cpu | n/a |
| <a name="module_pod_memory_widget"></a> [pod\_memory\_widget](#module\_pod\_memory\_widget) | ./modules/widgets/pod/memory | n/a |
| <a name="module_pod_restarts_widget"></a> [pod\_restarts\_widget](#module\_pod\_restarts\_widget) | ./modules/widgets/pod/restarts | n/a |
| <a name="module_redis_clients_widget"></a> [redis\_clients\_widget](#module\_redis\_clients\_widget) | ./modules/widgets/redis/clients | n/a |
| <a name="module_redis_connections_widget"></a> [redis\_connections\_widget](#module\_redis\_connections\_widget) | ./modules/widgets/redis/connections | n/a |
| <a name="module_redis_cpu_widget"></a> [redis\_cpu\_widget](#module\_redis\_cpu\_widget) | ./modules/widgets/redis/cpu | n/a |
| <a name="module_redis_errors_widget"></a> [redis\_errors\_widget](#module\_redis\_errors\_widget) | ./modules/widgets/redis/errors | n/a |
| <a name="module_redis_expired_evicted_keys_widget"></a> [redis\_expired\_evicted\_keys\_widget](#module\_redis\_expired\_evicted\_keys\_widget) | ./modules/widgets/redis/expired-evicted-keys | n/a |
| <a name="module_redis_expiring_notexpiring_keys_widget"></a> [redis\_expiring\_notexpiring\_keys\_widget](#module\_redis\_expiring\_notexpiring\_keys\_widget) | ./modules/widgets/redis/expiring-notexpiring-keys | n/a |
| <a name="module_redis_hits_misses_widget"></a> [redis\_hits\_misses\_widget](#module\_redis\_hits\_misses\_widget) | ./modules/widgets/redis/hits-misses | n/a |
| <a name="module_redis_keys_widget"></a> [redis\_keys\_widget](#module\_redis\_keys\_widget) | ./modules/widgets/redis/keys | n/a |
| <a name="module_redis_latency_widget"></a> [redis\_latency\_widget](#module\_redis\_latency\_widget) | ./modules/widgets/redis/latency | n/a |
| <a name="module_redis_max_uptime_widget"></a> [redis\_max\_uptime\_widget](#module\_redis\_max\_uptime\_widget) | ./modules/widgets/redis/max-uptime | n/a |
| <a name="module_redis_memory_widget"></a> [redis\_memory\_widget](#module\_redis\_memory\_widget) | ./modules/widgets/redis/memory | n/a |
| <a name="module_redis_network_widget"></a> [redis\_network\_widget](#module\_redis\_network\_widget) | ./modules/widgets/redis/network | n/a |
| <a name="module_redis_replicas_widget"></a> [redis\_replicas\_widget](#module\_redis\_replicas\_widget) | ./modules/widgets/redis/replicas | n/a |
| <a name="module_redis_restarts_widget"></a> [redis\_restarts\_widget](#module\_redis\_restarts\_widget) | ./modules/widgets/redis/restarts | n/a |
| <a name="module_redis_total_commands_widget"></a> [redis\_total\_commands\_widget](#module\_redis\_total\_commands\_widget) | ./modules/widgets/redis/total-commands | n/a |
| <a name="module_redis_total_memory_widget"></a> [redis\_total\_memory\_widget](#module\_redis\_total\_memory\_widget) | ./modules/widgets/redis/total-memory | n/a |
| <a name="module_text_title"></a> [text\_title](#module\_text\_title) | ./modules/widgets/text/title | n/a |
| <a name="module_text_title_with_collapse"></a> [text\_title\_with\_collapse](#module\_text\_title\_with\_collapse) | ./modules/widgets/text/title-with-collapse | n/a |
| <a name="module_text_title_with_link"></a> [text\_title\_with\_link](#module\_text\_title\_with\_link) | ./modules/widgets/text/title-with-link | n/a |
Expand Down
19 changes: 19 additions & 0 deletions modules/dashboard/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ locals {
ingress = values(module.block_ingress).*.result
service = values(module.block_service).*.result
sla = values(module.block_sla).*.result
redis = values(module.block_redis).*.result
}

blocks_by_type_results = concat([], [
Expand Down Expand Up @@ -148,5 +149,23 @@ locals {
values(module.logs_count_widget).*.data,
values(module.logs_error_rate_widget).*.data,
values(module.logs_warning_rate_widget).*.data,

# Redis widgets
values(module.redis_max_uptime_widget).*.data,
values(module.redis_memory_widget).*.data,
values(module.redis_total_memory_widget).*.data,
values(module.redis_cpu_widget).*.data,
values(module.redis_hits_misses_widget).*.data,
values(module.redis_restarts_widget).*.data,
values(module.redis_errors_widget).*.data,
values(module.redis_clients_widget).*.data,
values(module.redis_connections_widget).*.data,
values(module.redis_latency_widget).*.data,
values(module.redis_network_widget).*.data,
values(module.redis_replicas_widget).*.data,
values(module.redis_total_commands_widget).*.data,
values(module.redis_keys_widget).*.data,
values(module.redis_expired_evicted_keys_widget).*.data,
values(module.redis_expiring_notexpiring_keys_widget).*.data,
)
}
34 changes: 34 additions & 0 deletions modules/dashboard/modules/blocks/redis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ingress

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

No requirements.

## Providers

No providers.

## Modules

No modules.

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_namespace"></a> [namespace](#input\_namespace) | k8s namespace name | `string` | n/a | yes |
| <a name="input_redis_name"></a> [redis\_name](#input\_redis\_name) | Redis name | `string` | `"redis"` | no |
| <a name="input_redis_namespace"></a> [redis\_namespace](#input\_redis\_namespace) | k8s redis namespace name | `string` | n/a | yes |
| <a name="input_redis_pod"></a> [redis\_pod](#input\_redis\_pod) | Redis pod name, which may be the same with redis\_name | `string` | `"redis"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_result"></a> [result](#output\_result) | description |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
36 changes: 36 additions & 0 deletions modules/dashboard/modules/blocks/redis/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
output "result" {
description = "description"
value = [
[
{ type : "text/title-with-collapse", text : var.redis_name }
],
[
{ type : "redis/max-uptime", redis_name = var.redis_name, namespace = var.namespace, width : 4 }, //width : 2
{ type : "redis/memory", redis_name = var.redis_name, namespace = var.namespace, width : 4 }, //width : 2
{ type : "redis/total-memory", redis_name : var.redis_name, namespace = var.namespace, width : 4 }, //width : 4
{ type : "redis/cpu", redis_name : var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/replicas", redis_name = var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/restarts", redis_pod : var.redis_pod, redis_namespace : var.redis_namespace, width : 4 },
],
[
{ type : "redis/errors", redis_name : var.redis_name, namespace : var.namespace, width : 4 },
{ type : "redis/clients", redis_name = var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/connections", redis_name = var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/latency", redis_name = var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/network", redis_name = var.redis_name, namespace = var.namespace, width : 4 },
{ type : "container/network-transmit", pod : var.redis_pod, width : 4 },
],
[
{ type : "redis/total-commands", redis_name = var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/keys", redis_name : var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/expired-evicted-keys", redis_name : var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/expiring-notexpiring-keys", redis_name : var.redis_name, namespace = var.namespace, width : 4 },
{ type : "redis/hits-misses", redis_name : var.redis_name, namespace = var.namespace, width : 4 },
],
# [
# { type : "logs/count", aggregated_metric : "redis", width : 4},
# { type : "logs/error-rate", aggregated_metric : "redis", width : 4},
# { type : "logs/warning-rate", aggregated_metric : "redis", width : 4},
# ]
]
}
21 changes: 21 additions & 0 deletions modules/dashboard/modules/blocks/redis/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
variable "namespace" {
type = string
description = "k8s namespace name"
}

variable "redis_namespace" {
type = string
description = "k8s redis namespace name"
}

variable "redis_name" {
type = string
description = "Redis name"
default = "redis"
}

variable "redis_pod" {
type = string
description = "Redis pod name, which may be the same with redis_name"
default = "redis"
}
6 changes: 3 additions & 3 deletions modules/dashboard/modules/blocks/service/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ output "result" {
{ type : "container/network-transmit", host : var.host, pod : var.name, cluster : var.cluster, namespace : var.namespace, width : var.host != null ? 6 : 24, anomaly_detection : true, width : 6 },
],
var.host != null ? [
{ type : "container/request-count", host : var.host, container : var.name, cluster : var.cluster, namespace : var.namespace, width: 4 },
{ type : "container/request-count", host : var.host, container : var.name, cluster : var.cluster, namespace : var.namespace, only_5xx : true, width: 4 },
{ type : "container/response-time", host : var.host, container : var.name, cluster : var.cluster, namespace : var.namespace, width: 4 },
{ type : "container/request-count", host : var.host, container : var.name, cluster : var.cluster, namespace : var.namespace, width : 4 },
{ type : "container/request-count", host : var.host, container : var.name, cluster : var.cluster, namespace : var.namespace, only_5xx : true, width : 4 },
{ type : "container/response-time", host : var.host, container : var.name, cluster : var.cluster, namespace : var.namespace, width : 4 },
] : [],
),
]
Expand Down
2 changes: 2 additions & 0 deletions modules/dashboard/modules/widgets/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ No resources.
| <a name="input_annotations"></a> [annotations](#input\_annotations) | The annotations option for alarm widgets | `any` | `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_deviation"></a> [anomaly\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no |
| <a name="input_color_mode"></a> [color\_mode](#input\_color\_mode) | Color mode used for a widget | `string` | `"palette-classic"` | no |
| <a name="input_coordinates"></a> [coordinates](#input\_coordinates) | n/a | <pre>object({<br> x : number<br> y : number<br> width : number<br> height : number<br> })</pre> | n/a | yes |
| <a name="input_data_source"></a> [data\_source](#input\_data\_source) | The custom datasource for widget item | <pre>object({<br> uid = optional(string, null)<br> type = optional(string, "prometheus")<br> })</pre> | n/a | yes |
| <a name="input_decimals"></a> [decimals](#input\_decimals) | The decimals to enable on numbers | `number` | `0` | no |
Expand All @@ -49,6 +50,7 @@ No resources.
| <a name="input_stacked"></a> [stacked](#input\_stacked) | The stacked option for log insights and alarm widgets | `bool` | `null` | no |
| <a name="input_start"></a> [start](#input\_start) | start of widget | `string` | `null` | no |
| <a name="input_stat"></a> [stat](#input\_stat) | n/a | `string` | `"Average"` | no |
| <a name="input_thresholds"></a> [thresholds](#input\_thresholds) | Thresholds defined for a widget | <pre>object({<br> mode = string<br> steps = list(object({<br> color = string<br> value = number<br> }))<br> })</pre> | <pre>{<br> "mode": "absolute",<br> "steps": [<br> {<br> "color": "green",<br> "value": null<br> },<br> {<br> "color": "red",<br> "value": 80<br> }<br> ]<br>}</pre> | no |
| <a name="input_trend"></a> [trend](#input\_trend) | trend of widget | `bool` | `null` | no |
| <a name="input_type"></a> [type](#input\_type) | The type of widget to be prepared | `string` | `"metric"` | no |
| <a name="input_unit"></a> [unit](#input\_unit) | Unit used for widget metric | `string` | `""` | no |
Expand Down
2 changes: 2 additions & 0 deletions modules/dashboard/modules/widgets/base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module "base_grafana" {
query = var.query
sources = var.sources
view = var.view
thresholds = var.thresholds
color_mode = var.color_mode
stacked = var.stacked
annotations = var.annotations
alarms = var.alarms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ No resources.
| <a name="input_annotations"></a> [annotations](#input\_annotations) | The annotations option for alarm widgets | `any` | `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_deviation"></a> [anomaly\_deviation](#input\_anomaly\_deviation) | Height of anomaly band | `number` | `4` | no |
| <a name="input_color_mode"></a> [color\_mode](#input\_color\_mode) | Color mode used for a widget | `string` | `"palette-classic"` | no |
| <a name="input_coordinates"></a> [coordinates](#input\_coordinates) | n/a | <pre>object({<br> x : number<br> y : number<br> width : number<br> height : number<br> })</pre> | n/a | yes |
| <a name="input_data_source"></a> [data\_source](#input\_data\_source) | The custom datasource for widget item | <pre>object({<br> uid = optional(string, null)<br> type = optional(string, "prometheus")<br> })</pre> | n/a | yes |
| <a name="input_decimals"></a> [decimals](#input\_decimals) | The decimals to enable on numbers | `number` | `0` | no |
Expand All @@ -40,6 +41,7 @@ No resources.
| <a name="input_sources"></a> [sources](#input\_sources) | Log groups list for Logs Insights query | `list(string)` | `[]` | no |
| <a name="input_stacked"></a> [stacked](#input\_stacked) | The stacked option for log insights and alarm widgets | `bool` | `null` | no |
| <a name="input_stat"></a> [stat](#input\_stat) | n/a | `string` | `"Average"` | no |
| <a name="input_thresholds"></a> [thresholds](#input\_thresholds) | Thresholds defined for a widget | <pre>object({<br> mode = string<br> steps = list(object({<br> color = string<br> value = number<br> }))<br> })</pre> | <pre>{<br> "mode": "absolute",<br> "steps": [<br> {<br> "color": "green",<br> "value": null<br> },<br> {<br> "color": "red",<br> "value": 80<br> }<br> ]<br>}</pre> | no |
| <a name="input_type"></a> [type](#input\_type) | The type of widget to be prepared | `string` | `"metric"` | no |
| <a name="input_unit"></a> [unit](#input\_unit) | Unit used for widget metric | `string` | `""` | no |
| <a name="input_view"></a> [view](#input\_view) | The view for log insights and alarm widgets | `string` | `null` | no |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,33 @@ variable "description" {
description = "Description for the widget"
default = ""
}

variable "thresholds" {
type = object({
mode = string
steps = list(object({
color = string
value = number
}))
})
description = "Thresholds defined for a widget"
default = {
mode = "absolute"
steps = [
{
color = "green"
value = null
},
{
color = "red"
value = 80
},
]
}
}

variable "color_mode" {
type = string
description = "Color mode used for a widget"
default = "palette-classic"
}
19 changes: 7 additions & 12 deletions modules/dashboard/modules/widgets/base/platforms/grafana/widget.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
field_config_defaults = {
"color" : {
"mode" : "palette-classic"
"mode" : try(var.color_mode, "palette-classic")
},
decimals : var.decimals,
"custom" : {
Expand Down Expand Up @@ -33,19 +33,13 @@ locals {
}
},
mappings = []
thresholds = {
mode = "absolute"
thresholds = try(var.thresholds, {
mode = "absolute",
steps = [
{
color = "green"
value = null
},
{
color = "red"
value = 80
},
{ color = "green", value = null },
{ color = "red", value = 80 }
]
}
})
unit = var.unit
}

Expand Down Expand Up @@ -82,6 +76,7 @@ locals {
timeSeries = "timeseries"
gauge = "gauge"
histogram = "histogram"
stat = "stat"
}

# create query and metric based targets
Expand Down
30 changes: 30 additions & 0 deletions modules/dashboard/modules/widgets/base/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,33 @@ variable "description" {
description = "Description for the widget"
default = ""
}

variable "thresholds" {
type = object({
mode = string
steps = list(object({
color = string
value = number
}))
})
description = "Thresholds defined for a widget"
default = {
mode = "absolute"
steps = [
{
color = "green"
value = null
},
{
color = "red"
value = 80
},
]
}
}

variable "color_mode" {
type = string
description = "Color mode used for a widget"
default = "palette-classic"
}
Loading
Loading