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

Commit

Permalink
Log metric for in use hosts (#759)
Browse files Browse the repository at this point in the history
* init

* whitespace

* first pass

* Fix regex

* Fix escaping
  • Loading branch information
icco authored Oct 6, 2020
1 parent 53810ad commit 10cd709
Showing 1 changed file with 21 additions and 0 deletions.
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\\\\-._~%!$&'()*+,;=:]+\\\\])/.*$\")"
}
}

0 comments on commit 10cd709

Please sign in to comment.