https://github.com/codemonauts/dbbackup-textfileexporter
https://github.com/codemonauts/dbbackup-textfileexporter
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codemonauts/dbbackup-textfileexporter
- Owner: codemonauts
- Created: 2020-10-19T14:00:09.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-19T14:02:09.000Z (over 5 years ago)
- Last Synced: 2025-01-18T07:12:04.434Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 1000 Bytes
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dbbackup-textfileexporter
Export metrics about your local database backups to Prometheus.
# Requirements & Assumptions
1) This scripts needs Python >= 3.6 without any additional librarys
2) All backup files need to be written to one folder
3) All filenames must match the pattern `-YYYY-MM-DD.`
# Usage
Change the path where your backup files are create in the top part of the script (`BACKUP_DIR`).
The metrics get written to stdout so you can pipe the ouput into a file which gets then served by the node-exporter
```
dbbackup_exporter.py > /var/lib/prometheus/node-exporter/databases.prom
```
# Example metric
```
# HELP database_backup_file_size Size of latest backup file in bytes
# TYPE database_backup_file_size gauge
database_backup_file_size{database="my_database"} 160464896
# HELP database_backup_file_timestamp Timestamp of latest backup file
# TYPE database_backup_file_timestamp gauge
database_backup_file_timestamp{database="my_database"} 1603054802
```
# Example rules
```
# Alert after 30h for daily backups to avoid false-positives due to timezone mismatch
- alert: NoDatabaseBackup
expr: (time() - database_backup_file_timestamp) / 3600 > 30
for: 5m
annotations:
description: 'Es wurd kein tägliches Backup erzeugt'
summary: 'Kein Backup für {{ $labels.database }} auf {{ $labels.instance }} angelegt'
# Less than 1Kb is considered empty
- alert: EmptyDatabaseBackup
expr: database_backup_file_size < 1024
for: 5m
annotations:
description: 'Die Backupdatei ist leer'
summary: 'Leeres Backup für {{ $labels.database }} auf {{ $labels.instance }} angelegt'
```