MON-554 - Add first version of Velero monitors

This commit is contained in:
Jean-Philippe LAINE 2020-01-14 16:00:31 +01:00
parent 0c3fde1432
commit 303fffc00c
4 changed files with 418 additions and 0 deletions

View File

@ -0,0 +1,206 @@
# Datadog global variables
variable "environment" {
description = "Architecture environment"
}
variable "filter_tags_use_defaults" {
description = "Use default filter tags convention"
default = "true"
}
variable "filter_tags_custom" {
description = "Tags used for custom filtering when filter_tags_use_defaults is false"
default = "*"
}
variable "filter_tags_custom_excluded" {
description = "Tags excluded for custom filtering when filter_tags_use_defaults is false"
default = ""
}
variable "filter_tags_scheduled_backup_use_defaults" {
description = "Use default filter tags scheduled backup convention"
default = null
}
variable "filter_tags_scheduled_backup_custom" {
description = "Tags used for scheduled backup custom filtering when filter_tags_scheduled_backup_use_defaults is false"
default = null
}
variable "filter_tags_scheduled_backup_custom_excluded" {
description = "Tags excluded for scheduled backup custom filtering when filter_tags_scheduled_backup_use_defaults is false"
default = null
}
variable "message" {
description = "Message sent when a monitor is triggered"
}
variable "evaluation_delay" {
description = "Delay in seconds for the metric evaluation"
default = 15
}
variable "new_host_delay" {
description = "Delay in seconds before monitor new resource"
default = 300
}
variable "prefix_slug" {
description = "Prefix string to prepend between brackets on every monitors names"
default = ""
}
variable "notify_no_data" {
description = "Will raise no data alert if set to true"
default = true
}
# Datadog monitors variables
variable "velero_scheduled_backup_missing_monitor_message" {
description = "Custom message for Velero scheduled backup missing monitor"
type = string
default = ""
}
variable "velero_scheduled_backup_missing_monitor_timeframe" {
description = "Monitor timeframe for Velero scheduled backup missing monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_1d"
}
variable "velero_scheduled_backup_missing_enabled" {
description = "Flag to enable Velero scheduled backup missing monitor"
type = string
default = "true"
}
variable "velero_scheduled_backup_missing_extra_tags" {
description = "Extra tags for Velero scheduled backup missing monitor"
type = list(string)
default = []
}
variable "velero_scheduled_backup_missing_monitor_no_data_timeframe" {
description = "No data timeframe in minutes"
default = 1440
}
variable "velero_backup_failure_monitor_message" {
description = "Custom message for Velero backup failure monitor"
type = string
default = ""
}
variable "velero_backup_failure_monitor_timeframe" {
description = "Monitor timeframe for Velero backup failure monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_1d"
}
variable "velero_backup_failure_enabled" {
description = "Flag to enable Velero backup failure monitor"
type = string
default = "true"
}
variable "velero_backup_failure_extra_tags" {
description = "Extra tags for Velero backup failure monitor"
type = list(string)
default = []
}
variable "velero_backup_failure_monitor_no_data_timeframe" {
description = "No data timeframe in minutes"
default = 1440
}
variable "velero_backup_partial_failure_monitor_message" {
description = "Custom message for Velero backup partial failure monitor"
type = string
default = ""
}
variable "velero_backup_partial_failure_monitor_timeframe" {
description = "Monitor timeframe for Velero backup partial failure monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_1d"
}
variable "velero_backup_partial_failure_enabled" {
description = "Flag to enable Velero backup partial failure monitor"
type = string
default = "true"
}
variable "velero_backup_partial_failure_extra_tags" {
description = "Extra tags for Velero backup partial failure monitor"
type = list(string)
default = []
}
variable "velero_backup_partial_failure_monitor_no_data_timeframe" {
description = "No data timeframe in minutes"
default = 1440
}
variable "velero_backup_deletion_failure_monitor_message" {
description = "Custom message for Velero backup deletion failure monitor"
type = string
default = ""
}
variable "velero_backup_deletion_failure_monitor_timeframe" {
description = "Monitor timeframe for Velero backup deletion failure monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_1d"
}
variable "velero_backup_deletion_failure_enabled" {
description = "Flag to enable Velero backup deletion failure monitor"
type = string
default = "true"
}
variable "velero_backup_deletion_failure_extra_tags" {
description = "Extra tags for Velero backup deletion failure monitor"
type = list(string)
default = []
}
variable "velero_backup_deletion_failure_monitor_no_data_timeframe" {
description = "No data timeframe in minutes"
default = 1440
}
variable "velero_volume_snapshot_failure_monitor_message" {
description = "Custom message for Velero volume snapshot failure monitor"
type = string
default = ""
}
variable "velero_volume_snapshot_failure_monitor_timeframe" {
description = "Monitor timeframe for Velero volume snapshot failure monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_1d"
}
variable "velero_volume_snapshot_failure_enabled" {
description = "Flag to enable Velero volume snapshot failure monitor"
type = string
default = "true"
}
variable "velero_volume_snapshot_failure_extra_tags" {
description = "Extra tags for Velero volume snapshot failure monitor"
type = list(string)
default = []
}
variable "velero_volume_snapshot_failure_monitor_no_data_timeframe" {
description = "No data timeframe in minutes"
default = 1440
}

View File

