Description
log_min_messages sets the lowest severity PostgreSQL writes to the server log. The default is warning.
Potential impact
A higher threshold can hide warnings and errors. A lower one can make important events harder to find and increase logging costs.
Remediation
Set log_min_messages in settings.database_flags to a supported level that captures the events you need. Check the messages and log volume. Use query auditing separately when you need a history of database operations.
Examples
The google.cloud 1.14.0 example creates an instance. Supply a supported PostgreSQL version and tier, project, instance name and service account JSON file. For existing instances, change the flags in Cloud SQL and retain the other required values.
Before
- name: Cloud SQL 인스턴스 생성
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
database_version: POSTGRES_13
name: "{{ resource_name }}-2"
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
database_flags:
- name: log_min_messages
value: debug6
tier: db-custom-1-3840
state: present
PostgreSQL rejects debug6.
After
- name: Cloud SQL 인스턴스 생성
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
database_version: POSTGRES_13
name: "{{ resource_name }}-2"
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
database_flags:
- name: log_min_messages
value: log
tier: db-custom-1-3840
state: present
For server logging, log ranks above error and below fatal. Choose warning if you need ordinary warnings and errors.