CrunchyData / postgres-operator

Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
https://access.crunchydata.com/documentation/postgres-operator/v5/
Apache License 2.0
3.94k stars 593 forks source link

Is there a way to send the logs from the database container in this directory: /pgdata/<db_name>/pg_log to k8s #2088

Open alrooney opened 3 years ago

alrooney commented 3 years ago

pgo 4.5.0

Often I have to exec into the db container to look at logs because the interesting logs are in /pgdata//pg_log/ directory. Is there any way to send those to k8s so that kubectl logs -f -c database would show them? Also looking at collecting them with our fluentd which we are already doing for logs visible via the logs kubectl command.

jkatz commented 3 years ago

There's an older example here: https://access.crunchydata.com/documentation/crunchy-postgres-containers/latest/examples/logging/centralized-logging/ but the principle idea is that you need to redirect the PostgreSQL logs to stderr and turn off the logging collector.

Taking a fresh look at how we handle the application logs has been on my TODO for awhile. The actual change is not challenging (see my comment above), but the bigger question is around what recommendations we make around log aggregation, if any at all.

Perhaps to help:

alrooney commented 3 years ago
QuingKhaos commented 2 years ago

Adding ours:

Personally, having PGO configured logging into the filesystem is a huge kubernetes antipattern, as by default you expect logs on stdout/stderr and to be collected by e.g. fluentd.