Default variable details

Some of debops.pgbadger default variables have more extensive configuration than simple strings or lists, here you can find documentation and examples for them.

pgbadger__instances

The pgbadger__*_instances variables can be used to manage a set of Bash scripts stored in the pgbadger__scripts_path directory (by default, /srv/www/pgbadger/scripts). These scripts will be executed periodically via cron. Each script can contain pgbadger command(s) which will generate HTML files with parsed PostgreSQL log output. The Bash scripts will be executed as the pgbadger__user UNIX account (pgbadger by default), and will have access to its SSH public keys, permitting remote command execution.

Configuration entries are managed using the Universal Configuration system.

Examples

Define a Bash script that uses SSH to access remote log files and generates HTML output in the default location:

pgbadger__instances:

  - name: 'remote-log'
    host: 'db.example.org'
    output: 'db.example.org.html'

Use a custom pgBadger command to generate logs from multiple hosts:

pgbadger__instances:

  - name: 'multi-log'
    raw: |
      pgbadger --quiet --start-monday --outfile multi-log.html \
        ssh://pgbadger@db1.example.org//var/log/postgresql/*.log \
        ssh://pgbadger@db2.example.org//var/log/postgresql/*.log
    state: 'present'

Syntax

Configuration entries are defined as YAML dictionaries in a list with specific parameters:

name

Required. Name of the generated Bash script to manage in the /srv/www/pgbadger/scripts/ directory. Each configuration entry requires an unique name parameter, multiple entries with the same name will be merged at runtime and will override their parameters in order of appearance.

raw

String or YAML text block with custom Bash script inserted into a template. The script will be executed in the default output directory (defined in the pgbadger__www_root variable) or the directory specified by the chdir parameter.

If the raw parameter is not used, the host and output parameters are required.

raw_header

String or YAML tezt block with custom Bash script inserted into a template. This script will be used to prepare the execution environment for the rest of the pgBadger execution.

If not specified, a boilerplate lock file will be created to prevent repeated execution of the same script.

user

Optional. Name of the remote SSH user to use for SSH connection. If not specified, pgbadger__ssh_user value will be used by default.

host

Fully Qualified Domain Name of the remote host to which pgbadger will SSH to get the contents of the PostgreSQL log files. If the value is localhost, the script will not use SSH but will check local log files instead.

output

Name of the HTML file generated by the pgBadger command, should include the .html suffix to be correctly served by the webserver.

chdir

Optional. Absolute path to the directory which the generated script will cd into. If not specified, the script will change to the default WWW root directory before executing the pgBadger command(s).

log

Optional. Name of the PostgreSQL log file(s) which should be parsed by pgBadger, either on local or remote host. Logs will be searched in the /var/log/postgresql/ directory; the name may contain a star which will be used as a glob pattern. If not specified, *.log value will be used by default.

comment

Optional. String or YAML text block with a comment added at the top of the generated Bash script.

state

Optional. If not specified or present, a given Bash script will be generated in the /srv/www/pgbadger/scripts/ directory. If absent, a given Bash script will be removed from the host. If init, a given configuration entry will be prepared, but it will not be enabled by default; subsequent configuration entry with the same name and present state can enable a prepared entry. If ignore, a given configuration entry will be ignored at runtime.