2

I've deployed an EDB cluster on OpenShift, but I'm unable to read the contents of the postgres.json file. Do you happen to know why this might be the case, or if there's a workaround to access the log data?

➜  oc get cluster
NAME   AGE   INSTANCES   READY   STATUS                     PRIMARY
smt   4d    3           3       Cluster in healthy state   smt-1
➜  
➜  oc rsh -c postgres smt-1
sh-4.4$ psql -U postgres
psql (14.19 (EDB Postgres Extended Server 14.19.0))
Type "help" for help.

postgres=# show log_line_prefix;
                   log_line_prefix                   
-----------------------------------------------------
 %m [%p][%x]: [%l-1] user=%u,db=%d,app=%a,client=%h 
(1 row)

postgres=# show log_directory;
  log_directory  
-----------------
 /controller/log
(1 row)

postgres=# \q
sh-4.4$ 
sh-4.4$ cd /controller/log
sh-4.4$ ls -l
total 0
prw-------. 1 1000890000 1000890000 0 Nov  3 02:36 edb_audit.csv
prw-------. 1 1000890000 1000890000 0 Nov  3 02:36 postgres
prw-------. 1 1000890000 1000890000 0 Nov  3 02:54 postgres.csv
prw-------. 1 1000890000 1000890000 0 Nov  3 02:44 postgres.json
sh-4.4$ 
sh-4.4$ more postgres

sh-4.4$ more edb_audit.csv

But I can read file postgres.csv with command:

sh-4.4$ more postgres.csv
2025-11-03 03:50:15.970 CET,,,918,"[local]",69081867.396,1,"",2025-11-03 03:50:15 CET,,0,LOG,00000,"connection received: host=[local]",,,,,,,,,"","not initialized",,0
2025-11-03 03:50:15.971 CET,"postgres","postgres",918,"[local]",69081867.396,2,"authentication",2025-11-03 03:50:15 CET,6/462,0,LOG,00000,"connection authenticated: identity=""1000890000"" method=
peer (/var/lib/postgresql/data/pgdata/pg_hba.conf:7)",,,,,,,,,"","client backend",,0
2025-11-03 03:50:15.971 CET,"postgres","postgres",918,"[local]",69081867.396,3,"authentication",2025-11-03 03:50:15 CET,6/462,0,LOG,00000,"connection authorized: user=postgres database=postgres ap
plication_name=pg_isready",,,,,,,,,"","client backend",,0
2025-11-03 03:50:15.973 CET,"postgres","postgres",918,"[local]",69081867.396,4,"idle",2025-11-03 03:50:15 CET,,0,LOG,00000,"disconnection: session time: 0:00:00.002 user=postgres database=postgres
 host=[local]",,,,,,,,,"pg_isready","client backend",,0
2025-11-03 03:50:19.277 CET,,,920,"10.130.3.15:37828",6908186b.398,1,"",2025-11-03 03:50:19 CET,,0,LOG,00000,"connection received: host=10.130.3.15 port=37828",,,,,,,,,"","not initialized",,0
2025-11-03 03:50:19.283 CET,"streaming_replica","postgres",920,"10.130.3.15:37828",6908186b.398,2,"authentication",2025-11-03 03:50:19 CET,6/465,0,LOG,00000,"connection authenticated: identity=""C
N=streaming_replica"" method=cert (/var/lib/postgresql/data/pgdata/pg_hba.conf:10)",,,,,,,,,"","client backend",,0

Another odd thing is that although I've configured log_line_prefix in PostgreSQL, the format of entries in postgres.csv doesn't match the expected structure.

1
  • 1
    That ls -l command seems fake. It shows total 0, which means empty, but then four files. And the files seem to be named pipes (first letter p), so they will behave different from normal files. Commented Nov 3 at 18:58

1 Answer 1

2

although I've configured log_line_prefix in PostgreSQL, the format of entries in postgres.csv doesn't match the expected structure.

log_line_prefix only affects the log_destinations of stderr, syslog and eventlog. If you were able to prefix CSV and JSON log entries, you'd risk breaking their format and rendering them unparseable. They could probably accommodate a prefix in a separate field but they currently don't - their structure is fixed, as described in the doc.

