How to collect logs with VMware Postgres for Kubernetes
book
Article ID: 293292
calendar_today
Updated On:
Products
VMware Tanzu SQL
Issue/Introduction
Log collection with Postgres for Kubernetes is done differently compared to a traditional Postgres deployment or GPDB deployment. Log collection for Support/R&D review can be done using the below syntax:
Environment
Product Version: 1.6
Resolution
Alongside the logs, always be sure to capture the following context: -Which series of events lead to the issue? -Was this working previously, or is this the first time the task is being attempted?
Get the kubernetes version and other cluster info kubectl get nodes -o wide
Get the operator version and installed dependencies helm list --all-namespaces --all
Get the state of the impacted postgres instance and get an overview of other postgres instances kubectl get postgres -n <namespace> -o yaml kubectl get postgres -A
Get the logs from the Postgres pods kubectl logs -n <namespace> -l postgres-instance=<name-of-instance> --all-containers --max-log-requests 10 --prefix --tail=-1
Get the logs from the Postgres Operator kubectl logs -l app=postgres-operator -n <operator namespace> --tail=-1
Get the available pods kubectl get pods -l postgres-instance=<name-of-instance>,type=data
For each of the pods above, collect the following output kubectl exec -t -n <namespace> <pod-name> -- cat /pgsql/data/postgresql.conf kubectl exec -t -n <namespace> <pod-name> -- cat /pgsql/data/pg_hba.conf kubectl exec -t -n <namespace> <pod-name> -- cat /pgsql/data/postgresql.auto.conf kubectl exec -t -n <namespace> <pod-name> -- df -h /pgsql
Collect Postgres server logs from the available data pods kubectl cp -n <namespace> -c reconfigure-instance <pod-name>:/pgsql/data/log /tmp/<pod-name>/
After running the command above, we'll need the contents of the /tmp/<pod-name>/ directory
Please collect the following items if the issue is related to backups or restores:
Get the associated backup location of the impacted instance kubectl get postgresbackuplocation -n <namespace> -o yaml
Get all the backups executed on the impacted postgres instance kubectl get postgresbackup -l postgres-instance= <name-of-instance> -n <namespace> -o yaml
If a backup schedule is configured, get the backup schedule kubectl get postgresbackupschedules -n <namespace> -o yaml