Skip to content

Commit

Permalink
Merge pull request #67 from dasmeta/fix-bugs
Browse files Browse the repository at this point in the history
fix(DMVP-2740): Fix dashboard
  • Loading branch information
aghamyan44 authored Nov 10, 2023
2 parents d31a055 + 0d0cc7a commit d88d076
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 29 deletions.
2 changes: 1 addition & 1 deletion modules/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module "this" {

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

## Modules

Expand Down
9 changes: 5 additions & 4 deletions modules/dashboard/blocks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ module "block_service" {
count = length(local.blocks_by_type.service)

service_name = local.blocks_by_type.service[count.index].block.service_name
balancer_name = local.blocks_by_type.service[count.index].block.balancer_name
target_group_arn = local.blocks_by_type.service[count.index].block.target_group_arn
healthcheck_id = local.blocks_by_type.service[count.index].block.healthcheck_id
balancer_name = try(local.blocks_by_type.service[count.index].block.balancer_name, null)
target_group_arn = try(local.blocks_by_type.service[count.index].block.target_group_arn, null)
healthcheck_id = try(local.blocks_by_type.service[count.index].block.healthcheck_id, null)
cluster = local.blocks_by_type.service[count.index].block.cluster
namespace = try(local.blocks_by_type.service[count.index].block.namespace, "default")
region = var.region != "" ? var.region : data.aws_region.current.name
}

Expand All @@ -98,6 +99,6 @@ module "block_sla" {

count = length(local.blocks_by_type.sla)

balancer_name = local.blocks_by_type.service[count.index].block.balancer_name
balancer_name = local.blocks_by_type.sla[count.index].block.balancer_name
region = var.region != "" ? var.region : data.aws_region.current.name
}
6 changes: 3 additions & 3 deletions modules/dashboard/modules/blocks/alb/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ output "result" {
description = "description"
value = [
[
{ type : "text/title-with-link", text : "Load Balancer (ALB)", link_to_jump = "https://${var.region}.console.aws.amazon.com/ec2/home?region=${var.region}#LoadBalancer:loadBalancerArn=${data.aws_lb.balancer.arn};tab=listeners" }
{ type : "text/title-with-link", text : "Load Balancer (${var.balancer_name})", link_to_jump = "https://${var.region}.console.aws.amazon.com/ec2/home?region=${var.region}#LoadBalancer:loadBalancerArn=${data.aws_lb.balancer.arn};tab=listeners" }
],
[
{ type : "balancer/request-count", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection : false },
Expand All @@ -21,8 +21,8 @@ output "result" {
{ type : "balancer/connection-issues", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection = false },
],
[
{ type : "balancer/response-time", accountId : var.account_id, balancer_name : var.balancer_name },
{ type : "balancer/traffic", accountId : var.account_id, balancer_name : var.balancer_name },
{ type : "balancer/response-time", accountId : var.account_id, balancer_name : var.balancer_name, width : 12, anomaly_detection = true },
{ type : "balancer/traffic", accountId : var.account_id, balancer_name : var.balancer_name, width : 12, anomaly_detection = true },
],
]
}
1 change: 1 addition & 0 deletions modules/dashboard/modules/blocks/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ No resources.
| <a name="input_balancer_name"></a> [balancer\_name](#input\_balancer\_name) | ALB name | `string` | n/a | yes |
| <a name="input_cluster"></a> [cluster](#input\_cluster) | EKS cluster name | `string` | n/a | yes |
| <a name="input_healthcheck_id"></a> [healthcheck\_id](#input\_healthcheck\_id) | R53 healthcheck ID for the service | `string` | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | EKS namespace name | `string` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | n/a | `string` | `""` | no |
| <a name="input_service_name"></a> [service\_name](#input\_service\_name) | Service nameD | `string` | n/a | yes |
| <a name="input_target_group_arn"></a> [target\_group\_arn](#input\_target\_group\_arn) | Target group ARN which points to the service | `string` | n/a | yes |
Expand Down
42 changes: 28 additions & 14 deletions modules/dashboard/modules/blocks/service/output.tf
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
output "result" {
description = "description"
value = [
value = var.balancer_name != null ? [
[
{ type : "text/title", text : "Superset" }
{ type : "text/title", text : var.service_name }
],
[
{ type : "container/request-count", container : var.service_name, target_group_arn : var.target_group_arn, cluster : var.cluster },
{ type : "container/all-requests", container : var.service_name, target_group_arn : var.target_group_arn, balancer_name : var.balancer_name, cluster : var.cluster },
{ type : "container/error-rate", container : var.service_name, target_group_arn : var.target_group_arn, balancer_name : var.balancer_name, cluster : var.cluster },
{ type : "container/health-check", container : var.service_name, target_group_arn : var.target_group_arn, balancer_name : var.balancer_name, cluster : var.cluster },
{ type : "container/request-count", container : var.service_name, target_group_arn : var.target_group_arn, cluster : var.cluster, namespace : var.namespace },
{ type : "container/all-requests", container : var.service_name, target_group_arn : var.target_group_arn, balancer_name : var.balancer_name, cluster : var.cluster, namespace : var.namespace },
{ type : "container/error-rate", container : var.service_name, target_group_arn : var.target_group_arn, balancer_name : var.balancer_name, cluster : var.cluster, namespace : var.namespace },
{ type : "container/health-check", container : var.service_name, target_group_arn : var.target_group_arn, balancer_name : var.balancer_name, cluster : var.cluster, namespace : var.namespace },
],
[
{ type : "container/cpu", container : var.service_name, cluster : var.cluster },
{ type : "container/memory", container : var.service_name, cluster : var.cluster },
{ type : "container/network-in", container : var.service_name, cluster : var.cluster },
{ type : "container/network-out", container : var.service_name, cluster : var.cluster },
{ type : "container/cpu", container : var.service_name, cluster : var.cluster, namespace : var.namespace, anomaly_detection : true },
{ type : "container/memory", container : var.service_name, cluster : var.cluster, namespace : var.namespace, anomaly_detection : true },
{ type : "container/network-in", container : var.service_name, cluster : var.cluster, namespace : var.namespace, anomaly_detection : true },
{ type : "container/network-out", container : var.service_name, cluster : var.cluster, namespace : var.namespace, anomaly_detection : true },
],
[
{ type : "container/external-health-check", container : var.service_name, healthcheck_id : var.healthcheck_id, cluster : var.cluster },
{ type : "container/replicas", container : var.service_name, cluster : var.cluster },
{ type : "container/restarts", container : var.service_name, cluster : var.cluster },
{ type : "container/response-time", container : var.service_name, target_group_arn : var.target_group_arn, balancer_name : var.balancer_name, cluster : var.cluster },
{ type : "container/external-health-check", container : var.service_name, healthcheck_id : var.healthcheck_id, cluster : var.cluster, namespace : var.namespace },
{ type : "container/replicas", container : var.service_name, cluster : var.cluster, namespace : var.namespace },
{ type : "container/restarts", container : var.service_name, cluster : var.cluster, namespace : var.namespace },
{ type : "container/response-time", container : var.service_name, target_group_arn : var.target_group_arn, balancer_name : var.balancer_name, cluster : var.cluster, namespace : var.namespace },
# { type : "container/network", container : local.container_1 },
],
] : [
[
{ type : "text/title", text : var.service_name }
],
[
{ type : "container/cpu", container : var.service_name, cluster : var.cluster, namespace : var.namespace, anomaly_detection : true },
{ type : "container/memory", container : var.service_name, cluster : var.cluster, namespace : var.namespace, anomaly_detection : true },
{ type : "container/replicas", container : var.service_name, cluster : var.cluster, namespace : var.namespace },
{ type : "container/restarts", container : var.service_name, cluster : var.cluster, namespace : var.namespace },
],
[
{ type : "container/network-in", container : var.service_name, cluster : var.cluster, namespace : var.namespace, width : 12, anomaly_detection : true },
{ type : "container/network-out", container : var.service_name, cluster : var.cluster, namespace : var.namespace, width : 12, anomaly_detection : true },
]
]
}
5 changes: 5 additions & 0 deletions modules/dashboard/modules/blocks/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ variable "cluster" {
description = "EKS cluster name"
}

variable "namespace" {
type = string
description = "EKS namespace name"
}

variable "region" {
type = string
default = ""
Expand Down
2 changes: 1 addition & 1 deletion modules/dashboard/modules/widgets/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ No requirements.
| <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_view"></a> [view](#input\_view) | The view for log insights and alarm widgets | `string` | `null` | no |
| <a name="input_yAxis"></a> [yAxis](#input\_yAxis) | Widget Item common yAxis option (applied only metric type widgets). | `any` | <pre>{<br> "left": {<br> "min": 0<br> }<br>}</pre> | no |
| <a name="input_yAxis"></a> [yAxis](#input\_yAxis) | Widget Item common yAxis option (applied only metric type widgets). | `any` | <pre>{<br> "left": {}<br>}</pre> | no |

## Outputs

Expand Down
2 changes: 1 addition & 1 deletion modules/dashboard/modules/widgets/base/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ variable "properties_type" {

variable "yAxis" {
type = any
default = { left = { min = 0 } }
default = { left = {} }
description = "Widget Item common yAxis option (applied only metric type widgets)."
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ No requirements.

| 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_detection"></a> [anomaly\_detection](#input\_anomaly\_detection) | Allow to enable anomaly detection on widget metrics | `bool` | `true` | 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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ variable "zone_name" {

variable "anomaly_detection" {
type = bool
default = false
default = true
description = "Allow to enable anomaly detection on widget metrics"
}
2 changes: 1 addition & 1 deletion modules/dashboard/modules/widgets/sla-slo-sli/base.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module "base" {

coordinates = var.coordinates

name = "SLA"
name = "${var.balancer_name} SLA"

# stats
stat = "Sum"
Expand Down
76 changes: 76 additions & 0 deletions modules/dashboard/modules/widgets/text/markdown/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Why
Widget to render markdown text.

```
{
text: "Whatever text has to go here",
coordinates: {
x: 4
y: 10
width: 4
height: 4
}
}
```

<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.

## Providers

No providers.

## Modules

No modules.

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_text"></a> [text](#input\_text) | n/a | `string` | n/a | yes |
| <a name="input_y"></a> [y](#input\_y) | n/a | `number` | n/a | yes |

## 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

No modules.

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <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_text"></a> [text](#input\_text) | n/a | `string` | n/a | yes |
| <a name="input_transparent-background"></a> [transparent-background](#input\_transparent-background) | n/a | `bool` | `true` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_data"></a> [data](#output\_data) | n/a |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
14 changes: 14 additions & 0 deletions modules/dashboard/modules/widgets/text/markdown/local.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
locals {
data = {
"type" : "text",
"x" : var.coordinates.x,
"y" : var.coordinates.y,
"width" : var.coordinates.width,
"height" : var.coordinates.height,

"properties" : {
"markdown" : "${var.text}"
"background" : var.transparent-background ? "transparent" : ""
}
}
}
3 changes: 3 additions & 0 deletions modules/dashboard/modules/widgets/text/markdown/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "data" {
value = local.data
}
17 changes: 17 additions & 0 deletions modules/dashboard/modules/widgets/text/markdown/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "text" {
type = string
}

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

variable "transparent-background" {
type = bool
default = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ No resources.
|------|-------------|------|---------|:--------:|
| <a name="input_link_to_jump"></a> [link\_to\_jump](#input\_link\_to\_jump) | The URL to wich the user can be redirected after clicking on the title | `string` | n/a | yes |
| <a name="input_text"></a> [text](#input\_text) | n/a | `string` | n/a | yes |
| <a name="input_width"></a> [width](#input\_width) | n/a | `number` | `24` | no |
| <a name="input_y"></a> [y](#input\_y) | n/a | `number` | n/a | yes |

## Outputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ locals {
"type" : "text",
"x" : 0,
"y" : var.y,
"width" : 24,
"width" : var.width,
"height" : 1,

"properties" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ variable "link_to_jump" {
variable "y" {
type = number
}

variable "width" {
type = number
default = 24
}
2 changes: 1 addition & 1 deletion modules/dashboard/tests/widgets-log-based/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.33 |
| <a name="provider_test"></a> [test](#provider\_test) | n/a |

## Modules
Expand Down

0 comments on commit d88d076

Please sign in to comment.