Skip to content

Commit

Permalink
feat(DMVP-4004): Added redis metrics to dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
viktoryathegreat committed May 14, 2024
1 parent a12d91e commit 2ddafa3
Show file tree
Hide file tree
Showing 49 changed files with 1,549 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ module "this" {
| <a name="module_block_cdn"></a> [block\_cdn](#module\_block\_cdn) | ./modules/blocks/cdn | n/a |
| <a name="module_block_dns"></a> [block\_dns](#module\_block\_dns) | ./modules/blocks/dns | n/a |
| <a name="module_block_rds"></a> [block\_rds](#module\_block\_rds) | ./modules/blocks/rds | 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_all_requests"></a> [container\_all\_requests](#module\_container\_all\_requests) | ./modules/widgets/container/all-requests | n/a |
Expand Down Expand Up @@ -179,6 +180,14 @@ module "this" {
| <a name="module_widget_rds_network"></a> [widget\_rds\_network](#module\_widget\_rds\_network) | ./modules/widgets/rds/network | n/a |
| <a name="module_widget_rds_performance"></a> [widget\_rds\_performance](#module\_widget\_rds\_performance) | ./modules/widgets/rds/performance | n/a |
| <a name="module_widget_rds_swap"></a> [widget\_rds\_swap](#module\_widget\_rds\_swap) | ./modules/widgets/rds/swap | n/a |
| <a name="module_widget_redis_cache_hit"></a> [widget\_redis\_cache\_hit](#module\_widget\_redis\_cache\_hit) | ./modules/widgets/redis/cache-hit | n/a |
| <a name="module_widget_redis_capacity"></a> [widget\_redis\_capacity](#module\_widget\_redis\_capacity) | ./modules/widgets/redis/capacity | n/a |
| <a name="module_widget_redis_cpu"></a> [widget\_redis\_cpu](#module\_widget\_redis\_cpu) | ./modules/widgets/redis/cpu | n/a |
| <a name="module_widget_redis_current_connections"></a> [widget\_redis\_current\_connections](#module\_widget\_redis\_current\_connections) | ./modules/widgets/redis/current-connections | n/a |
| <a name="module_widget_redis_latency"></a> [widget\_redis\_latency](#module\_widget\_redis\_latency) | ./modules/widgets/redis/latency | n/a |
| <a name="module_widget_redis_memory"></a> [widget\_redis\_memory](#module\_widget\_redis\_memory) | ./modules/widgets/redis/memory | n/a |
| <a name="module_widget_redis_network"></a> [widget\_redis\_network](#module\_widget\_redis\_network) | ./modules/widgets/redis/network | n/a |
| <a name="module_widget_redis_new_connections"></a> [widget\_redis\_new\_connections](#module\_widget\_redis\_new\_connections) | ./modules/widgets/redis/new-connections | n/a |
| <a name="module_widget_sla_slo_sli"></a> [widget\_sla\_slo\_sli](#module\_widget\_sla\_slo\_sli) | ./modules/widgets/sla-slo-sli | n/a |

## Resources
Expand Down
11 changes: 11 additions & 0 deletions modules/dashboard/blocks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ locals {
# bring all module results together
blocks_results = {
rds = module.block_rds.*.result
redis = module.block_redis.*.result
dns = module.block_dns.*.result
cdn = module.block_cdn.*.result
alb = module.block_alb.*.result
Expand All @@ -35,6 +36,7 @@ locals {
# annotate each block type with subIndex
blocks_by_type = {
rds = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "rds")],
redis = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "redis")],
dns = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "dns")],
cdn = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "cdn")],
alb = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "alb")]
Expand All @@ -54,6 +56,15 @@ module "block_rds" {
region = var.region != "" ? var.region : data.aws_region.current.name
}

module "block_redis" {
source = "./modules/blocks/redis"

count = length(local.blocks_by_type.redis)

name = local.blocks_by_type.redis[count.index].block.name
region = var.region != "" ? var.region : data.aws_region.current.name
}

module "block_dns" {
source = "./modules/blocks/dns"

Expand Down
27 changes: 27 additions & 0 deletions modules/dashboard/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ locals {
"rds/free-storage" = []
"rds/swap" = []
"rds/disk-latency" = []
"redis/cache-hit" = []
"redis/capacity" = []
"redis/cpu" = []
"redis/current-connections" = []
"redis/latency" = []
"redis/memory" = []
"redis/network" = []
"redis/new-connections" = []
"cloudfront/errors" = []
"cloudfront/error-rate" = []
"cloudfront/traffic-bytes" = []
Expand Down Expand Up @@ -165,6 +173,15 @@ locals {
rds_swap = local.widget_config["rds/swap"]
rds_disk_latency = local.widget_config["rds/disk-latency"]

redis_cache_hit = local.widget_config["redis/cache-hit"]
redis_capacity = local.widget_config["redis/capacity"]
redis_cpu = local.widget_config["redis/cpu"]
redis_current_connections = local.widget_config["redis/current-connections"]
redis_latency = local.widget_config["redis/latency"]
redis_memory = local.widget_config["redis/memory"]
redis_network = local.widget_config["redis/network"]
redis_new_connections = local.widget_config["redis/new-connections"]

cloudfront_errors = local.widget_config["cloudfront/errors"]
cloudfront_error_rate = local.widget_config["cloudfront/error-rate"]
cloudfront_traffic_bytes = local.widget_config["cloudfront/traffic-bytes"]
Expand Down Expand Up @@ -239,6 +256,16 @@ locals {
module.widget_rds_swap[*].data,
module.widget_rds_disk_latency[*].data,

# Redis
module.widget_redis_cache_hit[*].data,
module.widget_redis_capacity[*].data,
module.widget_redis_cpu[*].data,
module.widget_redis_current_connections[*].data,
module.widget_redis_latency[*].data,
module.widget_redis_memory[*].data,
module.widget_redis_network[*].data,
module.widget_redis_new_connections[*].data,

# CDN
module.widget_cloudfront_errors[*].data,
module.widget_cloudfront_error_rate[*].data,
Expand Down
33 changes: 33 additions & 0 deletions modules/dashboard/modules/blocks/redis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# rds

<!-- 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_db_max_connections_count"></a> [db\_max\_connections\_count](#input\_db\_max\_connections\_count) | RDS maximum connection count | `string` | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | RDS name | `string` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | n/a | `string` | `""` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_result"></a> [result](#output\_result) | description |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20 changes: 20 additions & 0 deletions modules/dashboard/modules/blocks/redis/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
output "result" {
description = "description"
value = [
[
{ type : "text/title-with-link", text : "Redis (${var.name})", link_to_jump = "https://${var.region}.console.aws.amazon.com/elasticache/home?region=${var.region}#/redis/${var.name}" }
],
[
{ type : "redis/cpu", redis_name : var.name },
{ type : "redis/memory", redis_name : var.name },
{ type : "redis/capacity", redis_name : var.name },
{ type : "redis/cache-hit", redis_name : var.name },
],
[
{ type : "redis/current-connections", redis_name : var.name },
{ type : "redis/new-connections", redis_name : var.name },
{ type : "redis/network", redis_name : var.name },
{ type : "redis/latency", redis_name : var.name },
]
]
}
15 changes: 15 additions & 0 deletions modules/dashboard/modules/blocks/redis/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "name" {
type = string
description = "RDS name"
}

variable "db_max_connections_count" {
type = string
description = "RDS maximum connection count"
default = null
}

variable "region" {
type = string
default = ""
}
78 changes: 78 additions & 0 deletions modules/dashboard/modules/widgets/redis/cache-hit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../../base | n/a |

## Resources

| Name | Type |
|------|------|
| [aws_caller_identity.project](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | n/a | `string` | `null` | no |
| <a name="input_anomaly_detection"></a> [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no |
| <a name="input_cluster"></a> [cluster](#input\_cluster) | n/a | `string` | n/a | yes |
| <a name="input_container"></a> [container](#input\_container) | n/a | `string` | n/a | yes |
| <a name="input_coordinates"></a> [coordinates](#input\_coordinates) | position | <pre>object({<br> x : number<br> y : number<br> width : number<br> height : number<br> })</pre> | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | n/a | `string` | `"default"` | no |
| <a name="input_period"></a> [period](#input\_period) | stats | `number` | `300` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_data"></a> [data](#output\_data) | n/a |
<!-- END_TF_DOCS -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

No requirements.

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../../base | n/a |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_anomaly_detection"></a> [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `false` | no |
| <a name="input_anomaly_deviation"></a> [anomaly\_deviation](#input\_anomaly\_deviation) | Deviation of the anomaly band | `number` | `6` | no |
| <a name="input_coordinates"></a> [coordinates](#input\_coordinates) | position | <pre>object({<br> x : number<br> y : number<br> width : number<br> height : number<br> })</pre> | n/a | yes |
| <a name="input_data_source_uid"></a> [data\_source\_uid](#input\_data\_source\_uid) | The grafana dashboard widget item data source id | `string` | n/a | yes |
| <a name="input_period"></a> [period](#input\_period) | stats | `number` | `300` | no |
| <a name="input_platform"></a> [platform](#input\_platform) | The platform/service/adapter to create dashboard on. for now only cloudwatch and grafana supported | `string` | `"cloudwatch"` | no |
| <a name="input_redis_name"></a> [redis\_name](#input\_redis\_name) | ElastiCache instance name | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_data"></a> [data](#output\_data) | n/a |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
21 changes: 21 additions & 0 deletions modules/dashboard/modules/widgets/redis/cache-hit/base.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module "base" {
source = "../../base"

platform = var.platform
data_source_uid = var.data_source_uid

coordinates = var.coordinates

name = "Cache Hit Rate"

defaults = {
MetricNamespace = "AWS/ElastiCache"
CacheClusterId = var.redis_name
}

period = var.period

metrics = [
{ MetricName = "CacheHitRate", color = "#7FFFD4", anomaly_detection = var.anomaly_detection, anomaly_deviation = var.anomaly_deviation },
]
}
3 changes: 3 additions & 0 deletions modules/dashboard/modules/widgets/redis/cache-hit/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "data" {
value = module.base.data
}
44 changes: 44 additions & 0 deletions modules/dashboard/modules/widgets/redis/cache-hit/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
variable "platform" {
type = string
default = "cloudwatch"
description = "The platform/service/adapter to create dashboard on. for now only cloudwatch and grafana supported"
}

variable "data_source_uid" {
type = string
description = "The grafana dashboard widget item data source id"
}


# position
variable "coordinates" {
type = object({
x : number
y : number
width : number
height : number
})
}

# stats
variable "period" {
type = number
default = 300
}

variable "redis_name" {
type = string
description = "ElastiCache instance name"
}

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"
}
Loading

0 comments on commit 2ddafa3

Please sign in to comment.