Skip to content

Commit

Permalink
add example alerts doc
Browse files Browse the repository at this point in the history
  • Loading branch information
encima committed Nov 14, 2024
1 parent 51a0420 commit ff922c8
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/example-alerts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Example Alerts

This document contains some example alerting rules you may want to configure. Both Grafana and Prometheus use PromQL for their alerting configuration so the examples provide the PromQL query as well as the cofiguration for the alert itself. You can cutomise these based on your needs.

## Database Down

Alerting when the instance is sending metrics but the database is down and has been down for 5 minutes

```
alert: PostgresDatabaseDown
expr: pg_up == 0
for: 5m
labels:
severity: critical
annotations:
summary: "PostgreSQL database is down"
description: "The database has been down for more than 5 minutes on {{ $labels.instance }}"
```

## Replication Lag

Alerting when the replication lag is more than 10 minutes and has been increasing over the last 10 minutes

```
alert: PostgresReplicationLagHigh
expr: (physical_replication_lag_physical_replication_lag_seconds > 600) and (rate(physical_replication_lag_physical_replication_lag_seconds[10m]) > 0)
for: 5m
labels:
severity: warning
annotations:
summary: "PostgreSQL replication lag is high and growing"
description: "Replication lag is over 10 minutes and has been increasing for the last 10 minutes on {{ $labels.instance }}"
```

## Database Size

Alerting when the database size has increased by 20% or more in the last 12 hours

```
alert: PostgresDatabaseSizeGrowth
expr: (pg_database_size_mb - pg_database_size_mb offset 12h) / pg_database_size_mb offset 12h * 100 > 20
for: 5m
labels:
severity: warning
annotations:
summary: "PostgreSQL database size growth exceeds threshold"
description: "Database {{ $labels.instance }} has grown by more than 20% in the last 12 hours on {{ $labels.instance }}"
```

0 comments on commit ff922c8

Please sign in to comment.