Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure Database for PostgreSQL flexible server instances allow you to configure and access Postgres' standard logs. The logs can be used to identify, troubleshoot, and repair configuration errors and suboptimal performance. Logging information you can configure and access includes errors, query information, autovacuum records, connections, and checkpoints. (Access to transaction logs is not available).
Audit logging is made available through a Postgres extension, pgaudit. To learn more, visit the auditing concepts article.
Configure logging
You can configure Postgres standard logging on your server using the logging server parameters. To learn more about Postgres log parameters, visit the When To Log and What To Log sections of the Postgres documentation. Most, but not all, Postgres logging parameters are available to configure in Azure Database for PostgreSQL flexible server instances.
To learn how to configure parameters in your Azure Database for PostgreSQL flexible server instance, see the portal documentation or the CLI documentation.
Note
Configuring a high volume of logs, for example statement logging, can add significant performance overhead.
Accessing logs
Azure Database for PostgreSQL is integrated with Azure Monitor diagnostic settings. Diagnostic settings allows you to send your Azure Database for PostgreSQL logs in JSON format to Azure Monitor Logs for analytics and alerting, Event Hubs for streaming, and Azure Storage for archiving.
Data Retention Policy and Pricing
For logs sent to Event Hubs or a Storage account, you can set up a retention policy to automatically delete data after a certain period. When it comes to logs sent to Log Analytics, the costs for Azure Monitor Log Analytics are primarily influenced by two factors:
- Data Ingestion: Charges are based on the volume of data that is ingested into the workspace.
 - Data Retention: Logs stored in your Log Analytics workspace are kept free of charge for the first 31 days. Beyond this free retention period, there is a fee for storing data, calculated on a daily pro-rata basis, based on the amount of data (in GB) retained each month.
 
For a comprehensive breakdown of the costs associated with data ingestion and retention, please visit the Azure Monitor pricing page.
Log format
The following table describes the fields for the PostgreSQLLogs type. Depending on the output endpoint you choose, the fields included and the order in which they appear may vary.
| Field | Description | 
|---|---|
| TenantId | Your tenant ID | 
| SourceSystem | Azure | 
| TimeGenerated [UTC] | Time stamp when the log was recorded in UTC | 
| Type | Type of the log. Always AzureDiagnostics | 
| SubscriptionId | GUID for the subscription that the server belongs to | 
| ResourceGroup | Name of the resource group the server belongs to | 
| ResourceProvider | Name of the resource provider. Always MICROSOFT.DBFORPOSTGRESQL | 
| ResourceType | FlexibleServers | 
| ResourceId | Resource URI | 
| Resource | Name of the server | 
| Category | PostgreSQLLogs | 
| OperationName | LogEvent | 
| errorLevel_s | Logging level, example: LOG, ERROR, NOTICE | 
| processId_d | Process ID of the PostgreSQL backend | 
| sqlerrcode_s | PostgreSQL Error code that follows the SQL standard's conventions for SQLSTATE codes | 
| Message | Primary log message | 
| Detail | Secondary log message (if applicable) | 
| ColumnName | Name of the column (if applicable) | 
| SchemaName | Name of the schema (if applicable) | 
| DatatypeName | Name of the datatype (if applicable) | 
| _ResourceId | Resource URI | 
Known limitations
- Log Event Size: Query plans or log messages larger than 65 KB will not be captured in Azure Monitor Logs. This is a platform-wide Azure Monitor limit. As a result, very complex queries (for example, those involving nested views) may generate incomplete or missing query plan output in server logs.
 - Other Constraints: Additional platform-wide limits apply to Azure Monitor Logs, such as alert rule quotas and query result size. For the complete list, refer to the Azure Monitor service limits documentation for details.