# Source: bosh-exporter
---

- type: replace
  path: /instance_groups/name=prometheus2/jobs/name=prometheus2/properties/prometheus/custom_rules?/-
  value:
    name: BoshHighCPUUtilisation
    rules:
      - record: "bosh_job:bosh_job_cpu:avg1h"
        expr: avg_over_time(bosh_job_cpu_sys{bosh_job_name!="diego-cell",bosh_job_name!="concourse"}[1h]) + avg_over_time(bosh_job_cpu_user{bosh_job_name!="diego-cell",bosh_job_name!="concourse"}[1h]) + avg_over_time(bosh_job_cpu_wait{bosh_job_name!="diego-cell",bosh_job_name!="concourse"}[1h])

      - &alert
        alert: BoshHighCPUUtilisation_Warning
        expr: "bosh_job:bosh_job_cpu:avg1h > 70"
        labels:
          severity: warning
          notify: email
        annotations:
          summary: "High cpu utilisation on {{ $labels.bosh_job_name }}/{{ $labels.bosh_job_index }}"
          description: "{{ $labels.bosh_job_name }}/{{ $labels.bosh_job_index }} CPU utilisation was over {{ $value | printf \"%.0f\" }}% in the last hour on average"

      - <<: *alert
        alert: BoshHighCPUUtilisation_Critical
        expr: "bosh_job:bosh_job_cpu:avg1h > 90"
        labels:
          severity: critical
          notify: email

Migrate "EC2 high CPU utilization" monitor to Prometheus
Migrate "EC2 high CPU utilization" monitor to Prometheus

Original DataDog monitor:
avg:aws.ec2.cpuutilization{deploy_env:prod,!bosh-job:diego-cell} by {bosh-job,bosh-index}

The CPU utilisation is now provided by the bosh-exporter, but exposed as a
breakdown of bosh_job_cpu_sys, bosh_job_cpu_user and bosh_job_cpu_wait.
