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

Add variable monitoring-host-project to alerting module. #540

Merged
merged 3 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Terraform module.
# Enable optional alerting.
module "en-alerting" {
source = "github.com/google/exposure-notifications-verification-server/terraform/alerting"
project = "example"
monitoring-host-project = "example"

adminapi-host = "adminapi.example.org"
apiserver-host = "apiserver.example.org"
Expand Down
10 changes: 5 additions & 5 deletions terraform/alerting/monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
# limitations under the License.

resource "google_monitoring_dashboard" "verification-server" {
project = var.project
project = var.monitoring-host-project
dashboard_json = jsonencode(yamldecode(file("${path.module}/dashboards/verification-server.yaml")))
depends_on = [
null_resource.manual-step-to-enable-workspace
]
}

resource "google_monitoring_dashboard" "e2e" {
project = var.project
project = var.monitoring-host-project
dashboard_json = jsonencode(yamldecode(file("${path.module}/dashboards/e2e.yaml")))
depends_on = [
null_resource.manual-step-to-enable-workspace
]
}

resource "google_monitoring_alert_policy" "five_xx" {
project = var.project
project = var.monitoring-host-project
display_name = "Elevated 5xx"
combiner = "OR"
conditions {
Expand Down Expand Up @@ -75,7 +75,7 @@ EOT
}

resource "google_monitoring_alert_policy" "rate_limited_count" {
project = var.project
project = var.monitoring-host-project
display_name = "ElevatedRateLimitedCount"
combiner = "OR"
conditions {
Expand Down Expand Up @@ -111,7 +111,7 @@ client app, or a potential DoS attack.

View the metric here

https://console.cloud.google.com/monitoring/dashboards/custom/${basename(google_monitoring_dashboard.verification-server.id)}?project=${var.project}
https://console.cloud.google.com/monitoring/dashboards/custom/${basename(google_monitoring_dashboard.verification-server.id)}?project=${var.monitoring-host-project}
EOT
mime_type = "text/markdown"
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/alerting/notifications.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "google_monitoring_notification_channel" "email" {
provider = google-beta
project = var.project
project = var.monitoring-host-project
display_name = "Email Notification Channel"
type = "email"
labels = {
Expand Down
6 changes: 3 additions & 3 deletions terraform/alerting/probers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "google_monitoring_uptime_check_config" "https" {

display_name = each.key
timeout = "3s"
project = var.project
project = var.monitoring-host-project
period = "60s"

http_check {
Expand All @@ -16,7 +16,7 @@ resource "google_monitoring_uptime_check_config" "https" {
monitored_resource {
type = "uptime_url"
labels = {
project_id = var.project
project_id = var.monitoring-host-project
host = each.key
}
}
Expand All @@ -26,7 +26,7 @@ resource "google_monitoring_uptime_check_config" "https" {
}

resource "google_monitoring_alert_policy" "probers" {
project = var.project
project = var.monitoring-host-project
display_name = "Host Down"
combiner = "OR"
conditions {
Expand Down
5 changes: 3 additions & 2 deletions terraform/alerting/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
variable "project" {
type = string
variable "monitoring-host-project" {
type = string
description = "The host project for multi-project workspace. See also: http://cloud/monitoring/workspaces/create#first-multi-project-workspace"
}

variable "notification-email" {
Expand Down
2 changes: 1 addition & 1 deletion terraform/alerting/workspace.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resource "null_resource" "manual-step-to-enable-workspace" {
provisioner "local-exec" {
command = <<EOF
echo -e '>>>> WARNING WARNING WARNING!'
echo -e '>>>> Please use https://console.cloud.google.com/monitoring/signup?project=${var.project}&nextPath=monitoring to create the first workspace.'
echo -e '>>>> Please use https://console.cloud.google.com/monitoring/signup?project=${var.monitoring-host-project}&nextPath=monitoring to create the first workspace.'
echo -e '>>>> Terraform cannot create workspace yet, you can only create workspace via the Google Cloud Console.'
echo -e '>>>> Related doc: https://cloud.google.com/monitoring/workspaces/create#single-project-workspace'
EOF
Expand Down