resource "datadog_monitor" "kafka_connector_content_review_throughput" {
  count   = 0 # set to 1 to enable the monitor
  name    = "${var.environment}-${var.service_name}-throughput-monitor"
  type    = "metric alert"
  message = "Incoming data level has dropped in connector's topics for the last 24h. Notify: ${var.notification_endpoints}"

  query = "sum(last_1d):avg:aws.kafka.messages_in_per_sec{environment:${var.environment},topic:cdc.contentreview.*} by {topic} * 60 * 60 * 24 < 50"

  monitor_thresholds {
    critical          = 50
    warning           = 100
    warning_recovery  = 110
    critical_recovery = 60
  }

  notify_no_data      = true
  notify_audit        = false
  renotify_interval   = 60
  timeout_h           = 0
  require_full_window = false
  no_data_timeframe   = 2880 # in minutes

  tags = [
    "environment:${var.environment}",
    "service_name:${var.service_name}",
  ]
}
