diff --git a/alerts/webhook_alert_integration/alerts_profile.tf b/alerts/webhook_alert_integration/alerts_profile.tf new file mode 100644 index 0000000..1b06608 --- /dev/null +++ b/alerts/webhook_alert_integration/alerts_profile.tf @@ -0,0 +1,52 @@ +resource "dynatrace_alerting" "cosmos-integration-alerting-profile" { + name = var.alerting_profile_name + rules { + rule { + include_mode = var.availability_include_mode + delay_in_minutes = var.availability_delay_in_minutes + severity_level = "AVAILABILITY" + } + rule { + include_mode = var.custom_alert_include_mode + delay_in_minutes = var.custom_alert_delay_in_minutes + severity_level = "CUSTOM_ALERT" + } + rule { + include_mode = var.errors_include_mode + delay_in_minutes = var.errors_delay_in_minutes + severity_level = "ERRORS" + } + rule { + include_mode = var.monitoring_unavailable_include_mode + delay_in_minutes = var.monitoring_unavailable_delay_in_minutes + severity_level = "MONITORING_UNAVAILABLE" + } + rule { + include_mode = var.performance_include_mode + delay_in_minutes = var.performance_delay_in_minutes + severity_level = "PERFORMANCE" + } + rule { + include_mode = var.resource_contention_include_mode + delay_in_minutes = var.resource_contention_delay_in_minutes + severity_level = "RESOURCE_CONTENTION" + } + } +} + +resource "dynatrace_webhook_notification" "snow_webhook_integration" { + active = var.active + name = var.integration_notification_name + profile = dynatrace_alerting.cosmos-snow-alerting-profile.id + url = var.webhook_url + insecure = var.insecure + notify_event_merges = var.notify_closed_problems + notify_closed_problems = var.notify_closed_problems + payload = var.payload + use_oauth_2 = var.use_oauth_2 + oauth_2_credentials { + access_token_url = var.access_token_url + client_id = var.client_id + client_secret = var.client_secret + } +} diff --git a/alerts/webhook_alert_integration/providers.tf b/alerts/webhook_alert_integration/providers.tf new file mode 100644 index 0000000..59ee8ed --- /dev/null +++ b/alerts/webhook_alert_integration/providers.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + dynatrace = { + version = "~> 1.0" + source = "dynatrace-oss/dynatrace" + } + } +} \ No newline at end of file diff --git a/alerts/webhook_alert_integration/variables.tf b/alerts/webhook_alert_integration/variables.tf new file mode 100644 index 0000000..fb4aaf3 --- /dev/null +++ b/alerts/webhook_alert_integration/variables.tf @@ -0,0 +1,123 @@ +variable "alerting_profile_name" { + type = string + description = "The name of the alerting profile." +} + +variable "availability_include_mode" { + type = string + description = "The inclusion mode for availability rule." +} + +variable "availability_delay_in_minutes" { + type = string + description = "The delay in minutes for availability rule." +} + +variable "custom_alert_include_mode" { + type = string + description = "The inclusion mode for custom alert rule." +} + +variable "custom_alert_delay_in_minutes" { + type = string + description = "The delay in minutes for custom alert rule." +} + +variable "errors_include_mode" { + type = string + description = "The inclusion mode for error alert rule." +} + +variable "errors_delay_in_minutes" { + type = string + description = "The delay in minutes for error alert rule." +} + +variable "monitoring_unavailable_include_mode" { + type = string + description = "The inclusion mode for monitoring unavailable alert rule." +} + +variable "monitoring_unavailable_delay_in_minutes" { + type = string + description = "The delay in minutes for monitoring unavailable alert rule." +} + +variable "performance_include_mode" { + type = string + description = "The inclusion mode for performance alert rule." +} + +variable "performance_delay_in_minutes" { + type = string + description = "The delay in minutes for performance alert rule." +} + +variable "resource_contention_include_mode" { + type = string + description = "The inclusion mode for resource contention alert rule." +} + +variable "resource_contention_delay_in_minutes" { + type = string + description = "The delay in minutes for resource contention alert rule." +} + +variable "active" { + type = bool + description = "The configuration is enabled" +} + +variable "integration_notification_name" { + type = string + description = "The name of the notification configuration" +} + +variable "webhook_url" { + type = string + description = "The URL of the WebHook endpoint" +} + +variable "insecure" { + type = bool + default = false + description = "Accept any, including self-signed and invalid, SSL certificate" +} + +variable "notify_event_merges" { + type = bool + default = false + description = "Call webhook if new events merge into existing problems" +} + +variable "notify_closed_problems" { + type = bool + default = false + description = "Send email if problem is closed" +} + +variable "use_oauth_2" { + type = bool + default = false + description = "Use OAuth 2.0 for authentication" +} + +variable "access_token_url" { + type = string + description = "Access token URL" +} + +variable "client_id" { + type = string + description = "Client ID" +} + +variable "client_secret" { + type = string + description = "Client secret" +} + +variable "payload" { + type = string + description = "The content of the notification message" +} \ No newline at end of file