I have been trying to setup alert policies(thru stack-driver) to get email notifications whenever there is new object in the cloud storage bucket.
But the issue here is, it works sometimes after a while and most of the other times, it wont.
How do we make the alerts triggered immediately as in when there is a new file in the bucket(multiple times per day).
Below is the code:
resource "google_monitoring_alert_policy" "alert_policy" {
display_name = "File notification"
combiner = "OR"
notification_channels = ["${google_monitoring_notification_channel.email.name}"]
conditions {
display_name = "File Notification"
condition_threshold {
comparison = "COMPARISON_LT"
duration = "60s"
filter = "metric.type=\"storage.googleapis.com/storage/object_count\" resource.type=\"gcs_bucket\" resource.label.\"bucket_name\"=\"realbucketname\""
threshold_value = 1
aggregations {
alignment_period = "60s"
per_series_aligner = "ALIGN_COUNT"
}
trigger {
count = 1
}
}
}
documentation {
content = "There is a new file"
}
}
Appreciate your inputs!
Thank you
Thank you. I had it fixed by removing aggregations in my scripts,
It worked as expected now !!!
condition_threshold {
comparison = "COMPARISON_GT"
duration = "60s"
filter = "metric.type=\"storage.googleapis.com/storage/object_count\" resource.type=\"gcs_bucket\" resource.label.\"bucket_name\"=\"realbucketname\""
threshold_value = 1