@ -0,0 +1,19 @@
module "filter-tags" {
source = "../../../common/filter-tags"
environment = var.environment
resource = "velero"
filter_tags_use_defaults = var.filter_tags_use_defaults
filter_tags_custom = var.filter_tags_custom
filter_tags_custom_excluded = var.filter_tags_custom_excluded
}
module "filter-tags-scheduled-backup" {
source = "../../../common/filter-tags"
environment = var.environment
resource = "velero"
filter_tags_use_defaults = var.filter_tags_scheduled_backup_use_defaults != null ? var.filter_tags_scheduled_backup_use_defaults : var.filter_tags_use_defaults
filter_tags_custom = var.filter_tags_scheduled_backup_custom != null ? var.filter_tags_scheduled_backup_custom : var.filter_tags_custom
filter_tags_custom_excluded = var.filter_tags_scheduled_backup_custom_excluded != null ? var.filter_tags_scheduled_backup_custom_excluded : var.filter_tags_custom_excluded
}

View File

@ -0,0 +1,169 @@
resource "datadog_monitor" "velero_scheduled_backup_missing" {
count = var.velero_scheduled_backup_missing_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Velero scheduled backup missing"
type = "query alert"
message = coalesce(var.velero_scheduled_backup_missing_monitor_message, var.message)
query = <<EOQ
sum(${var.velero_scheduled_backup_missing_monitor_timeframe}):sum:velero.velero_backup_success_total${module.filter-tags-scheduled-backup.query_alert} by {cluster-name,schedule}.as_count() < 1
EOQ
thresholds = {
critical = 1
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
no_data_timeframe = var.velero_scheduled_backup_missing_monitor_no_data_timeframe
notify_no_data = var.notify_no_data
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:caas", "provider:prometheus", "resource:velero", "team:claranet", "created-by:terraform"], var.velero_scheduled_backup_missing_extra_tags)
lifecycle {
ignore_changes = [silenced]
}
}
resource "datadog_monitor" "velero_backup_failure" {
count = var.velero_backup_failure_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Velero backup failure"
type = "query alert"
message = coalesce(var.velero_backup_failure_monitor_message, var.message)
query = <<EOQ
sum(${var.velero_backup_failure_monitor_timeframe}):min:velero.velero_backup_failure_total${module.filter-tags.query_alert} by {schedule}.as_count() > 1
EOQ
thresholds = {
critical = 1
warning = 0
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
no_data_timeframe = var.velero_backup_failure_monitor_no_data_timeframe
notify_no_data = var.notify_no_data
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:caas", "provider:prometheus", "resource:velero", "team:claranet", "created-by:terraform"], var.velero_backup_failure_extra_tags)
lifecycle {
ignore_changes = [silenced]
}
}
resource "datadog_monitor" "velero_backup_partial_failure" {
count = var.velero_backup_partial_failure_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Velero backup partial failure"
type = "query alert"
message = coalesce(var.velero_backup_partial_failure_monitor_message, var.message)
query = <<EOQ
sum(${var.velero_backup_partial_failure_monitor_timeframe}):min:velero.velero_backup_partial_failure_total${module.filter-tags.query_alert} by {schedule}.as_count() > 1
EOQ
thresholds = {
critical = 1
warning = 0
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
no_data_timeframe = var.velero_backup_partial_failure_monitor_no_data_timeframe
notify_no_data = var.notify_no_data
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:caas", "provider:prometheus", "resource:velero", "team:claranet", "created-by:terraform"], var.velero_backup_partial_failure_extra_tags)
lifecycle {
ignore_changes = [silenced]
}
}
resource "datadog_monitor" "velero_backup_deletion_failure" {
count = var.velero_backup_deletion_failure_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Velero backup deletion failure"
type = "query alert"
message = coalesce(var.velero_backup_deletion_failure_monitor_message, var.message)
query = <<EOQ
sum(${var.velero_backup_deletion_failure_monitor_timeframe}):min:velero.velero_backup_deletion_failure_total${module.filter-tags.query_alert} by {schedule}.as_count() > 1
EOQ
thresholds = {
critical = 1
warning = 0
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
no_data_timeframe = var.velero_backup_deletion_failure_monitor_no_data_timeframe
notify_no_data = var.notify_no_data
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:caas", "provider:prometheus", "resource:velero", "team:claranet", "created-by:terraform"], var.velero_backup_deletion_failure_extra_tags)
lifecycle {
ignore_changes = [silenced]
}
}
resource "datadog_monitor" "velero_volume_snapshot_failure" {
count = var.velero_volume_snapshot_failure_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Velero volume snapshot failure"
type = "query alert"
message = coalesce(var.velero_volume_snapshot_failure_monitor_message, var.message)
query = <<EOQ
sum(${var.velero_volume_snapshot_failure_monitor_timeframe}):min:velero.velero_volume_snapshot_failure_total${module.filter-tags.query_alert} by {schedule}.as_count() > 1
EOQ
thresholds = {
critical = 1
warning = 0
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
no_data_timeframe = var.velero_volume_snapshot_failure_monitor_no_data_timeframe
notify_no_data = var.notify_no_data
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:caas", "provider:prometheus", "resource:velero", "team:claranet", "created-by:terraform"], var.velero_volume_snapshot_failure_extra_tags)
lifecycle {
ignore_changes = [silenced]
}
}

View File

@ -0,0 +1,24 @@
output "velero_scheduled_backup_missing_id" {
description = "id for monitor velero_scheduled_backup_missing"
value = datadog_monitor.velero_scheduled_backup_missing.*.id
}
output "velero_backup_failure_id" {
description = "id for monitor velero_backup_failure"
value = datadog_monitor.velero_backup_failure.*.id
}
output "velero_backup_partial_failure_id" {
description = "id for monitor velero_backup_partial_failure"
value = datadog_monitor.velero_backup_partial_failure.*.id
}
output "velero_backup_deletion_failure_id" {
description = "id for monitor velero_backup_deletion_failure"
value = datadog_monitor.velero_backup_deletion_failure.*.id
}
output "velero_volume_snapshot_failure_id" {
description = "id for monitor velero_volume_snapshot_failure"
value = datadog_monitor.velero_volume_snapshot_failure.*.id
}