# Source: firehose-exporter
---
- type: replace
  path: /instance_groups/name=prometheus2/jobs/name=prometheus2/properties/prometheus/custom_rules?/-
  value:
    name: DiegoCellRepMemoryCapacity
    rules:
      - record: rep_memory_capacity_pct:avg5m
        expr: >
          100 *
          sum(avg_over_time(firehose_value_metric_rep_capacity_remaining_memory{environment="((metrics_environment))"}[5m])) by (environment) /
          sum(avg_over_time(firehose_value_metric_rep_capacity_total_memory{environment="((metrics_environment))"}[5m])) by (environment)
      - &alert
        alert: DiegoCellRepMemoryCapacity_Warning
        expr:  rep_memory_capacity_pct:avg5m < 35
        for: 2h
        labels:
          severity: warning
          notify: email
        annotations:
          summary: Rep low free memory capacity
          description: >
            Low free memory {{ $value | printf "%.0f" }}% for the advertised rep memory capacity
            in the last 2 hours on average.
            Review if we need to scale...
          url: https://team-manual.cloud.service.gov.uk/architecture_decision_records/ADR021-cell-capacity-assignment-2/#decision

      - <<: *alert
        alert: DiegoCellRepMemoryCapacity_Critical
        expr: rep_memory_capacity_pct:avg5m < 33
        labels:
          severity: critical
          notify: email

Migrate alert "rep memoty capacity" to Prometheus
Migrate alert "rep memoty capacity" to Prometheus

Original datadog monitor:

avg(last_2h):(ewma_5(sum:cf.rep.CapacityRemainingMemory/sum:cf.rep.CapacityTotalMemory))

from terraform/datadog/cell.tf rep-memory-capacity
