~xenrox/ansible

4fb6bdd9b9b2a1f5e2258c5fcd57c336c07cfa19 — Thorben Günther 1 year, 3 months ago eceb728
postgres: Enable slow query logging

I want to monitor if my self-developed software has unoptimized queries.
M host_vars/xenrox.net/vars.yml => host_vars/xenrox.net/vars.yml +4 -0
@@ 17,9 17,13 @@ firewalld_backend: iptables
hostname: avalon.xenrox.net
srht: true

# PostgreSQL settings
pg_max_connections: 200
pg_shared_buffers: 8GB
pg_work_mem: 64MB
pg_maintenance_work_mem: 2GB
pg_effective_io_concurrency: 100
pg_effective_cache_size: 24GB

pg_logging_collector: on
pg_log_min_duration_statement: 15ms

M roles/postgres/defaults/main.yml => roles/postgres/defaults/main.yml +3 -0
@@ 5,3 5,6 @@ pg_work_mem: 4MB
pg_maintenance_work_mem: 64MB
pg_effective_io_concurrency: 1
pg_effective_cache_size: 4GB

pg_logging_collector: off
pg_log_min_duration_statement: -1

M roles/postgres/templates/postgresql.conf.j2 => roles/postgres/templates/postgresql.conf.j2 +2 -2
@@ 436,7 436,7 @@ effective_cache_size = {{ pg_effective_cache_size }}
					# requires logging_collector to be on.

# This is used when logging to stderr:
#logging_collector = off		# Enable capturing of stderr and csvlog
logging_collector = {{ pg_logging_collector }}		# Enable capturing of stderr and csvlog
					# into log files. Required to be on for
					# csvlogs.
					# (change requires restart)


@@ 502,7 502,7 @@ effective_cache_size = {{ pg_effective_cache_size }}
					#   fatal
					#   panic (effectively off)

#log_min_duration_statement = -1	# -1 is disabled, 0 logs all statements
log_min_duration_statement = {{ pg_log_min_duration_statement }}	# -1 is disabled, 0 logs all statements
					# and their durations, > 0 logs only
					# statements running at least this number
					# of milliseconds