
resource "datadog_monitor" "DtfKinesisIteratorAge" {
  name = "DAPD monitor: {{streamname.name}} kinesis iterator age is too high"
  type = "query alert"

  message = <<EOT
{{#is_alert}}
${local.alert_message_env_title} amount of ScraperSpotifyPlaylistProcessed is < 12000 for the last 6 hours.
{{/is_alert}}

{{#is_recovery}}
${local.alert_message_env_title} amount of ScraperSpotifyPlaylistProcessed is back to normal values.
{{/is_recovery}}
${local.alert_channels}
EOT

  query = "avg(last_30m):max:aws.kinesis.get_records_iterator_age_milliseconds{*} by {streamname} > 600000"


  evaluation_delay    = 600 // minimum recommended value for GCP metrics 300
  require_full_window = true
  notify_no_data      = true
  no_data_timeframe   = 30
  renotify_interval   = 1440
  include_tags        = true
  restricted_roles    = [data.datadog_role.datadog_admin_role.id]

  tags = local.common_tags
}
