groups:
- name: "StreamSmart On-Air Alerts"
  rules:
  - alert: "NoSegmentsReceived"
    annotations:
      description: "The rate of received segments has been less than 1 for the last 1m. Check status and upstream system."
      summary: "No segments are being received."
    expr: "rate(imax_ssoa_received_segment[30s]) < 1"
    for: "1m"
    labels:
      severity: "critical"
  - alert: "NoManifestsReceived"
    annotations:
      description: "The rate of received manifests has been less than 1 for the last 1m. Check status and upstream system."
      summary: "No manifests are being received."
    expr: "rate(imax_ssoa_received_manifest[30s]) < 1"
    for: "1m"
    labels:
      severity: "critical"
  - alert: "SegmentsStuck"
    annotations:
      description: "The rate of sent segments is significantly lower than received segments for the last 1m. Received: {{ $value | printf \"%.2f\" }}/s (using ratio rule example). Potential processing failure or backlog."
      summary: "Segment forwarding issue detected."
    expr: "rate(imax_ssoa_received_segment[5m]) > (rate(imax_ssoa_sent_segment[5m]) * 1.1) and rate(imax_ssoa_received_segment[5m]) > 0"
    for: "1m"
    labels:
      severity: "critical"
  - alert: "ManifestsStuck"
    annotations:
      description: "The rate of sent manifests is significantly lower than received manifests for the last 1m. Received: {{ $value | printf \"%.2f\" }}/s (using ratio rule example). Potential processing failure or backlog."
      summary: "Manifest forwarding issue detected."
    expr: "rate(imax_ssoa_received_manifest[5m]) > (rate(imax_ssoa_sent_manifest[5m]) * 1.1) and rate(imax_ssoa_received_manifest[5m]) > 0"
    for: "1m"
    labels:
      severity: "critical"
  - alert: "RecentIngressSegmentTrafficDrop"
    annotations:
      description: "Average segment ingress rate over the last 15 minutes ({{ printf \"%.2f\" $value }} req/s) is more than 25% lower than the average segment ingress rate over the preceding hour. Check for recent changes or issues."
      summary: "Recent segment traffic rate drop detected for {{ $labels.job }} / {{ $labels.instance }}."
    expr: "sum by (job, instance) (rate(imax_ssoa_received_segment[15m])) < (sum by (job, instance) (rate(imax_ssoa_received_segment[1h] offset 15m)) * 0.75) and sum by (job, instance) (rate(imax_ssoa_received_segment[1h] offset 15m)) > 1"
    for: "30s"
    labels:
      severity: "warning"
  - alert: "RecentIngressManifestTrafficDrop"
    annotations:
      description: "Average manifest ingress rate over the last 15 minutes ({{ printf \"%.2f\" $value }} req/s) is more than 25% lower than the average manifest ingress rate over the preceding hour. Check for recent changes or issues."
      summary: "Recent manifest traffic rate drop detected for {{ $labels.job }} / {{ $labels.instance }}."
    expr: "sum by (job, instance) (rate(imax_ssoa_received_manifest[15m])) < (sum by (job, instance) (rate(imax_ssoa_received_manifest[1h] offset 15m)) * 0.75) and sum by (job, instance) (rate(imax_ssoa_received_manifest[1h] offset 15m)) > 1"
    for: "30s"
    labels:
      severity: "warning"
  - alert: "RecentEgressSegmentTrafficDrop"
    annotations:
      description: "Average segment egress rate over the last 15 minutes ({{ printf \"%.2f\" $value }} req/s) is more than 25% lower than the average segment egress rate over the preceding hour. Check for recent changes or issues."
      summary: "Recent segment egress traffic rate drop detected for {{ $labels.job }} / {{ $labels.instance }}."
    expr: "sum by (job, instance) (rate(imax_ssoa_sent_segment[15m])) < (sum by (job, instance) (rate(imax_ssoa_sent_segment[1h] offset 15m)) * 0.75) and sum by (job, instance) (rate(imax_ssoa_sent_segment[1h] offset 15m)) > 1"
    for: "30s"
    labels:
      severity: "warning"
  - alert: "RecentEgressManifestTrafficDrop"
    annotations:
      description: "Average manifest egress rate over the last 15 minutes ({{ printf \"%.2f\" $value }} req/s) is more than 25% lower than the average manifest egress rate over the preceding hour. Check for recent changes or issues."
      summary: "Recent manifest egress traffic rate drop detected for {{ $labels.job }} / {{ $labels.instance }}."
    expr: "sum by (job, instance) (rate(imax_ssoa_sent_manifest[15m])) < (sum by (job, instance) (rate(imax_ssoa_sent_manifest[1h] offset 15m)) * 0.75) and sum by (job, instance) (rate(imax_ssoa_sent_manifest[1h] offset 15m)) > 1"
    for: "30s"
    labels:
      severity: "warning"
