Menu
myezbrew
  • Privacy Policy
  • prometheus documentation
myezbrew

Prometheus Alerting Rules

Posted on August 13, 2023August 20, 2023 by Andy Jenkins
Follow us on Social Media
linkedin
  • Prometheus alertmanager docs
  • github alertmanager
  • alertmanager docs
    • Alerting Rules 
    • Template Examples
    • Template Reference
  • Routing tree editor
  • My Philosophy on Alerting (Google SRE)
  • Prometheus best practice alerting guide
  • Alerting on SLOs like Pros
  •  

Example alert rule:

				
					groups:
- name: demo-service-alerts # Name of the group of rules.
  rules:                    # A list of alerting rules in this group.
  - alert: HighErrorRate    # The name of the alert.
    expr: |                 # A PromQL expression whose output series become alerts.
      (
        sum by(path, instance, job) (
          rate(demo_api_request_duration_seconds_count{status=~"5..",job="demo"}[1m])
        )
      /
        sum by(path, instance, job) (
          rate(demo_api_request_duration_seconds_count{job="demo"}[1m])
        ) * 100 > 0.5
      )
    for: 5m                 # How long each result time series needs to be present to become a firing alert.
    labels:                 # Extra labels to attach for routing.
      severity: critical
    annotations:            # Non-identifying annotations that can be used in Alertmanager notifications.
      title: "{{$labels.instance}} high 5xx rate on {{$labels.path}}"
      description: "The 5xx error rate for path {{$labels.path}} on {{$labels.instance}} is {{$value}}%."
				
			

Don’t loose labels:

				
					decent:
rate(errors_total{job="my-job"}[5m]) > 10
bad:
sum by(job) (rate(errors_total{job="my-job"}[5m])) > 10
best:
sum without(instance, type) (rate(errors_total{job="my-job"}[5m])) > 10
				
			

Recent Posts

  • HAOS – Notes
  • Vger: Docker Images
  • Project: Duplicate Terraform Cloud Global Variable
  • PowerShell Crash Day
  • vger: Using a man in the middle terraform module

Recent Comments

    Archives

    • October 2023
    • September 2023
    • August 2023
    • March 2023
    • February 2023
    • November 2022
    • May 2022
    • April 2022
    • December 2021
    • October 2021
    • September 2021

    Categories

    • devops
    • docker images
    • prometheus
    • Prometheus Alerting
    • Uncategorized
    • vger

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    ©2025 myezbrew | WordPress Theme by Superb Themes