Skip to main content
APA
Sponsored by CAST AI — Kubernetes cost optimization Better Stack — Uptime monitoring and log management
⚠️

Alert thresholds depend on the nature of your applications. Some queries may have arbitrary tolerance thresholds. Building an efficient monitoring platform takes time. 😉

Ruby Prometheus Alert Rules

5 Prometheus alerting rules for Ruby. Exported via prometheus_exporter. These rules cover critical and warning conditions — copy and paste the YAML into your Prometheus configuration.

5.4. prometheus_exporter (5 rules)

wget https://raw.githubusercontent.com/samber/awesome-prometheus-alerts/refs/heads/master/dist/rules/ruby/ruby-exporter.yml
warning

5.4.1. Ruby heap live slots high

Ruby heap has too many live slots (> 500k), heap bloat

  # Threshold is a rough default. Adjust based on your application's normal heap size.
- alert: RubyHeapLiveSlotsHigh
  expr: ruby_heap_live_slots > 500000
  for: 5m
  labels:
    severity: warning
  annotations:
    summary: Ruby heap live slots high (instance {{ $labels.instance }})
    description: "Ruby heap has too many live slots (> 500k), heap bloat\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

5.4.2. Ruby heap free slots high

Ruby heap has too many free slots (> 500k), memory fragmentation after large allocations

- alert: RubyHeapFreeSlotsHigh
  expr: ruby_heap_free_slots > 500000
  for: 5m
  labels:
    severity: warning
  annotations:
    summary: Ruby heap free slots high (instance {{ $labels.instance }})
    description: "Ruby heap has too many free slots (> 500k), memory fragmentation after large allocations\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

5.4.3. Ruby major GC rate high

Ruby is performing too many major GC cycles, indicating memory pressure

  # Major GC rate > 5/s only fires if the app is essentially non-functional. Threshold of 2/s provides earlier detection.
- alert: RubyMajorGCRateHigh
  expr: rate(ruby_major_gc_ops_total[5m]) > 2
  for: 5m
  labels:
    severity: warning
  annotations:
    summary: Ruby major GC rate high (instance {{ $labels.instance }})
    description: "Ruby is performing too many major GC cycles, indicating memory pressure\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

5.4.4. Ruby RSS high

Ruby process RSS is high (> 1GB)

- alert: RubyRSSHigh
  expr: ruby_rss > 1e9
  for: 5m
  labels:
    severity: warning
  annotations:
    summary: Ruby RSS high (instance {{ $labels.instance }})
    description: "Ruby process RSS is high (> 1GB)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

5.4.5. Ruby allocated objects spike

Ruby is allocating objects at a high rate

- alert: RubyAllocatedObjectsSpike
  expr: rate(ruby_allocated_objects_total[5m]) > 100000
  for: 5m
  labels:
    severity: warning
  annotations:
    summary: Ruby allocated objects spike (instance {{ $labels.instance }})
    description: "Ruby is allocating objects at a high rate\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"