diff --git a/alerts/cloudfront_alerts/cloudfront_alerts.tf b/alerts/cloudfront_alerts/cloudfront_alerts.tf new file mode 100644 index 0000000..aff754a --- /dev/null +++ b/alerts/cloudfront_alerts/cloudfront_alerts.tf @@ -0,0 +1,35 @@ +resource "dynatrace_alerting" "cosmos-cloudfront-alerting-profile" { + name = var.cloudfront_alerting_profile_name + rules { + rule { + include_mode = var.cloudfront_include_mode + delay_in_minutes = var.cloudfront_delay_in_minutes + severity_level = "AVAILABILITY" + } + rule { + include_mode = var.cloudfront_include_mode + delay_in_minutes = var.cloudfront_delay_in_minutes + severity_level = "CUSTOM_ALERT" + } + rule { + include_mode = var.cloudfront_include_mode + delay_in_minutes = var.cloudfront_delay_in_minutes + severity_level = "ERRORS" + } + rule { + include_mode = var.cloudfront_include_mode + delay_in_minutes = var.cloudfront_delay_in_minutes + severity_level = "MONITORING_UNAVAILABLE" + } + rule { + include_mode = var.cloudfront_include_mode + delay_in_minutes = var.cloudfront_delay_in_minutes + severity_level = "PERFORMANCE" + } + rule { + include_mode = var.cloudfront_include_mode + delay_in_minutes = var.cloudfront_delay_in_minutes + severity_level = "RESOURCE_CONTENTION" + } + } +} \ No newline at end of file diff --git a/alerts/cloudfront_alerts/cloudfront_alerts_variable.tf b/alerts/cloudfront_alerts/cloudfront_alerts_variable.tf new file mode 100644 index 0000000..950f7dc --- /dev/null +++ b/alerts/cloudfront_alerts/cloudfront_alerts_variable.tf @@ -0,0 +1,186 @@ +# Variables for cloudfront Alerting Profile +# Name of the alerting profile to be used for cloudfront +# This typically refers to the specific configuration profile for monitoring and alerts in your system. +variable "cloudfront_alerting_profile_name" { + type = string + description = "The name of the alerting profile for cloudfront monitoring and notification configuration." +} + +# Mode for including cloudfront instances in the alerting configuration. +# This could define a specific inclusion strategy, such as "ALL", "NONE", or "FILTERED". +variable "cloudfront_include_mode" { + type = string + description = "The inclusion mode for cloudfront instances in the alerting configuration (e.g., 'ALL', 'NONE', or 'FILTERED')." +} + +# Delay in minutes for triggering alerts after an event is detected. +# This ensures alerts are not sent prematurely during transient issues. +variable "cloudfront_delay_in_minutes" { + type = string + description = "The delay (in minutes) before sending an alert for an event related to cloudfront." +} + +# List of email IDs to receive alerts for cloudfront events. +# This is typically used to notify relevant stakeholders or administrators. +variable "cloudfront_email_id" { + type = list(string) + description = "A list of email addresses to send cloudfront alerts to." +} + +# Variables for cloudfront total alerts +variable "cloudfront_total_alert_rate_enabled" { + type = bool + description = "Enable or disable the total alert rate alert." +} + +variable "cloudfront_total_alert_rate_event_entity_dimension_key" { + type = string + description = "Dimension key for the event entity of total alert rate." +} + +variable "cloudfront_total_alert_rate_summary" { + type = string + description = "Summary of the total alert rate alert." +} + +variable "cloudfront_total_alert_rate_description" { + type = string + description = "Description of the total alert rate alert." +} + +variable "cloudfront_total_alert_rate_davis_merge" { + type = bool + description = "Flag to enable or disable Davis merge for total alert rate events." +} + +variable "cloudfront_total_alert_rate_event_type" { + type = string + description = "Type of the event for total alert rate." +} + +variable "cloudfront_total_alert_rate_title" { + type = string + description = "Title of the total alert rate event." +} + +variable "cloudfront_total_alert_rate_model_properties_type" { + type = string + description = "Type of the model properties for total alert rate." +} + +variable "cloudfront_total_alert_rate_alert_condition" { + type = string + description = "Alert condition for total alert rate events." +} + +variable "cloudfront_total_alert_rate_alert_on_no_data" { + type = bool + description = "Enable or disable alerts for no data in total alert rate." +} + +variable "cloudfront_total_alert_rate_dealerting_samples" { + type = string + description = "string of samples for dealerting in total alert rate." +} + +variable "cloudfront_total_alert_rate_samples" { + type = string + description = "string of samples for total alert rate events." +} + +variable "cloudfront_total_alert_rate_threshold" { + type = string + description = "Threshold value for total alert rate events." +} + +variable "cloudfront_total_alert_rate_violating_samples" { + type = string + description = "string of violating samples for total alert rate events." +} + +variable "cloudfront_total_alert_rate_query_definition_type" { + type = string + description = "Query definition type for total alert rate." +} + +variable "cloudfront_total_alert_rate_aggregation" { + type = string + description = "Aggregation method for total alert rate events." +} + +variable "cloudfront_total_alert_rate_metric_key" { + type = string + description = "Metric key for total alert rate." +} + +variable "cloudfront_total_alert_rate_dimension_key" { + type = string + description = "Dimension key for total alert rate." +} + +variable "cloudfront_total_alert_rate_dimension_value" { + type = string + description = "Dimension value for total alert rate." +} + +variable "cloudfront_total_alert_rate_entity_filter_condition1_type" { + type = string + description = "Type of the first entity filter condition for total alert rate." +} + +variable "cloudfront_total_alert_rate_entity_filter_condition1_operator" { + type = string + description = "Operator for the first entity filter condition for total alert rate." +} + +variable "cloudfront_total_alert_rate_entity_filter_condition1_value" { + type = string + description = "Value of the first entity filter condition for total alert rate." +} + +# Variables for Dynatrace Email Notification +variable "cloudfront_email_notification_enabled" { + type = bool + description = "Enable or disable the Dynatrace email notification." +} + +variable "cloudfront_email_notification_name" { + type = string + description = "Name of the Dynatrace email notification." +} + +variable "cloudfront_email_subject" { + type = string + description = "Subject of the Dynatrace email notifications." +} + +variable "cloudfront_notify_closed_problem" { + type = bool + description = "Enable or disable notifications for closed problems." +} + +# Variables for cloudfront Slack Notification +variable "cloudfront_slack_notification_enabled" { + type = bool + description = "Enable or disable the Dynatrace Slack notification." +} + +variable "cloudfront_slack_notification_name" { + type = string + description = "Name of the Dynatrace Slack notification." +} + +variable "cloudfront_slack_url" { + type = string + description = "Slack webhook URL for Dynatrace notifications." +} + +variable "cloudfront_channel_name" { + type = string + description = "Slack channel name for Dynatrace notifications." +} + +variable "cloudfront_slack_message" { + type = string + description = "Message template for Dynatrace Slack notifications." +} diff --git a/alerts/cloudfront_alerts/cloudfront_metrics_events.tf b/alerts/cloudfront_alerts/cloudfront_metrics_events.tf new file mode 100644 index 0000000..6a49fc9 --- /dev/null +++ b/alerts/cloudfront_alerts/cloudfront_metrics_events.tf @@ -0,0 +1,59 @@ +resource "dynatrace_metric_events" "cloudfront_total_alert_rate" { + enabled = var.cloudfront_total_alert_rate_enabled + event_entity_dimension_key = var.cloudfront_total_alert_rate_event_entity_dimension_key + summary = var.cloudfront_total_alert_rate_summary + event_template { + description = var.cloudfront_total_alert_rate_description + davis_merge = var.cloudfront_total_alert_rate_davis_merge + event_type = var.cloudfront_total_alert_rate_event_type + title = var.cloudfront_total_alert_rate_title + } + model_properties { + type = var.cloudfront_total_alert_rate_model_properties_type + alert_condition = var.cloudfront_total_alert_rate_alert_condition + alert_on_no_data = var.cloudfront_total_alert_rate_alert_on_no_data + dealerting_samples = var.cloudfront_total_alert_rate_dealerting_samples + samples = var.cloudfront_total_alert_rate_samples + threshold = var.cloudfront_total_alert_rate_threshold + violating_samples = var.cloudfront_total_alert_rate_violating_samples + } + query_definition { + type = var.cloudfront_total_alert_rate_query_definition_type + aggregation = var.cloudfront_total_alert_rate_aggregation + metric_key = var.cloudfront_total_alert_rate_metric_key + dimension_filter { + filter { + dimension_key = var.cloudfront_total_alert_rate_dimension_key + dimension_value = var.cloudfront_total_alert_rate_dimension_value + } + } + entity_filter { + dimension_key = var.cloudfront_total_alert_rate_dimension_key + conditions { + condition { + type = var.cloudfront_total_alert_rate_entity_filter_condition1_type + operator = var.cloudfront_total_alert_rate_entity_filter_condition1_operator + value = var.cloudfront_total_alert_rate_entity_filter_condition1_value + } + } + } + } +} +resource "dynatrace_email_notification" "cloudfront_email_alerts" { + active = var.cloudfront_email_notification_enabled + name = var.cloudfront_email_notification_name + profile = dynatrace_alerting.cosmos-cloudfront-alerting-profile.id + subject = var.cloudfront_email_subject + to = var.cloudfront_email_id + notify_closed_problems = var.cloudfront_notify_closed_problem + body = "{ProblemDetailsHTML}" +} + +resource "dynatrace_slack_notification" "cloudfront_slack_alerts" { + active = var.cloudfront_slack_notification_enabled + name = var.cloudfront_slack_notification_name + profile = dynatrace_alerting.cosmos-cloudfront-alerting-profile.id + url = var.cloudfront_slack_url + channel = var.cloudfront_channel_name + message = var.cloudfront_slack_message +} diff --git a/alerts/cloudfront_alerts/providers.tf b/alerts/cloudfront_alerts/providers.tf new file mode 100644 index 0000000..59ee8ed --- /dev/null +++ b/alerts/cloudfront_alerts/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/msk_alerts/msk_alerts.tf b/alerts/msk_alerts/msk_alerts.tf new file mode 100644 index 0000000..1b27068 --- /dev/null +++ b/alerts/msk_alerts/msk_alerts.tf @@ -0,0 +1,35 @@ +resource "dynatrace_alerting" "cosmos-msk-alerting-profile" { + name = var.msk_alerting_profile_name + rules { + rule { + include_mode = var.msk_include_mode + delay_in_minutes = var.msk_delay_in_minutes + severity_level = "AVAILABILITY" + } + rule { + include_mode = var.msk_include_mode + delay_in_minutes = var.msk_delay_in_minutes + severity_level = "CUSTOM_ALERT" + } + rule { + include_mode = var.msk_include_mode + delay_in_minutes = var.msk_delay_in_minutes + severity_level = "ERRORS" + } + rule { + include_mode = var.msk_include_mode + delay_in_minutes = var.msk_delay_in_minutes + severity_level = "MONITORING_UNAVAILABLE" + } + rule { + include_mode = var.msk_include_mode + delay_in_minutes = var.msk_delay_in_minutes + severity_level = "PERFORMANCE" + } + rule { + include_mode = var.msk_include_mode + delay_in_minutes = var.msk_delay_in_minutes + severity_level = "RESOURCE_CONTENTION" + } + } +} \ No newline at end of file diff --git a/alerts/msk_alerts/msk_alerts_variables.tf b/alerts/msk_alerts/msk_alerts_variables.tf new file mode 100644 index 0000000..a8d770a --- /dev/null +++ b/alerts/msk_alerts/msk_alerts_variables.tf @@ -0,0 +1,407 @@ +# Variables for msk Alerting Profile +# Name of the alerting profile to be used for msk +# This typically refers to the specific configuration profile for monitoring and alerts in your system. +variable "msk_alerting_profile_name" { + type = string + description = "The name of the alerting profile for msk monitoring and notification configuration." +} + +# Mode for including msk instances in the alerting configuration. +# This could define a specific inclusion strategy, such as "ALL", "NONE", or "FILTERED". +variable "msk_include_mode" { + type = string + description = "The inclusion mode for msk instances in the alerting configuration (e.g., 'ALL', 'NONE', or 'FILTERED')." +} + +# Delay in minutes for triggering alerts after an event is detected. +# This ensures alerts are not sent prematurely during transient issues. +variable "msk_delay_in_minutes" { + type = string + description = "The delay (in minutes) before sending an alert for an event related to msk." +} + +# List of email IDs to receive alerts for msk events. +# This is typically used to notify relevant stakeholders or administrators. +variable "msk_email_id" { + type = list(string) + description = "A list of email addresses to send msk alerts to." +} + +# Variables for msk cpu utilization userspace +variable "msk_cpu_utilization_userspace_enabled" { + type = bool + description = "Enable or disable the cpu utilization userspace alert." +} + +variable "msk_cpu_utilization_userspace_event_entity_dimension_key" { + type = string + description = "Dimension key for the event entity of cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_summary" { + type = string + description = "Summary of the cpu utilization userspace alert." +} + +variable "msk_cpu_utilization_userspace_description" { + type = string + description = "Description of the cpu utilization userspace alert." +} + +variable "msk_cpu_utilization_userspace_davis_merge" { + type = bool + description = "Flag to enable or disable Davis merge for cpu utilization userspace events." +} + +variable "msk_cpu_utilization_userspace_event_type" { + type = string + description = "Type of the event for cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_title" { + type = string + description = "Title of the cpu utilization userspace event." +} + +variable "msk_cpu_utilization_userspace_model_properties_type" { + type = string + description = "Type of the model properties for cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_alert_condition" { + type = string + description = "Alert condition for cpu utilization userspace events." +} + +variable "msk_cpu_utilization_userspace_alert_on_no_data" { + type = bool + description = "Enable or disable alerts for no data in cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_dealerting_samples" { + type = string + description = "string of samples for dealerting in cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_samples" { + type = string + description = "string of samples for cpu utilization userspace events." +} + +variable "msk_cpu_utilization_userspace_threshold" { + type = string + description = "Threshold value for cpu utilization userspace events." +} + +variable "msk_cpu_utilization_userspace_violating_samples" { + type = string + description = "string of violating samples for cpu utilization userspace events." +} + +variable "msk_cpu_utilization_userspace_query_definition_type" { + type = string + description = "Query definition type for cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_aggregation" { + type = string + description = "Aggregation method for cpu utilization userspace events." +} + +variable "msk_cpu_utilization_userspace_metric_key" { + type = string + description = "Metric key for cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_dimension_key" { + type = string + description = "Dimension key for cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_dimension_value" { + type = string + description = "Dimension value for cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_entity_filter_condition1_type" { + type = string + description = "Type of the first entity filter condition for cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_entity_filter_condition1_operator" { + type = string + description = "Operator for the first entity filter condition for cpu utilization userspace." +} + +variable "msk_cpu_utilization_userspace_entity_filter_condition1_value" { + type = string + description = "Value of the first entity filter condition for cpu utilization userspace." +} +# Variables for msk cpu utilization kernel + +variable "msk_cpu_utilization_kernel_enabled" { + type = bool + description = "Enable or disable the msk cpu utilization kernel alert." +} + +variable "msk_cpu_utilization_kernel_event_entity_dimension_key" { + type = string + description = "Dimension key for the event entity of msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_summary" { + type = string + description = "Summary of the msk cpu utilization kernel alert." +} + +variable "msk_cpu_utilization_kernel_description" { + type = string + description = "Description of the msk cpu utilization kernel alert." +} + +variable "msk_cpu_utilization_kernel_davis_merge" { + type = bool + description = "Flag to enable or disable Davis merge for msk cpu utilization kernel events." +} + +variable "msk_cpu_utilization_kernel_event_type" { + type = string + description = "Type of the event for msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_title" { + type = string + description = "Title of the msk cpu utilization kernel event." +} + +variable "msk_cpu_utilization_kernel_model_properties_type" { + type = string + description = "Type of the model properties for msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_alert_condition" { + type = string + description = "Alert condition for msk cpu utilization kernel events." +} + +variable "msk_cpu_utilization_kernel_alert_on_no_data" { + type = bool + description = "Enable or disable alerts for no data in msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_dealerting_samples" { + type = string + description = "string of samples for dealerting in msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_samples" { + type = string + description = "string of samples for msk cpu utilization kernel events." +} + +variable "msk_cpu_utilization_kernel_threshold" { + type = string + description = "Threshold value for msk cpu utilization kernel events." +} + +variable "msk_cpu_utilization_kernel_violating_samples" { + type = string + description = "string of violating samples for msk cpu utilization kernel events." +} + +variable "msk_cpu_utilization_kernel_query_definition_type" { + type = string + description = "Query definition type for msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_aggregation" { + type = string + description = "Aggregation method for msk cpu utilization kernel events." +} + +variable "msk_cpu_utilization_kernel_metric_key" { + type = string + description = "Metric key for msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_dimension_key" { + type = string + description = "Dimension key for msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_dimension_value" { + type = string + description = "Dimension value for msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_entity_filter_condition1_type" { + type = string + description = "Type of the first entity filter condition for msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_entity_filter_condition1_operator" { + type = string + description = "Operator for the first entity filter condition for msk cpu utilization kernel." +} + +variable "msk_cpu_utilization_kernel_entity_filter_condition1_value" { + type = string + description = "Value of the first entity filter condition for msk cpu utilization kernel." +} +# Variables for msk root disk usage +variable "msk_rootdisk_usage_enabled" { + type = bool + description = "Enable or disable the msk root disk usage alert." +} + +variable "msk_rootdisk_usage_event_entity_dimension_key" { + type = string + description = "Dimension key for the event entity of msk root disk usage." +} + +variable "msk_rootdisk_usage_summary" { + type = string + description = "Summary of the msk root disk usage alert." +} + +variable "msk_rootdisk_usage_description" { + type = string + description = "Description of the msk root disk usage alert." +} + +variable "msk_rootdisk_usage_davis_merge" { + type = bool + description = "Flag to enable or disable Davis merge for msk root disk usage events." +} + +variable "msk_rootdisk_usage_event_type" { + type = string + description = "Type of the event for msk root disk usage." +} + +variable "msk_rootdisk_usage_title" { + type = string + description = "Title of the msk root disk usage event." +} + +variable "msk_rootdisk_usage_model_properties_type" { + type = string + description = "Type of the model properties for msk root disk usage." +} + +variable "msk_rootdisk_usage_alert_condition" { + type = string + description = "Alert condition for msk root disk usage events." +} + +variable "msk_rootdisk_usage_alert_on_no_data" { + type = bool + description = "Enable or disable alerts for no data in msk root disk usage." +} + +variable "msk_rootdisk_usage_dealerting_samples" { + type = string + description = "string of samples for dealerting in msk root disk usage." +} + +variable "msk_rootdisk_usage_samples" { + type = string + description = "string of samples for msk root disk usage events." +} + +variable "msk_rootdisk_usage_threshold" { + type = string + description = "Threshold value for msk root disk usage events." +} + +variable "msk_rootdisk_usage_violating_samples" { + type = string + description = "string of violating samples for msk root disk usage events." +} + +variable "msk_rootdisk_usage_query_definition_type" { + type = string + description = "Query definition type for msk root disk usage." +} + +variable "msk_rootdisk_usage_aggregation" { + type = string + description = "Aggregation method for msk root disk usage events." +} + +variable "msk_rootdisk_usage_metric_key" { + type = string + description = "Metric key for msk root disk usage." +} + +variable "msk_rootdisk_usage_dimension_key" { + type = string + description = "Dimension key for msk root disk usage." +} + +variable "msk_rootdisk_usage_dimension_value" { + type = string + description = "Dimension value for msk root disk usage." +} + +variable "msk_rootdisk_usage_entity_filter_condition1_type" { + type = string + description = "Type of the first entity filter condition for msk root disk usage." +} + +variable "msk_rootdisk_usage_entity_filter_condition1_operator" { + type = string + description = "Operator for the first entity filter condition for msk root disk usage." +} + +variable "msk_rootdisk_usage_entity_filter_condition1_value" { + type = string + description = "Value of the first entity filter condition for msk root disk usage." +} + +# Variables for Dynatrace Email Notification +variable "msk_email_notification_enabled" { + type = bool + description = "Enable or disable the Dynatrace email notification." +} + +variable "msk_email_notification_name" { + type = string + description = "Name of the Dynatrace email notification." +} + +variable "msk_email_subject" { + type = string + description = "Subject of the Dynatrace email notifications." +} + +variable "msk_notify_closed_problem" { + type = bool + description = "Enable or disable notifications for closed problems." +} + +# Variables for msk Slack Notification +variable "msk_slack_notification_enabled" { + type = bool + description = "Enable or disable the Dynatrace Slack notification." +} + +variable "msk_slack_notification_name" { + type = string + description = "Name of the Dynatrace Slack notification." +} + +variable "msk_slack_url" { + type = string + description = "Slack webhook URL for Dynatrace notifications." +} + +variable "msk_channel_name" { + type = string + description = "Slack channel name for Dynatrace notifications." +} + +variable "msk_slack_message" { + type = string + description = "Message template for Dynatrace Slack notifications." +} diff --git a/alerts/msk_alerts/msk_metrics_events.tf b/alerts/msk_alerts/msk_metrics_events.tf new file mode 100644 index 0000000..5bd8c02 --- /dev/null +++ b/alerts/msk_alerts/msk_metrics_events.tf @@ -0,0 +1,141 @@ +resource "dynatrace_metric_events" "msk_cpu_utilization_userspace" { + enabled = var.msk_cpu_utilization_userspace_enabled + event_entity_dimension_key = var.msk_cpu_utilization_userspace_event_entity_dimension_key + summary = var.msk_cpu_utilization_userspace_summary + event_template { + description = var.msk_cpu_utilization_userspace_description + davis_merge = var.msk_cpu_utilization_userspace_davis_merge + event_type = var.msk_cpu_utilization_userspace_event_type + title = var.msk_cpu_utilization_userspace_title + } + model_properties { + type = var.msk_cpu_utilization_userspace_model_properties_type + alert_condition = var.msk_cpu_utilization_userspace_alert_condition + alert_on_no_data = var.msk_cpu_utilization_userspace_alert_on_no_data + dealerting_samples = var.msk_cpu_utilization_userspace_dealerting_samples + samples = var.msk_cpu_utilization_userspace_samples + threshold = var.msk_cpu_utilization_userspace_threshold + violating_samples = var.msk_cpu_utilization_userspace_violating_samples + } + query_definition { + type = var.msk_cpu_utilization_userspace_query_definition_type + aggregation = var.msk_cpu_utilization_userspace_aggregation + metric_key = var.msk_cpu_utilization_userspace_metric_key + dimension_filter { + filter { + dimension_key = var.msk_cpu_utilization_userspace_dimension_key + dimension_value = var.msk_cpu_utilization_userspace_dimension_value + } + } + entity_filter { + dimension_key = var.msk_cpu_utilization_userspace_dimension_key + conditions { + condition { + type = var.msk_cpu_utilization_userspace_entity_filter_condition1_type + operator = var.msk_cpu_utilization_userspace_entity_filter_condition1_operator + value = var.msk_cpu_utilization_userspace_entity_filter_condition1_value + } + } + } + } +} +resource "dynatrace_metric_events" "msk_cpu_utilization_kernel" { + enabled = var.msk_cpu_utilization_kernel_enabled + event_entity_dimension_key = var.msk_cpu_utilization_kernel_event_entity_dimension_key + summary = var.msk_cpu_utilization_kernel_summary + event_template { + description = var.msk_cpu_utilization_kernel_description + davis_merge = var.msk_cpu_utilization_kernel_davis_merge + event_type = var.msk_cpu_utilization_kernel_event_type + title = var.msk_cpu_utilization_kernel_title + } + model_properties { + type = var.msk_cpu_utilization_kernel_model_properties_type + alert_condition = var.msk_cpu_utilization_kernel_alert_condition + alert_on_no_data = var.msk_cpu_utilization_kernel_alert_on_no_data + dealerting_samples = var.msk_cpu_utilization_kernel_dealerting_samples + samples = var.msk_cpu_utilization_kernel_samples + threshold = var.msk_cpu_utilization_kernel_threshold + violating_samples = var.msk_cpu_utilization_kernel_violating_samples + } + query_definition { + type = var.msk_cpu_utilization_kernel_query_definition_type + aggregation = var.msk_cpu_utilization_kernel_aggregation + metric_key = var.msk_cpu_utilization_kernel_metric_key + dimension_filter { + filter { + dimension_key = var.msk_cpu_utilization_kernel_dimension_key + dimension_value = var.msk_cpu_utilization_kernel_dimension_value + } + } + entity_filter { + dimension_key = var.msk_cpu_utilization_kernel_dimension_key + conditions { + condition { + type = var.msk_cpu_utilization_kernel_entity_filter_condition1_type + operator = var.msk_cpu_utilization_kernel_entity_filter_condition1_operator + value = var.msk_cpu_utilization_kernel_entity_filter_condition1_value + } + } + } + } +} +resource "dynatrace_metric_events" "msk_rootdisk_usage" { + enabled = var.msk_rootdisk_usage_enabled + event_entity_dimension_key = var.msk_rootdisk_usage_event_entity_dimension_key + summary = var.msk_rootdisk_usage_summary + event_template { + description = var.msk_rootdisk_usage_description + davis_merge = var.msk_rootdisk_usage_davis_merge + event_type = var.msk_rootdisk_usage_event_type + title = var.msk_rootdisk_usage_title + } + model_properties { + type = var.msk_rootdisk_usage_model_properties_type + alert_condition = var.msk_rootdisk_usage_alert_condition + alert_on_no_data = var.msk_rootdisk_usage_alert_on_no_data + dealerting_samples = var.msk_rootdisk_usage_dealerting_samples + samples = var.msk_rootdisk_usage_samples + threshold = var.msk_rootdisk_usage_threshold + violating_samples = var.msk_rootdisk_usage_violating_samples + } + query_definition { + type = var.msk_rootdisk_usage_query_definition_type + aggregation = var.msk_rootdisk_usage_aggregation + metric_key = var.msk_rootdisk_usage_metric_key + dimension_filter { + filter { + dimension_key = var.msk_rootdisk_usage_dimension_key + dimension_value = var.msk_rootdisk_usage_dimension_value + } + } + entity_filter { + dimension_key = var.msk_rootdisk_usage_dimension_key + conditions { + condition { + type = var.msk_rootdisk_usage_entity_filter_condition1_type + operator = var.msk_rootdisk_usage_entity_filter_condition1_operator + value = var.msk_rootdisk_usage_entity_filter_condition1_value + } + } + } + } +} +resource "dynatrace_email_notification" "msk_email_alerts" { + active = var.msk_email_notification_enabled + name = var.msk_email_notification_name + profile = dynatrace_alerting.cosmos-msk-alerting-profile.id + subject = var.msk_email_subject + to = var.msk_email_id + notify_closed_problems = var.msk_notify_closed_problem + body = "{ProblemDetailsHTML}" +} + +resource "dynatrace_slack_notification" "msk_slack_alerts" { + active = var.msk_slack_notification_enabled + name = var.msk_slack_notification_name + profile = dynatrace_alerting.cosmos-msk-alerting-profile.id + url = var.msk_slack_url + channel = var.msk_channel_name + message = var.msk_slack_message +} diff --git a/alerts/msk_alerts/providers.tf b/alerts/msk_alerts/providers.tf new file mode 100644 index 0000000..59ee8ed --- /dev/null +++ b/alerts/msk_alerts/providers.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + dynatrace = { + version = "~> 1.0" + source = "dynatrace-oss/dynatrace" + } + } +} \ No newline at end of file