diff --git a/aws/eks/cloudwatch_alarms.tf b/aws/eks/cloudwatch_alarms.tf index 4670222b0..d3888f7a1 100644 --- a/aws/eks/cloudwatch_alarms.tf +++ b/aws/eks/cloudwatch_alarms.tf @@ -176,7 +176,7 @@ resource "aws_cloudwatch_metric_alarm" "admin-pods-high-cpu-warning" { treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-admin" + Service = var.env == "production" ? "admin" : "notify-admin" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -197,7 +197,7 @@ resource "aws_cloudwatch_metric_alarm" "api-pods-high-cpu-warning" { treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-api" + Service = var.env == "production" ? "api" : "notify-api" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -218,7 +218,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-primary-pods-high-cpu-warning" { treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-celery-primary" + Service = var.env == "production" ? "celery-primary" : "notify-celery-primary" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -239,7 +239,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-scalable-pods-high-cpu-warning" { treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-celery-scalable" + Service = var.env == "production" ? "celery-scalable" : "notify-celery-scalable" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -260,7 +260,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-sms-pods-high-cpu-warning" { treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-celery-sms" + Service = var.env == "production" ? "celery-sms" : "notify-celery-sms" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -282,7 +282,7 @@ resource "aws_cloudwatch_metric_alarm" "admin-pods-high-memory-warning" { treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-admin" + Service = var.env == "production" ? "admin" : "notify-admin" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -303,7 +303,7 @@ resource "aws_cloudwatch_metric_alarm" "api-pods-high-memory-warning" { treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-api" + Service = var.env == "production" ? "api" : "notify-api" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -324,7 +324,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-primary-pods-high-memory-warning" treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-celery-primary" + Service = var.env == "production" ? "celery-primary" : "notify-celery-primary" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -345,7 +345,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-sms-pods-high-memory-warning" { treat_missing_data = "missing" dimensions = { Namespace = "notification-canada-ca" - Service = "notify-celery-sms" + Service = var.env == "production" ? "celery-sms" : "notify-celery-sms" ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name } } @@ -478,7 +478,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-primary-replicas-unavailable" { dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-celery-primary" + deployment = var.env == "production" ? "celery-primary" : "notify-celery-primary" } } } @@ -507,7 +507,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-scalable-replicas-unavailable" { dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-celery-scalable" + deployment = var.env == "production" ? "celery-scalable" : "notify-celery-scalable" } } } @@ -535,7 +535,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-beat-replicas-unavailable" { dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-celery-beat" + deployment = var.env == "production" ? "celery-beat" : "notify-celery-beat" } } } @@ -563,7 +563,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-sms-replicas-unavailable" { dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-celery-sms" + deployment = var.env == "production" ? "celery-sms" : "notify-celery-sms" } } } @@ -591,7 +591,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-email-send-primary-replicas-unava dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-celery-email-send-primary" + deployment = var.env == "production" ? "celery-email-send-primary" : "notify-celery-email-send-primary" } } } @@ -620,7 +620,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-email-send-scalable-replicas-unav dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-celery-email-send-scalable" + deployment = var.env == "production" ? "celery-email-send-scalable" : "notify-celery-email-send-scalable" } } } @@ -648,7 +648,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-sms-send-primary-replicas-unavail dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-celery-sms-send-primary" + deployment = var.env == "production" ? "celery-sms-send-primary" : "notify-celery-sms-send-primary" } } } @@ -677,7 +677,7 @@ resource "aws_cloudwatch_metric_alarm" "celery-sms-send-scalable-replicas-unavai dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-celery-sms-send-scalable" + deployment = var.env == "production" ? "celery-sms-send-scalable" : "notify-celery-sms-send-scalable" } } } @@ -705,7 +705,7 @@ resource "aws_cloudwatch_metric_alarm" "admin-replicas-unavailable" { dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-admin" + deployment = var.env == "production" ? "admin" : "notify-admin" } } } @@ -733,7 +733,7 @@ resource "aws_cloudwatch_metric_alarm" "api-replicas-unavailable" { dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-api" + deployment = var.env == "production" ? "api" : "notify-api" } } } @@ -761,7 +761,7 @@ resource "aws_cloudwatch_metric_alarm" "documentation-replicas-unavailable" { dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-documentation" + deployment = var.env == "production" ? "documentation" : "notify-documentation" } } } @@ -789,7 +789,7 @@ resource "aws_cloudwatch_metric_alarm" "document-download-api-replicas-unavailab dimensions = { ClusterName = aws_eks_cluster.notification-canada-ca-eks-cluster.name namespace = var.notify_k8s_namespace - deployment = "notify-document-download" + deployment = var.env == "production" ? "document-download" : "notify-document-download" } } } diff --git a/aws/eks/cloudwatch_log.tf b/aws/eks/cloudwatch_log.tf index 08b72c95a..d6e84a3ed 100644 --- a/aws/eks/cloudwatch_log.tf +++ b/aws/eks/cloudwatch_log.tf @@ -98,7 +98,7 @@ resource "aws_cloudwatch_log_metric_filter" "bounce-rate-critical" { resource "aws_cloudwatch_log_metric_filter" "api-evicted-pods" { count = var.cloudwatch_enabled ? 1 : 0 name = "api-evicted-pods" - pattern = "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-api-*\") }" + pattern = var.env == "production" ? "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"api-*\") }" : "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-api-*\") }" log_group_name = aws_cloudwatch_log_group.notification-canada-ca-eks-prometheus-logs[0].name metric_transformation { @@ -111,7 +111,7 @@ resource "aws_cloudwatch_log_metric_filter" "api-evicted-pods" { resource "aws_cloudwatch_log_metric_filter" "celery-evicted-pods" { count = var.cloudwatch_enabled ? 1 : 0 name = "celery-evicted-pods" - pattern = "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-celery-*\") }" + pattern = var.env == "production" ? "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"celery-*\") }" : "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-celery-*\") }" log_group_name = aws_cloudwatch_log_group.notification-canada-ca-eks-prometheus-logs[0].name metric_transformation { @@ -124,7 +124,7 @@ resource "aws_cloudwatch_log_metric_filter" "celery-evicted-pods" { resource "aws_cloudwatch_log_metric_filter" "admin-evicted-pods" { count = var.cloudwatch_enabled ? 1 : 0 name = "admin-evicted-pods" - pattern = "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-admin-*\") }" + pattern = var.env == "production" ? "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"admin-*\") }" : "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-admin-*\") }" log_group_name = aws_cloudwatch_log_group.notification-canada-ca-eks-prometheus-logs[0].name metric_transformation { @@ -137,7 +137,7 @@ resource "aws_cloudwatch_log_metric_filter" "admin-evicted-pods" { resource "aws_cloudwatch_log_metric_filter" "document-download-evicted-pods" { count = var.cloudwatch_enabled ? 1 : 0 name = "document-download-evicted-pods" - pattern = "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-document-download-*\") }" + pattern = var.env == "production" ? "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"document-download-*\") }" : "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-document-download-*\") }" log_group_name = aws_cloudwatch_log_group.notification-canada-ca-eks-prometheus-logs[0].name metric_transformation { @@ -150,7 +150,7 @@ resource "aws_cloudwatch_log_metric_filter" "document-download-evicted-pods" { resource "aws_cloudwatch_log_metric_filter" "documentation-evicted-pods" { count = var.cloudwatch_enabled ? 1 : 0 name = "documentation-evicted-pods" - pattern = "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-documentation-*\") }" + pattern = var.env == "production" ? "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"documentation-*\") }" : "{ ($.reason = \"Evicted\") && ($.kube_pod_status_reason = 1) && ($.pod = \"notify-documentation-*\") }" log_group_name = aws_cloudwatch_log_group.notification-canada-ca-eks-prometheus-logs[0].name metric_transformation { diff --git a/aws/eks/cloudwatch_queries.tf b/aws/eks/cloudwatch_queries.tf index d3e7f707a..c3e90c2df 100644 --- a/aws/eks/cloudwatch_queries.tf +++ b/aws/eks/cloudwatch_queries.tf @@ -1,3 +1,12 @@ +locals { + celery_name = var.env == "production" ? "celery" : "notify-celery" + admin_name = var.env == "production" ? "admin" : "notify-admin" + api_name = var.env == "production" ? "api" : "notify-api" + document_download_name = var.env == "production" ? "document-download" : "notify-document-download" + documentation_name = var.env == "production" ? "documentation" : "notify-documentation" + +} + ################################ CELERY FOLDER ################################ resource "aws_cloudwatch_query_definition" "celery-errors" { @@ -10,7 +19,7 @@ resource "aws_cloudwatch_query_definition" "celery-errors" { query_string = <\d+s)/ | stats count() by retry_duration @@ -196,7 +205,7 @@ resource "aws_cloudwatch_query_definition" "admin-50X-errors" { query_string = <