Skip to content

Commit

Permalink
[DPE-1755] Log rotation (#251)
Browse files Browse the repository at this point in the history
* Initial implementation

* Log locations

* Fix log location
  • Loading branch information
dragomirp authored Sep 15, 2023
1 parent 21794cc commit ffe4240
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
WORKLOAD_OS_USER = "postgres"
METRICS_PORT = "9187"
POSTGRES_LOG_FILES = [
"/var/log/pgbackrest",
"/var/log/pgbackrest/*",
"/var/log/postgresql/patroni.log",
"/var/log/postgresql/postgresql.log",
"/var/log/postgresql/postgresql*.log",
]
# List of system usernames needed for correct work of the charm/workload.
SYSTEM_USERS = [BACKUP_USER, REPLICATION_USER, REWIND_USER, USER, MONITORING_USER]
Expand Down
19 changes: 18 additions & 1 deletion templates/patroni.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,25 @@ bootstrap:
archive_command: /bin/true
{%- endif %}
archive_mode: on
log_filename: 'postgresql.log'
log_autovacuum_min_duration: 60000
log_checkpoints: 'on'
log_destination: 'stderr'
log_directory: '/var/log/postgresql'
log_file_mode: '0600'
log_filename: 'postgresql-%w_%H%M.log'
log_hostname: 'off'
log_line_prefix: '%t [%p]: user=%u,db=%d,app=%a,client=%h,line=%l '
log_min_duration_sample: -1
log_recovery_conflict_waits: 'on'
log_replication_commands: 'on'
log_rotation_age: 1
log_rotation_size: 0
log_statement: ddl
log_statement_sample_rate: 1
log_statement_stats: 'off'
log_temp_files: 1
log_timezone: 'GMT'
log_truncate_on_rotation: 'on'
logging_collector: 'on'
wal_level: logical
{%- if restoring_backup %}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def check_tls_rewind(ops_test: OpsTest) -> None:
logs = await run_command_on_unit(
ops_test,
unit.name,
"grep rewind /var/log/postgresql/postgresql.log",
"grep rewind /var/log/postgresql/postgresql-*.log",
)
except Exception:
continue
Expand Down

0 comments on commit ffe4240

Please sign in to comment.