Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Log metric for in use hosts #759

Merged
merged 6 commits into from
Oct 6, 2020
Merged
Changes from all commits
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
21 changes: 21 additions & 0 deletions terraform/alerting/monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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\\\\-._~%!$&'()*+,;=:]+\\\\])/.*$\")"
}
}