Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made sample alert creation optional #850

Merged
2 changes: 1 addition & 1 deletion blueprints/cloud-operations/quota-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Labels are set with project id (which may differ from the monitoring workspace p

<img src="explorer.png" width="640px" alt="GCP Metrics Explorer, usage, limit and utilization view sample">

The solution also creates a basic monitoring alert policy, to demonstrate how to raise alerts when quotas utilization goes over a predefined threshold.
The solution can also create a basic monitoring alert policy, to demonstrate how to raise alerts when quotas utilization goes over a predefined threshold, to enable it, set variable `alert_create` to true and reapply main.tf after main.py has run at least one and quota monitoring metrics have been creaed.

## Running the blueprint

Expand Down
3 changes: 3 additions & 0 deletions blueprints/cloud-operations/quota-monitoring/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ resource "google_project_iam_member" "quota_viewer" {
member = module.cf.service_account_iam_email
}


resource "google_monitoring_alert_policy" "alert_policy" {
count = var.alert_create ? 1 : 0
project = module.project.project_id
display_name = "Quota monitor"
combiner = "OR"
Expand Down Expand Up @@ -137,6 +139,7 @@ resource "google_monitoring_alert_policy" "alert_policy" {
}
}


resource "random_pet" "random" {
length = 1
}
8 changes: 7 additions & 1 deletion blueprints/cloud-operations/quota-monitoring/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
* limitations under the License.
*/

variable "alert_create" {
description = "Enables the creation of a sample monitoring alert, false by default."
type = bool
default = false
}

variable "bundle_path" {
description = "Path used to write the intermediate Cloud Function code bundle."
type = string
Expand All @@ -27,7 +33,7 @@ variable "name" {
}

variable "project_create" {
description = "Create project instead ofusing an existing one."
description = "Create project instead of using an existing one."
type = bool
default = false
}
Expand Down