Check the Logs¶
Logs provide valuable information. It makes sense to check the logs of the
database Pods and the Operator Pod. Following flags are helpful for checking the
logs with the kubectl logs command:
| Flag | Description |
|---|---|
--container=<container-name> |
Print log of a specific container in case of multiple containers in a Pod |
--follow |
Follows the logs for a live output |
--since=<time> |
Print logs newer than the specified time, for example: --since="10s" |
--timestamps |
Print timestamp in the logs (timezone is taken from the container) |
--previous |
Print previous instantiation of a container. This is extremely useful in case of container restart, where there is a need to check the logs on why the container restarted. Logs of previous instantiation might not be available in all the cases. |
When persistent logging is enabled, the MySQL error log is written to a file on the data volume and streamed to the logs container. It does not appear in the mysql container output. Read it with:
kubectl logs ps-cluster1-mysql-0 -c logs
In the following examples we will access containers of the ps-cluster1-mysql-0 Pod.
-
Check logs of the
mysqlcontainer:kubectl logs ps-cluster1-mysql-0 -c mysql -
Check logs of the
xtrabackupcontainer:kubectl logs ps-cluster1-mysql-0 -c xtrabackupSee more about troubleshooting backups in the Troubleshoot backups and restores chapter.
-
Filter logs of the
mysqlcontainer which are not older than 600 seconds:kubectl logs ps-cluster1-mysql-0 -c mysql --since=600s -
Check logs of a previous instantiation of the
mysqlcontainer, if any:kubectl logs ps-cluster1-mysql-0 -c mysql --previous -
Check logs of the
mysqlcontainer forERRORmessages:kubectl logs ps-cluster1-mysql-0 -c mysql | grep 'ERROR' -
Check logs of the Operator:
kubectl logs -l "app.kubernetes.io/name=percona-server-mysql-operator" --tail=-1 -
Check logs of the operator, parsing the output with jq JSON processor (requires
LOG_STRUCTUREDto betrue):kubectl logs -l "app.kubernetes.io/name=percona-server-mysql-operator" --tail=-1 -f | jq -R 'fromjson?' -
Check logs of the HAProxy pod for configuration issues:
kubectl logs ps-cluster1-haproxy-0 | grep 'The custom config /etc/haproxy-custom/haproxy.cfg is not valid and will be ignored.'
Created: September 5, 2023