# Source: cloudwatch-exporter
---

- type: replace
  path: /instance_groups/name=prometheus2/jobs/name=prometheus2/properties/prometheus/custom_rules?/-
  value:
    name: RDSCPUCreditsLow
    rules:
      - &alert
        alert: RDSCPUCreditsLow_Warning
        expr: avg_over_time(aws_rds_cpucreditbalance_minimum[30m]) <= 20
        labels:
          severity: warning
          notify: email
        annotations:
          summary: "RDS CPU credits are low on {{ $labels.tag_Name }}"
          description: "RDS instance {{ $labels.tag_Name }} has only {{ $value | printf \"%.0f\" }} CPU credits left and may perform badly."
          url: "https://team-manual.cloud.service.gov.uk/incident_management/responding_to_alerts/#cpu-credits"

      - <<: *alert
        alert: RDSCPUCreditsLow_Critical
        expr: avg_over_time(aws_rds_cpucreditbalance_minimum[30m]) <= 1
        labels:
          severity: critical
          notify: email

Migrate "RDS CPU credits" monitor to Prometheus
Migrate "RDS CPU credits" monitor to Prometheus

Original DataDog monitor:
avg(last_30m):avg:aws.rds.cpucredit_balance{deploy_env:prod,!created_by:aws_rds_service_broker} by {dbinstanceidentifier} <= 1

The cloudwatch-exporter only collects this information for the system
databases, so we don't need to filter out the tenant ones.
