1.- Odoo provisioning version >=v0.7.10 (usually in all.yml file)
odoo_provisioning_version: "v0.7.10"
2.- Add upstream to ngnix_configs (usually in all.yml file)
nginx_configs:
upstream:
...
...
- upstream bexporter { server 127.0.0.1:11800; }
3.- Add configuration to nginix_sites -> odoo.ssl (usually in all.yml file)
nginx_sites:
odoo:
...
...
odoo.ssl:
...
...
location /backup/ {
include proxy_params;
proxy_redirect off;
proxy_pass http://bexporter;
auth_basic "closed site";
auth_basic_user_file /etc/nginx/.bexporter.htpasswd;
}
...
4.- Enable backup monitoring (usually in config.yml file)
monitoring_backup_exporter_enabled: true
5.- Add backup monitoring to basic_auth_users
basic_auth_users:
...
...
- { 'path': '/etc/nginx/.bexporter.htpasswd', 'name': 'bexporter', 'password': '{{ basic_auth_user_bexporter_password }}' }
6.- Define basic_auth_user_bexporter_password (usually in secrets.yml)
basic_auth_user_bexporter_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
66333337316220306166323962336162326133323465663866653939373366306361623164363531
376634633936613134338323839306462346664316434310a306335336332393536616232653463
396366613763643633333465643062396339366332393833373438733326136623636613435383638
6362646439343139390a393261643061323062626133343338396437333562336365363765336265
32366632616432393765346665656433643165663063363831623937376439353734
7.- Deploy provisioning with tags: nginx, backup and monitoring
ansible-playbook playbooks/provision.yml -i ../odoo-XXXX-inventory/inventory/hosts --limit=production --vault-password-file ~/vault/vault1 --tags=nginx,backup,monitoring
8.- Check backup monitoring in:
https://<host.>/backup/
Username: bexporter
Password: basic_auth_user_bexporter_password
The result should be something like that:
# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 102.0
python_gc_objects_collected_total{generation="1"} 289.0
python_gc_objects_collected_total{generation="2"} 0.0
# HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 41.0
python_gc_collections_total{generation="1"} 3.0
python_gc_collections_total{generation="2"} 0.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="10",patchlevel="5",version="3.10.5"} 1.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 1.76279552e+08
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.9771392e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.66208363184e+09
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 4.54
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 7.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP restic_last_snapshot_timestamp Last snapshot timestamp
# TYPE restic_last_snapshot_timestamp gauge
restic_last_snapshot_timestamp 1.609728343e+09
# HELP restic_total_size_bytes Last snapshot size in bytes
# TYPE restic_total_size_bytes gauge
restic_total_size_bytes 3.2327974e+08
# HELP restic_total_file_count Last snapshot number of files
# TYPE restic_total_file_count gauge
restic_total_file_count 5.0
# HELP restic_file_size_bytes Size in bytes for every file for last snapshot
# TYPE restic_file_size_bytes gauge
restic_file_size_bytes{path="/opt/backup/.tmp/odoo-backup.zip"} 3.5225633e+08
restic_file_size_bytes{path="/opt/backup/.tmp/odoo-test-backup.zip"} 5341.0
1.- Install the monitoring_role
from ansible
2.- Enable promtail
and its module backups
in host_vars
config file.
monitoring_enabled: true
monitoring_promtail_enabled: true
monitoring_promtail_modules_enabled:
- backups
3.- Add (and encrypt) the Loki’s credentials:
monitoring_loki_user: <int>
monitoring_loki_hostname: somewhere.lokihost.net
monitoring_loki_key: asgkD7agAKJAyAHAKJlaj9AJkjgOadA0DAD2AAsadajsfh3
4.- Run the playbook provision.yml
.
The following query is valid for both dashboard and Grafana alerts.
count_over_time({job="backup"} |="Backup complete" [1d])<1
Query:
count_over_time({job="backup"} |="Backup complete" [1d])<1
A - Query
Key | Value |
---|---|
Rule Type | Grafana managed alert |
Datasource | Loki |
Timerange | now-1d to now |
Query | count_over_time({job=“backup”} |=“Backup complete” [1d]) |
Query Type | Range |
B - Expression
Key | Value |
---|---|
Operation | Classic condition |
Conditions | WHEN count() OF A IS BELOW 1 |
Query:
({filename="/var/log/cron.d/restic-stdout.log",job="backup"})