diff --git a/modules/gcp/baseline-monitoring/00_foundation.tf b/modules/gcp/baseline-monitoring/00_foundation.tf new file mode 100644 index 0000000..173184a --- /dev/null +++ b/modules/gcp/baseline-monitoring/00_foundation.tf @@ -0,0 +1,17 @@ +variable "infra_ops_project_id" { + description = "The ID of the central Infra-Ops project (e.g., cloudkite-infra-ops)" + type = string +} + +variable "monitored_project_ids" { + description = "List of project IDs to monitor (e.g., cloudkite-dev, cloudkite-prod)" + type = list(string) +} + +# Link the projects (Metrics Scope) +resource "google_monitoring_monitored_project" "projects" { + for_each = toset(var.monitored_project_ids) + + metrics_scope = var.infra_ops_project_id + name = each.value +} diff --git a/modules/gcp/baseline-monitoring/01_infrastructure.tf b/modules/gcp/baseline-monitoring/01_infrastructure.tf new file mode 100644 index 0000000..92d4035 --- /dev/null +++ b/modules/gcp/baseline-monitoring/01_infrastructure.tf @@ -0,0 +1,25 @@ +# LOG-BASED METRICS (Iterated per project) +resource "google_logging_metric" "oom_events" { + for_each = toset(var.monitored_project_ids) + + name = "k8s_oom_events" + project = each.value + + description = "Count of OOMKilled events from GKE containers" + filter = "resource.type=\"k8s_container\" AND textPayload:\"OOMKilled\"" + + metric_descriptor { + metric_kind = "DELTA" + value_type = "INT64" + unit = "1" + } +} + +# INFRASTRUCTURE DASHBOARD +# resource "google_monitoring_dashboard" "infrastructure_dashboard" { +# project = var.infra_ops_project_id + +# dashboard_json = <