Check your current_logfiles file to see what your db knows about where it's currently supposed to save logs.
demo at db<>fiddle

select pg_read_file('current_logfiles');
pg_read_file
stderr log/postgresql-2025-11-03_132133.log
select name, setting, vartype, unit, concat_ws(' ',short_desc,extra_desc) as desc, context, source, min_val,    max_val,    enumvals,   boot_val,   reset_val,  sourcefile, sourceline, pending_restart
from pg_settings
where category='Reporting and Logging / Where to Log';
name setting__________________________________ vartype unit description___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ context source min_val max_val enumvals boot_val__________________________________ reset_val__________________________________ sourcefile sourceline pending_restart
event_source PostgreSQL string null Sets the application name used to identify PostgreSQL messages in the event log. postmaster default null null null PostgreSQL PostgreSQL null null f
log_destination stderr string null Sets the destination for server log output. Valid values are combinations of "stderr", "syslog", "csvlog", "jsonlog", and "eventlog", depending on the platform. sighup default null null null stderr stderr null null f
log_directory log string null Sets the destination directory for log files. Can be specified as relative to the data directory or as absolute path. sighup default null null null log log null null f
log_file_mode 0600 integer null Sets the file permissions for log files. The parameter value is expected to be a numeric mode specification in the form accepted by the chmod and umask system calls. (To use the customary octal format the number must start with a 0 (zero).) sighup default 0 511 null 384 384 null null f
log_filename postgresql-%Y-%m-%d_%H%M%S.log string null Sets the file name pattern for log files. sighup default null null null postgresql-%Y-%m-%d_%H%M%S.log postgresql-%Y-%m-%d_%H%M%S.log null null f
log_rotation_age 1440 integer min Sets the amount of time to wait before forcing log file rotation. sighup default 0 35791394 null 1440 1440 null null f
log_rotation_size 10240 integer kB Sets the maximum size a log file can reach before being rotated. sighup default 0 2097151 null 10240 10240 null null f
log_truncate_on_rotation off bool null Truncate existing log files of same name during log rotation. sighup default null null null off off null null f
logging_collector on bool null Start a subprocess to capture stderr output and/or csvlogs into log files. postmaster configuration file null null null off on /etc/postgresql/17/main/postgresql.conf 7 f
syslog_facility local0 enum null Sets the syslog "facility" to be used when syslog enabled. sighup default null null {local0,local1,local2,local3,local4,local5,local6,local7} local0 local0 null null f
syslog_ident postgres string null Sets the program name used to identify PostgreSQL messages in syslog. sighup default null null null postgres postgres null null f
syslog_sequence_numbers on bool null Add sequence number to syslog messages to avoid duplicate suppression. sighup default null null null on on null null f
syslog_split_messages on bool null Split messages sent to syslog by lines and to fit into 1024 bytes. sighup default null null null on on null null f
select pg_read_file(regexp_replace((select pg_read_file('current_logfiles') limit 1),'^stderr (.*)\.log.*','\1.log'));
pg_read_file
2025-11-03 13:21:33.485 GMT [729] LOG: starting PostgreSQL 17.2 (Debian 17.2-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2025-11-03 13:21:33.485 GMT [729] LOG: listening on IPv4 address "0.0.0.0", port 5432
2025-11-03 13:21:33.485 GMT [729] LOG: listening on IPv6 address "::", port 5432
2025-11-03 13:21:33.485 GMT [729] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-11-03 13:21:33.492 GMT [733] LOG: database system was shut down at 2025-01-12 21:06:28 GMT
2025-11-03 13:21:33.502 GMT [729] LOG: database system is ready to accept connections

I wouldn't be surprised the log_destination was set to only csvlog in your case, which means it's only ever trying to save that one log. Change it to csvlog,stderr,jsonlog if you really need all three.

Also, the three files you're showing seem like there's no log rotation in place. It might be helpful to use the default log_filename of postgresql-%Y-%m-%d_%H%M%S.log to enable the default 24h, 10MB rotation. It'll change .log to .csv and .json on its own.

See Chapter 19.8.1 Server Configuration. Error Reporting and Logging: Where to Log.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the explanations. You are right. log_destination is set to csvlog and in EDB Postgres deployed on Openshift, the change to log_filename and log_destination is not allowed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.