From 224cdc2d45442e753ea996147b3f3ba7b892439a Mon Sep 17 00:00:00 2001 From: whekin Date: Mon, 16 Mar 2026 05:01:41 +0400 Subject: [PATCH] chore(infra): add log exclusions and reduce retention to lower costs --- infra/terraform/monitoring.tf | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/infra/terraform/monitoring.tf b/infra/terraform/monitoring.tf index 6a6bbee..90e1b17 100644 --- a/infra/terraform/monitoring.tf +++ b/infra/terraform/monitoring.tf @@ -30,6 +30,30 @@ locals { } } +resource "google_logging_project_exclusion" "noise" { + name = "${local.name_prefix}-log-exclusion" + project = var.project_id + description = "Exclude successful health checks and static assets from ingestion" + + filter = <<-EOT +resource.type="cloud_run_revision" +httpRequest.status=200 +( + httpRequest.userAgent =~ "GoogleHC/.*" OR + httpRequest.userAgent =~ "kube-probe/.*" OR + httpRequest.requestUrl =~ ".*\\.(js|css|png|jpg|jpeg|ico|svg|woff|woff2|map)$" OR + httpRequest.requestUrl =~ ".*/health$" +) + EOT +} + +resource "google_logging_project_bucket_config" "default" { + project = var.project_id + location = "global" + bucket_id = "_Default" + retention_days = 3 +} + resource "google_monitoring_notification_channel" "email" { for_each = toset(var.alert_notification_emails)