From 1001a58e72722c04c7dfd058904c189f273026ff Mon Sep 17 00:00:00 2001 From: MOHAMMED-ho Date: Fri, 15 Nov 2024 09:25:21 +0000 Subject: [PATCH] amending Readme.md (#3) (#14) * amending Readme.md (#3) adding s3 dashboard module renaming variable.tf CCL-898 json config updating visual config updating width of tiles adding .github adding .github adding .github CCL-898 golden dashboards CCL-898 added mks dashboards CCL-898 latest CCL-898-test latest classic dashboards adding varibales file amending README file adding varibles correcting readme file removing .ided/,DSstore etc removing .ided/,DSstore etc moving terraform files into root folder chaning workflow name chaning workflow name adding cloudfront and ES dashbaords (#5) adding new dashboards adding new dashboards adding cloudfront and ES dashbaords (#6) adding new dashboards adding new dashboards adding new dashboards adding new dashboards adding new dashboards adding new dashboards adding new dashboards adding new dashboards CCL-827added dyntarce metrics and anomolies revert adding variables adding alerts and events.tf * adding variables * adding variables * Delete files/rds.json * adding alerts config * removing mgmt zone * adding variable description --- dynatrace_alerts.tf | 50 ++++++++ dynatrace_metric_events.tf | 51 ++++++++ variables.tf | 233 ++++++++++++++++++++++++++++++++----- 3 files changed, 304 insertions(+), 30 deletions(-) create mode 100644 dynatrace_alerts.tf create mode 100644 dynatrace_metric_events.tf diff --git a/dynatrace_alerts.tf b/dynatrace_alerts.tf new file mode 100644 index 0000000..7bdd3d2 --- /dev/null +++ b/dynatrace_alerts.tf @@ -0,0 +1,50 @@ +resource "dynatrace_alerting" "dynatrace_alerting_profile" { + name = var.alerting_profile_name + filters { + filter { + custom { + description { + operator = var.operator + value = var.value + case_sensitive = var.case_sensitive + enabled = var.enabled + } + title { + operator = var.operator + value = var.value + case_sensitive = var.case_sensitive + enabled = var.enabled + + } + + } + } + } + rules { + rule { + include_mode = var.include_mode + tags = var.tags + delay_in_minutes = var.delay_in_minutes + severity_level = var.severity_level + } + } +} + +resource "dynatrace_email_notification" "dynatrace_email_alerts" { + active = var.email_notification_enabled + name = var.email_notification_name + profile = dynatrace_alerting.dynatrace_alerting_profile.id + subject = var.email_subject + to = var.email_id + notify_closed_problems = var.notify_closed_problem + body = "{ProblemDetailsHTML}" +} + +resource "dynatrace_slack_notification" "dynatrace_slack_alerts" { + active = var.slack_notification_enabled + name = var.slack_notification_name + profile = dynatrace_alerting.dynatrace_alerting_profile.id + url = var.slack_url + channel = var.channel_name + message = var.slack_message +} \ No newline at end of file diff --git a/dynatrace_metric_events.tf b/dynatrace_metric_events.tf new file mode 100644 index 0000000..1c4f07f --- /dev/null +++ b/dynatrace_metric_events.tf @@ -0,0 +1,51 @@ +resource "dynatrace_metric_events" "dynatrace_readcapacityunitssum" { + enabled = var.tenant_vars.enabled + event_entity_dimension_key = var.tenant_vars.event_entity_dimension_key + summary = var.tenant_vars.summary + event_template { + description = var.tenant_vars.description + davis_merge = var.tenant_vars.davis_merge + event_type = var.tenant_vars.event_type + title = var.tenant_vars.title + } + model_properties { + type = var.tenant_vars.model_properties_type + alert_condition = var.tenant_vars.alert_condition + alert_on_no_data = var.tenant_vars.alert_on_no_data + dealerting_samples = var.tenant_vars.dealerting_samples + samples = var.tenant_vars.samples + threshold = var.tenant_vars.threshold + violating_samples = var.tenant_vars.violating_samples + } + query_definition { + type = var.tenant_vars.query_definition_type + aggregation = var.tenant_vars.aggregation + metric_key = var.tenant_vars.metric_key + dimension_filter { + filter { + dimension_key = var.tenant_vars.dimension_key + dimension_value = var.tenant_vars.dimension_value + } + } + entity_filter { + dimension_key = var.tenant_vars.dimension_key + conditions { + condition { + type = var.tenant_vars.entity_filter_condition1_type + operator = var.tenant_vars.entity_filter_condition1_operator + value = var.tenant_vars.entity_filter_condition1_value + } + condition { + type = var.tenant_vars.entity_filter_condition2_type + operator = var.tenant_vars.entity_filter_condition2_operator + value = var.tenant_vars.entity_filter_condition2_value + } + # condition { + # type = "HOST_GROUP_NAME" re-visit when we need host group + # operator = "EQUALS" + # value = "HOST-42FDD00356069724" + # } + } + } + } +} diff --git a/variables.tf b/variables.tf index d74cb8c..37d9bdf 100644 --- a/variables.tf +++ b/variables.tf @@ -1,94 +1,267 @@ - variable "tenant_vars" { - type = any + type = any } variable "s3_dashboard_name" { - type = string + type = string + description = "The name of the dashboard for monitoring S3 metrics." } + variable "s3_owner_name" { - type = string + type = string + description = "The owner of the S3 monitoring configuration." } + variable "s3_shared" { - type = string + type = string + description = "Indicates whether the S3 dashboard is shared. Possible values could be 'true' or 'false'." } + variable "s3_preset" { - type = bool + type = bool + description = "Indicates if a preset configuration is used for the S3 dashboard, Possible values could be 'true' or 'false' " } + variable "rds_dashboard_name" { - type = string + type = string + description = "The name of the dashboard for monitoring RDS metrics." } + variable "rds_owner_name" { - type = string + type = string + description = "The owner of the RDS monitoring configuration." } + variable "rds_shared" { - type = string + type = string + description = "Indicates whether the RDS dashboard is shared. Possible values could be 'true' or 'false'." } + variable "rds_preset" { - type = bool + type = bool + description = "Indicates if a preset configuration is used for the RDS dashboard, Possible values could be 'true' or 'false'" } + variable "msk_dashboard_name" { - type = string + type = string + description = "The name of the dashboard for monitoring MSK metrics." } + variable "msk_owner_name" { - type = string + type = string + description = "The owner of the MSK monitoring configuration." } + variable "msk_shared" { - type = string + type = string + description = "Indicates whether the MSK dashboard is shared. Possible values could be 'true' or 'false'." } + variable "msk_preset" { - type = bool + type = bool + description = "Indicates if a preset configuration is used for the MSK dashboard,Possible values could be 'true' or 'false' " } + variable "cloudfront_dashboard_name" { - type = string + type = string + description = "The name of the dashboard for monitoring CloudFront metrics." } + variable "cloudfront_owner_name" { - type = string + type = string + description = "The owner of the CloudFront monitoring configuration." } + variable "cloudfront_shared" { - type = string + type = string + description = "Indicates whether the CloudFront dashboard is shared. Possible values could be 'true' or 'false'." } + variable "cloudfront_preset" { - type = bool + type = bool + description = "Indicates if a preset configuration is used for the CloudFront dashboard, Possible values could be 'true' or 'false'" } + variable "elasticsearch_dashboard_name" { - type = string + type = string + description = "The name of the dashboard for monitoring Elasticsearch metrics." } + variable "elasticsearch_owner_name" { - type = string + type = string + description = "The owner of the Elasticsearch monitoring configuration." } + variable "elasticsearch_shared" { - type = string + type = string + description = "Indicates whether the Elasticsearch dashboard is shared. Possible values could be 'true' or 'false'." } + variable "elasticsearch_preset" { - type = bool + type = bool + description = "Indicates if a preset configuration is used for the Elasticsearch dashboard,Possible values could be 'true' or 'false'Possible values could be 'true' or 'false'" } variable "elasticache_owner_name" { - type = string + type = string + description = "The owner of the ElastiCache monitoring configuration." } + variable "elasticache_shared" { - type = string + type = string + description = "Indicates whether the ElastiCache dashboard is shared. Possible values could be 'true' or 'false'." } variable "elasticache_dashboard_name" { - type = string + type = string + description = "The name of the dashboard for monitoring ElastiCache metrics." } variable "elasticache_preset" { - type = bool + type = bool + description = "Indicates if a preset configuration is used for the ElastiCache dashboard,Possible values could be 'true' or 'false' " } variable "dynamodb_owner_name" { - type = string + type = string + description = "The owner of the DynamoDB monitoring configuration." } + variable "dynamodb_shared" { - type = string + type = string + description = "Indicates whether the DynamoDB dashboard is shared. Possible values could be 'true' or 'false'." } variable "dynamodb_dashboard_name" { - type = string + type = string + description = "The name of the dashboard for monitoring DynamoDB metrics." } variable "dynamodb_preset" { - type = bool + type = bool + description = "Indicates if a preset configuration is used for the DynamoDB dashboard, Possible values could be 'true' or 'false' " +} + +variable "alerting_profile_name" { + type = string + description = "Name of the alerting profile." +} + +variable "email_notification_name" { + type = string + description = "Name of the email notification configuration." +} + +variable "email_subject" { + type = string + description = "Subject line for email notifications." +} + +variable "email_id" { + type = list(string) + description = "List of email addresses to receive notifications." +} + +variable "slack_url" { + type = string + description = "Webhook URL for sending Slack notifications." +} + +variable "channel_name" { + type = string + description = "Slack channel name to post notifications." +} + +variable "slack_message" { + type = string + description = "Message content for Slack notifications." } + +variable "email_notification_enabled" { + type = bool + description = "Indicates if email notifications are enabled." +} + +variable "notify_closed_problem" { + type = bool + description = "Indicates if notifications should be sent for closed problems." +} + +variable "slack_notification_enabled" { + type = bool + description = "Indicates if Slack notifications are enabled." +} + +variable "slack_notification_name" { + type = string + description = "Name of the Slack notification configuration." +} + +variable "operator" { + type = string + description = "Operator used in condition evaluations (e.g., EQUALS, GREATER_THAN)." +} + +variable "value" { + type = string + description = "Value used for condition evaluations." +} + +variable "case_sensitive" { + type = bool + description = "Indicates if the condition evaluation is case-sensitive." +} + +variable "enabled" { + type = bool + description = "Indicates if the configuration or rule is enabled." +} + +variable "include_mode" { + type = string + description = "Mode for including entities or configurations." +} + +variable "tags" { + type = list(string) + description = "List of tags associated with the configuration." +} + +variable "severity_level" { + type = string + description = "Severity level of alerts (e.g., CRITICAL, WARNING)." +} + +variable "management_zone_name" { + type = string + description = "Name of the management zone to which the configuration belongs." +} + +variable "rule_type" { + type = string + description = "Type of rule to apply (e.g., METRIC, EVENT)." +} + +variable "entity_selector" { + type = string + description = "Entity selector for targeted monitoring or alerting." +} + +variable "entity_type" { + type = string + description = "Type of the monitored entity (e.g., HOST, PROCESS_GROUP)." +} + +variable "key" { + type = string + description = "Key used in key-value pairs for configuration or tagging." +} + +variable "string_value" { + type = string + description = "String value used in conditions or configurations." +} + +variable "delay_in_minutes" { + type = string + description = "Delay duration in minutes for certain operations or alerts." +} \ No newline at end of file