# Monitor (ansible role)

This role will install monitor component on target hosts
* Install exporters
* node_exporter
* pg_exporter
* pgbouncer_exporter

### Tasks

[tasks/main.yml](tasks/main.yml)

```yaml
Install exporter yum repo	TAGS: [exporter_install, exporter_yum_install, monitor, pgsql]
Install node_exporter and pg_exporter	TAGS: [exporter_install, exporter_yum_install, monitor, pgsql]
Copy exporter binaries	TAGS: [exporter_binary_install, exporter_install, monitor, pgsql]
Create /etc/pg_exporter conf dir	TAGS: [monitor, pg_exporter, pgsql]
Copy default pg_exporter.yaml	TAGS: [monitor, pg_exporter, pgsql]
Config /etc/default/pg_exporter	TAGS: [monitor, pg_exporter, pgsql]
Config pg_exporter service unit	TAGS: [monitor, pg_exporter, pgsql]
Launch pg_exporter systemd service	TAGS: [monitor, pg_exporter, pgsql]
Wait for pg_exporter service online	TAGS: [monitor, pg_exporter, pgsql]
Config pgbouncer_exporter opts	TAGS: [monitor, pgbouncer_exporter, pgsql]
Config pgbouncer_exporter service	TAGS: [monitor, pgbouncer_exporter, pgsql]
Launch pgbouncer_exporter service	TAGS: [monitor, pgbouncer_exporter, pgsql]
Wait for pgbouncer_exporter online	TAGS: [monitor, pgbouncer_exporter, pgsql]
Copy node_exporter systemd service	TAGS: [monitor, node_exporter, pgsql]
Config default node_exporter options	TAGS: [monitor, node_exporter, pgsql]
Launch node_exporter service unit	TAGS: [monitor, node_exporter, pgsql]
Wait for node_exporter online	TAGS: [monitor, node_exporter, pgsql]
```

### Default variables

[defaults/main.yml](defaults/main.yml)

```yaml
#------------------------------------------------------------------------------
# MONITOR PROVISION
#------------------------------------------------------------------------------
# - install - #
exporter_install: none                        # none|yum|binary, none by default
exporter_repo_url: ''                         # if set, repo will be added to /etc/yum.repos.d/ before yum installation

# - collect - #
exporter_metrics_path: /metrics               # default metric path for pg related exporter

# - node exporter - #
node_exporter_enabled: true                   # setup node_exporter on instance
node_exporter_port: 9100                      # default port for node exporter
node_exporter_options: '--no-collector.softnet --collector.systemd --collector.ntp --collector.tcpstat --collector.processes'

# - pg exporter - #
pg_exporter_config: pg_exporter-demo.yaml     # default config files for pg_exporter
pg_exporter_enabled: true                     # setup pg_exporter on instance
pg_exporter_port: 9630                        # default port for pg exporter
pg_exporter_url: ''                           # optional, if not set, generate from reference parameters
pg_exporter_auto_discovery: true              # optional, discovery available database on target instance ?
pg_exporter_exclude_database: 'template0,template1,postgres' # optional, comma separated list of database that WILL NOT be monitored when auto-discovery enabled
pg_exporter_include_database: ''                             # optional, comma separated list of database that WILL BE monitored when auto-discovery enabled, empty string will disable include mode
pg_exporter_options: '--log.level=info --log.format="logger:syslog?appname=pg_exporter&local=7"'

# - pgbouncer exporter - #
pgbouncer_exporter_enabled: true              # setup pgbouncer_exporter on instance (if you don't have pgbouncer, disable it)
pgbouncer_exporter_port: 9631                 # default port for pgbouncer exporter
pgbouncer_exporter_url: ''                    # optional, if not set, generate from reference parameters
pgbouncer_exporter_options: '--log.level=info --log.format="logger:syslog?appname=pgbouncer_exporter&local=7"'

# - postgres variables reference - #
pg_dbsu: postgres
pg_port: 5432
pgbouncer_port: 6432
pg_localhost: /var/run/postgresql
pg_monitor_username: dbuser_monitor
pg_monitor_password: DBUser.Monitor
service_registry: consul
```