diff --git a/terraform/alerting/monitoring.tf b/terraform/alerting/monitoring.tf index 5ba49d5bb..cb9d640c3 100644 --- a/terraform/alerting/monitoring.tf +++ b/terraform/alerting/monitoring.tf @@ -221,3 +221,24 @@ EOT null_resource.manual-step-to-enable-workspace ] } + +resource "google_logging_metric" "requests_by_host" { + name = "requests_by_host" + filter = <<-EOT +resource.type=cloud_run_revision +httpRequest.requestUrl!="" +EOT + + metric_descriptor { + metric_kind = "DELTA" + value_type = "INT64" + labels { + key = "host" + value_type = "STRING" + } + } + + label_extractors = { + "host" = "REGEXP_EXTRACT(httpRequest.requestUrl, \"^https?://([a-z0-9\\\\-._~%]+|\\\\[[a-z0-9\\\\-._~%!$&'()*+,;=:]+\\\\])/.*$\")" + } +}