Skip to content

Commit

Permalink
[Dashboard] Show number of devices needed for majority (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter authored Sep 30, 2024
1 parent 3e96b07 commit ec2cb5d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions deployment/modules/monitoring/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ resource "google_project_service" "monitoring_api" {
locals {
distributor_service = "distributor-service-${var.env}"
duration = "5m"
# Calculate the threshold for majority.
majority = ceil((1 + var.num_expected_devices) / 2)
majority_percent = local.majority / var.num_expected_devices * 100
}

resource "google_monitoring_dashboard" "witness_dashboard" {
Expand Down Expand Up @@ -93,6 +96,9 @@ resource "google_monitoring_dashboard" "witness_dashboard" {
},
"plotType": "STACKED_AREA"
}],
"thresholds": [{
"value": ${local.majority}
}],
"timeshiftDuration": "0s",
"yAxis": {
"label": "Devices",
Expand All @@ -110,7 +116,7 @@ resource "google_monitoring_dashboard" "witness_dashboard" {
"plotType": "STACKED_AREA"
}],
"thresholds": [{
"value": 51
"value": ${local.majority_percent}
}],
"timeshiftDuration": "0s",
"yAxis": {
Expand Down Expand Up @@ -143,7 +149,7 @@ resource "google_monitoring_alert_policy" "witness_liveness" {
# timeseries across instances overlap, take the average. This ensures
# that the count for each witness is not double-counted across instances.
# Finally, add all the counts together to compare against the threshold.
query = <<-EOT
query = <<-EOT
fetch prometheus_target
| metric
'prometheus.googleapis.com/distributor_update_checkpoint_success/counter'
Expand Down

0 comments on commit ec2cb5d

Please sign in to comment.