Configure log redirection
You can redirect control plane and data plane service logs, internal logs, audit logs, and backup logs (pgBackRest) in AlloyDB Omni to a centralized folder or observation disk. By aggregating logs distributed across local node paths—such as /var/log or /run/log—you enable production monitoring tools to identify system errors, improve system observability, and streamline troubleshooting.
Centralized observability
The AlloyDB Omni stack contains multiple components separated into a control plane—for example, cluster manager, node manager, etcd—and a data plane. Log redirection pushes logs from these components to a centralized path or observation disk (ObsDisk). You can then pipe these logs into your observability tools to detect system issues without needing to access individual node paths.
etcd is a standalone distributed configuration store required by the cluster manager to coordinate and manage state. It can run on its own dedicated nodes or be colocated with cluster manager nodes. In contrast, node managers act as local agents installed on data plane nodes—database and load balancer nodes—to process control plane commands.
Log redirection covers the following components:
- Control plane components service logs
- cluster manager on cluster manager nodes
- node manager on all nodes
etcdon theetcdnodes
- Data plane components service logs
alloydbomnion primary instance and readpool instance nodesalloydbomnimonitor on primary instance and readpool instance nodespgBackReston primary instance nodespgbounceron primary instance nodes or load balancer nodeskeepalivedon primary instance nodes or load balancer nodesHAProxyon load balancer nodes
- AlloyDB Omni internal and audit logs
Limitations
rsyslogandjournalhave limitations regarding global limits and rate-based limits.etcdlog redirection is only supported when you use the Ansible interface.- Logs truncation:
rsyslogdoesn't have built-in support for log truncation. - Rsyslog observability: direct monitoring of
rsyslogdaemon status might require additional setup.
Before you begin
- Verify that paths specified for log redirection exist on the relevant nodes and that they're directories.
Configure log redirection
To configure log redirection in AlloyDB Omni, you must specify destination directories for both control plane and data plane components.
Redirect control plane logs
Follow these steps to configure log redirection for the control plane components
cluster manager, node manager, and etcd.
Open your
deployment_spec.yamlfile.Add parameters to the
cluster_managerandetcdstanzas to specify the destination directory.The following
deployment_spec.yamlprovides an example:alloydbomni: vars: cluster_manager: name: CM_CLUSTER logging: disk: path: "/obs" etcd: logging: disk: path: "/obs"You can provision the
etcdservice separately. To capture all control plane logs, you must define theloggingpath under both thecluster_managerandetcdstanzas in yourdeployment_spec.yamlfile.The following table describes the parameters for configuring control plane log redirection, which you can use to specify the destination path for logs in your deployment specification:
Parameter Required Description logging.diskNo Subsection for control plane log redirection to disk. logging.disk.pathConditional Required if logging.diskis set. Disk path wherersyslogredirects service logs. Must exist on nodes and must be a directory.Apply the configuration changes.
Ansible
The Ansible orchestrator automatically invokes configuration utilities during installation or update. To apply configuration updates using the Ansible orchestrator, follow these steps:
- Open your Ansible control node, which is the administrative machine or workstation where you installed Ansible.
Create a file named
update.ymland add the following contents:--- - hosts: all become: true vars: update_action: "update_logging" ansible_user: SSH_USER ansible_ssh_private_key_file: ~/path/to/private-key roles: - role: google.alloydbomni_orchestrator.updateReplace
SSH_USERwith the SSH username that you used to connect to your deployment nodes.Run the playbook to apply the configuration changes.
ansible-playbook -i DEPLOYMENT_SPECIFICATION update.ymlReplace
DEPLOYMENT_SPECIFICATIONwith the path to the deployment specification file that you created in Install AlloyDB Omni components—for example,deployment_spec.yaml.
alloydbctl
On cluster manager nodes, run the following command:
/usr/local/bin/alloydbomni_cm_config apply -d deployment_spec.yamlOn node manager nodes, which include all of the database and load balancer nodes, run the following command:
/usr/local/bin/alloydbomni_nm_config apply -d deployment_spec.yamlOn
etcdnodes, create or update theetcdsystemd override file/etc/systemd/system/etcd.service.d/logging.confwith the following:[Service] SyslogIdentifier=etcdCreate or update the
etcdrsyslog file/etc/rsyslog.d/etcd.conf:template(name="DailyLogProg_etcd" type="string" string="ETCD_LOG_REDIRECT_DIR/%$year%-%$month%-%$day%-journal.log") if $programname == 'etcd' then { action(type="omfile" dynaFile="DailyLogProg_etcd" FileCreateMode="0644") stop }Replace
ETCD_LOG_REDIRECT_DIRwith the path to the directory where you wantetcdlogs redirected—for example,/obs.Restart the
rsyslogservice:sudo systemctl restart rsyslog
Redirect data plane logs
To configure log redirection for data plane components, follow these steps:
Open your
DBClusterresource specification.Add an observation disk (
ObsDisk) to the list of disks. The following example shows how to define a storage extension, add an observation disk, and specify that the disk must be mounted or accessed at the path/obs.DBCluster: metadata: name: "DBCLUSTER_NAME" spec: primarySpec: resources: disks: - name: ObsDisk path: /obs ```Apply or bootstrap the
DBClusterresource.Ansible
Create a file named
update.ymland add the following contents:--- - hosts: all vars: update_action: "update_resource_spec" ansible_user: SSH_USER ansible_ssh_private_key_file: PRIVATE_KEY_PATH roles: - role: google.alloydbomni_orchestrator.updateReplace the following:
SSH_USER: the SSH username used to connect to your deployment nodes.PRIVATE_KEY_PATH: the path to the SSH private key file on your Ansible control node—for example,~/path/to/private-key.
Run the playbook to apply the configuration changes.
ansible-playbook -i DEPLOYMENT_SPECIFICATION update.yml -e "resource_spec=DBCLUSTER_SPECIFICATION"Replace the following:
DEPLOYMENT_SPECIFICATION: path to the deployment specification that you created in Install AlloyDB Omni components.DBCLUSTER_SPECIFICATION: path to your cluster specification.
alloydbctl
Run the following command:
alloydbctl apply -d DEPLOYMENT_SPECIFICATION -r DBCLUSTER_SPECIFICATIONReplace the following:
DEPLOYMENT_SPECIFICATION: path to the deployment specification you created in Install AlloyDB Omni components.DBCLUSTER_SPECIFICATION: path to your cluster specification.
Verify log redirection
After you apply your configurations, verify that the logs are streaming to the specified directories by reviewing the control plane and data plane redirected paths.
Control plane redirected paths
| Component | Redirected log path |
|---|---|
alloydbomni_cluster_manager |
LOGGING_DISK_PATH/CM_CLUSTER_NAME/alloydbomni_cluster_manager/YYYY-MM-DD-journal.log |
alloydbomni_node_manager |
LOGGING_DISK_PATH/CM_CLUSTER_NAME/alloydbomni_node_manager/YYYY-MM-DD-journal.log |
etcd |
LOGGING_DISK_PATH/CM_CLUSTER_NAME/etcd/YYYY-MM-DD-journal.log |
LOGGING_DISK_PATH: the base directory path on your node where the control plane service logs are redirected—for example,/obs.CM_CLUSTER_NAME: the name of your control plane cluster as defined in thedeployment_spec.yamlfile.
Data plane redirected paths
| Component | Redirected log path |
|---|---|
alloydbomni |
OBS_DISK_PATH/DB_CLUSTER_NAME/alloydbomniVERSION@SYSTEMD_INSTANCE_NAME/YYYY-MM-DD-journal.log |
alloydbomni_monitor |
OBS_DISK_PATH/DB_CLUSTER_NAME/alloydbomni_monitor@SYSTEMD_INSTANCE_NAME/YYYY-MM-DD-journal.log |
pgbouncer |
OBS_DISK_PATH/DB_CLUSTER_NAME/PgBouncer@SYSTEMD_INSTANCE_NAME/YYYY-MM-DD-journal.log |
keepalived |
OBS_DISK_PATH/DB_CLUSTER_NAME/keepalived@SYSTEMD_INSTANCE_NAME/YYYY-MM-DD-journal.log |
haproxy |
OBS_DISK_PATH/DB_CLUSTER_NAME/haproxy@SYSTEMD_INSTANCE_NAME/YYYY-MM-DD-journal.log |
pgbackrest |
OBS_DISK_PATH/DB_CLUSTER_NAME/pgbackrest/YYYY-MM-DD-*.log |
OBS_DISK_PATH: the path specified inObsDisk—for example,/obs.DB_CLUSTER_NAME: the name of your database cluster.
Logging configuration parameters
AlloyDB Omni automatically sets the standard PostgreSQL parameters to manage log generation based on your configuration. However, you can override parameters like log_rotation_age and log_filename in your user-defined parameter to customize your log rotation policy.
| GUC | Description | Without OBS disk | With OBS disk |
|---|---|---|---|
logging_collector |
Enables the logging collector background process. | On | On |
log_directory |
Directory for internal and audit logs. | DATA_DISK_PATH/VERSION/log |
OBS_DISK_PATH/DB_CLUSTER_NAME/alloydbomni/VERSION |
log_filename |
Filename pattern (strftime). |
postgresql-%H.log (truncated every 24 hours) |
postgresql-%Y-%m-%d_%H%M%S.log |
log_file_mode |
File permissions. | 0600 |
0600 |
log_rotation_age |
Maximum time to use a file before rotating. | 60 minutes | 60 minutes |
log_rotation_size |
Maximum file size before rotating. | 0 | 0 |
log_truncate_on_rotation |
Truncate rather than append on rotation. | On | Off |