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

alert on remaining disk instead of utilization #658

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Changes from 1 commit
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
31 changes: 16 additions & 15 deletions terraform/gcp/modules/monitoring/infra/alerts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ resource "google_monitoring_alert_policy" "cloud_sql_memory_utilization" {
project = var.project_id
}

# Cloud SQL Database Disk Utilization > 98%
# Cloud SQL Database Disk has < 20GiB Free
resource "google_monitoring_alert_policy" "cloud_sql_disk_utilization" {
# In the absence of data, incident will auto-close in 7 days
alert_strategy {
Expand All @@ -118,30 +118,31 @@ resource "google_monitoring_alert_policy" "cloud_sql_disk_utilization" {
combiner = "OR"

conditions {
condition_threshold {
aggregations {
alignment_period = "300s"
per_series_aligner = "ALIGN_MEAN"
}

comparison = "COMPARISON_GT"
duration = "0s"
filter = "metric.type=\"cloudsql.googleapis.com/database/disk/utilization\" resource.type=\"cloudsql_database\""
threshold_value = "0.98"

condition_monitoring_query_language {
duration = "0s"
query = <<-EOT
fetch cloudsql_database
| { bytes: metric 'cloudsql.googleapis.com/database/disk/bytes_used'
; quota: metric 'cloudsql.googleapis.com/database/disk/quota' }
| join
| group_by 5m, [q_mean: mean(value.quota), b_mean: mean(value.bytes_used)]
| every 5m
| group_by [resource.database_id], [free_space: sub(mean(q_mean), mean(b_mean))]
| condition free_space < 20 'GiBy'
EOT
trigger {
count = "1"
percent = "0"
}
}

display_name = "Cloud SQL Database - Disk utilization [MEAN]"
display_name = "Cloud SQL Database - Disk free space [MEAN]"
}

display_name = "Cloud Sql Disk Utilization > 98%"
display_name = "Cloud SQL Database Disk has < 20GiB Free"

documentation {
content = "Cloud SQL disk utilization is > 98%. Please increase capacity. Note that autoresize should be enabled for the database. Ensure there is no issue with the autoresize process."
content = "Cloud SQL disk has less than 20GiB free space remaining. Please increase capacity. Note that autoresize should be enabled for the database. Ensure there is no issue with the autoresize process."
mime_type = "text/markdown"
}

Expand Down
Loading