{"id":20345195,"url":"https://github.com/marcinhlybin/prometheus-barman-exporter","last_synced_at":"2026-02-23T00:06:16.120Z","repository":{"id":48834499,"uuid":"195996610","full_name":"marcinhlybin/prometheus-barman-exporter","owner":"marcinhlybin","description":"Barman exporter for Prometheus","archived":false,"fork":false,"pushed_at":"2022-02-22T02:15:45.000Z","size":1583,"stargazers_count":32,"open_issues_count":7,"forks_count":17,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-11-27T17:25:20.686Z","etag":null,"topics":["barman","barman-exporter","exporter","grafana","metrics","postgresql","prometheus","prometheus-exporter"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcinhlybin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-09T11:38:00.000Z","updated_at":"2025-08-12T12:28:12.000Z","dependencies_parsed_at":"2022-09-16T01:25:10.266Z","dependency_job_id":null,"html_url":"https://github.com/marcinhlybin/prometheus-barman-exporter","commit_stats":null,"previous_names":["ahes/prometheus-barman-exporter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/marcinhlybin/prometheus-barman-exporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinhlybin%2Fprometheus-barman-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinhlybin%2Fprometheus-barman-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinhlybin%2Fprometheus-barman-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinhlybin%2Fprometheus-barman-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcinhlybin","download_url":"https://codeload.github.com/marcinhlybin/prometheus-barman-exporter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinhlybin%2Fprometheus-barman-exporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29731700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["barman","barman-exporter","exporter","grafana","metrics","postgresql","prometheus","prometheus-exporter"],"created_at":"2024-11-14T22:07:14.582Z","updated_at":"2026-02-23T00:06:16.099Z","avatar_url":"https://github.com/marcinhlybin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Barman exporter for Prometheus\n\nThe barman exporter runs `barman` shell command with _experimental_ JSON output. I am the author of JSON output in Barman so it should work fine until somebody else changes output format which may happen in the future.\n \nBy default `barman-exporter` runs as a service and binds to 127.0.0.1:9780. Metrics are cached and refreshed every hour.\n\nYou can run `barman-exporter` from cron using `-f` argument to output results to a textfile:\n\n```\n/usr/local/bin/barman-exporter -f /var/lib/prometheus/node_exporter/barman.prom\n```\n\nIn such case the `node_exporter` must point to this path with `--collector.textfile.directory` option.\n\n## Grafana dashboard\n\nYou can find basic grafana dashboard in `grafana-dashboard.json`. It is open for improvements.\n\n![Grafana screenshot](grafana-screenshot.png?raw=true \"Grafana screenshot\")\n\n## Usage\n\n```\nusage: barman-exporter [-h] [-u USER] [-g GROUP] [-m MODE] [-c SECONDS] [-v] [-f TEXTFILE_PATH | -l HOST:PORT | -d]\n                       [servers [servers ...]]\n\nBarman exporter\n\npositional arguments:\n  servers               Space separated list of servers to check (default: ['all'])\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -u USER, --user USER  Textfile owner (default: prometheus)\n  -g GROUP, --group GROUP\n                        Textfile group (default: prometheus)\n  -m MODE, --mode MODE  Textfile mode (default: 0644)\n  -c SECONDS, --cache-time SECONDS\n                        Number of seconds to cache barman output for (default: 3600)\n  -v, --version         Show barman exporter version (default: False)\n  -f TEXTFILE_PATH, --file TEXTFILE_PATH\n                        Save output to textfile (default: None)\n  -l HOST:PORT, --listen-address HOST:PORT\n                        Address to listen on (default: 127.0.0.1:9780)\n  -d, --debug           Print output to stdout (default: False)\n```\n\nExamples:\n\n- `$ /usr/local/bin/barman-exporter postgres-01`\n- `$ /usr/local/bin/barman-exporter postgres-01 postgres-02`\n- `$ /usr/local/bin/barman-exporter all`\n- `$ /usr/local/bin/barman-exporter -l 10.10.10.10:9780 -c 900`\n- `$ /usr/local/bin/barman-exporter -f /var/lib/prometheus/node_exporter/barman.prom -u prometheus -g prometheus -m 0640 all`\n\n## Requirements\n\nPython3 and following modules are required to run it:\n\n- prometheus_client\n- sh\n\nAll dependencies will be installed automatically with pip command (see Installation).\n\n## Installation\n\n```\npip3 install barman-exporter\n```\n\n### Systemd service file to run barman-exporter as a service\n\n```\n[Unit]\nDescription=Barman Exporter\nAfter=network-online.target\n\n[Service]\nType=simple\nUser=barman\nGroup=barman\nExecStart=/usr/local/bin/barman-exporter -l 10.10.10.10:9780 -c 3600\nSyslogIdentifier=barman_exporter\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\n```\n\n### Cron job to run barman-exporter with textfile output\n\nIf you don't want to use barman exporter as a service you can run it with `-f` argument from the cron job. To run it every hour:\n\n```\n0 * * * * /usr/local/bin/barman-exporter -f /var/lib/prometheus/node_exporter/barman.prom\n```\n\nIn this mode barman exporter does not require any Prometheus configuration because it uses **node-exporter** to parse the metrics from a textfile. Remember to use `--collector.textfile.directory` in `node-exporter` to define a directory with textfiles.\n\n## Prometheus configuration\n\nPlease note that `barman-exporter` is listing all backups which is quite heavy operation to perform and it takes some time. Barman exporter caches its results because execution every 5 seconds would be impossible.\n\n```\nscrape_configs:\n  - job_name: barman\n    static_configs:\n      - targets:\n        - 10.10.10.10:9780'\n```\n\n## Metrics\n\n- `number=1` label indicates the newest backup\n- `barman_backups_size` and `barman_backup_wal_size` show successful backups only. Failed backups will not be listed here.\n- `barman_backups_total` includes failed backups\n- `barman_backups_failed`exposes the number of failed backups.\n- `barman_last_backup_copy_time` shows how long it takes to make a backup\n- `barman_up` shows all checks from `barman check SERVER_NAME` command. Output `OK` is `1.0`, `FAILED` is `0.0`.\n- `barman_metrics_update` shows a timestamp when barman metrics has been last updated\n\nWith `barman_last_backup` and `barman_first_backup` you can easily calculate when the latest backup was completed:\n\n```\ntime() - barman_last_backup{instance=\"$instance\", server=\"$server\"}\n```\n\n### Raw metrics\n\n```\n# HELP barman_backup_size Size of available backups\n# TYPE barman_backup_size gauge\nbarman_backup_size{number=\"1\",server=\"postgres-01\"} 1.429365116108e+012\nbarman_backup_size{number=\"2\",server=\"postgres-01\"} 1.429365116108e+012\nbarman_backup_size{number=\"3\",server=\"postgres-01\"} 1.429365116108e+012\nbarman_backup_size{number=\"4\",server=\"postgres-01\"} 1.429365116108e+012\nbarman_backup_size{number=\"5\",server=\"postgres-01\"} 1.429365116108e+012\nbarman_backup_size{number=\"6\",server=\"postgres-01\"} 1.429365116108e+012\nbarman_backup_size{number=\"7\",server=\"postgres-01\"} 1.429365116108e+012\nbarman_backup_size{number=\"8\",server=\"postgres-01\"} 1.429365116108e+012\n\n# HELP barman_backup_wal_size WAL size of available backups\n# TYPE barman_backup_wal_size gauge\nbarman_backup_wal_size{number=\"1\",server=\"postgres-01\"} 1.94347270144e+011\nbarman_backup_wal_size{number=\"2\",server=\"postgres-01\"} 3.06553290752e+011\nbarman_backup_wal_size{number=\"3\",server=\"postgres-01\"} 3.05479548928e+011\nbarman_backup_wal_size{number=\"4\",server=\"postgres-01\"} 4.79318350233e+011\nbarman_backup_wal_size{number=\"5\",server=\"postgres-01\"} 2.87333312102e+011\nbarman_backup_wal_size{number=\"6\",server=\"postgres-01\"} 2.73267294208e+011\nbarman_backup_wal_size{number=\"7\",server=\"postgres-01\"} 3.65501716889e+011\nbarman_backup_wal_size{number=\"8\",server=\"postgres-01\"} 2.34075717632e+011\n\n# HELP barman_backups_total Total number of backups\n# TYPE barman_backups_total gauge\nbarman_backups_total{server=\"postgres-01\"} 9.0\n\n# HELP barman_backups_failed Number of failed backups\n# TYPE barman_backups_failed gauge\nbarman_backups_failed{server=\"postgres-01\"} 1.0\n\n# HELP barman_last_backup Last successful backup timestamp\n# TYPE barman_last_backup gauge\nbarman_last_backup{server=\"postgres-01\"} 1.562537102e+09\n\n# HELP barman_last_backup_copy_time Last successful backup copy time\n# TYPE barman_last_backup_copy_time gauge\nbarman_last_backup_copy_time{server=\"postgres-01\"} 18706.918297\n\n# HELP barman_first_backup First successful backup timestamp\n# TYPE barman_first_backup gauge\nbarman_first_backup{server=\"postgres-01\"} 1.561154701e+09\n\n# HELP barman_up Barman status checks\n# TYPE barman_up gauge\nbarman_up{check=\"archiver_errors\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"backup_maximum_age\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"compression_settings\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"directories\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"failed_backups\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"is_superuser\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"minimum_redundancy_requirements\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"pg_basebackup\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"pg_basebackup_compatible\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"pg_basebackup_supports_tablespaces_mapping\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"pg_receivexlog\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"pg_receivexlog_compatible\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"postgresql\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"postgresql_streaming\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"receive_wal_running\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"replication_slot\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"retention_policy_settings\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"systemid_coherence\",server=\"postgres-01\"} 1.0\nbarman_up{check=\"wal_level\",server=\"postgres-01\"} 1.0\n\n# HELP barman_metrics_update Barman metrics update timestamp\n# TYPE barman_metrics_update gauge\nbarman_metrics_update{server=\"autouncle\"} 1.580485601e+09\n```\n\n## Development\n\nUpload to PyPi:\n\n```\nsource venv/bin/activate\nrm -f dist/*\npython3 setup.py sdist\ntwine upload dist/*\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinhlybin%2Fprometheus-barman-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcinhlybin%2Fprometheus-barman-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinhlybin%2Fprometheus-barman-exporter/lists"}