监视和优化 Azure Database for PostgreSQL(单一服务器)Monitor and tune Azure Database for PostgreSQL - Single Server

监视服务器的相关数据有助于排查工作负荷故障及优化工作负荷。Monitoring data about your servers helps you troubleshoot and optimize for your workload. Azure Database for PostgreSQL 提供各种监视选项,帮助用户深入了解服务器的行为。Azure Database for PostgreSQL provides various monitoring options to provide insight into the behavior of your server.


Azure Database for PostgreSQL 提供了各种指标来帮助用户深入了解为 PostgreSQL 服务器提供支持的资源的行为。Azure Database for PostgreSQL provides various metrics that give insight into the behavior of the resources supporting the PostgreSQL server. 每项指标以一分钟为频率发出,历史记录长达 93 天Each metric is emitted at a one-minute frequency, and has up to 93 days of history. 可针对指标配置警报。You can configure alerts on the metrics. 有关分步指南,请参阅如何设置警报For step by step guidance, see How to set up alerts. 其他任务包括设置自动操作、执行高级分析和存档历史记录。Other tasks include setting up automated actions, performing advanced analytics, and archiving history. 有关详细信息,请参阅 Azure 指标概述For more information, see the Azure Metrics Overview.

指标列表List of metrics

这些指标适用于 Azure Database for PostgreSQL:These metrics are available for Azure Database for PostgreSQL:

指标Metric 指标显示名称Metric Display Name 计价单位Unit 说明Description
cpu_percentcpu_percent CPU 百分比CPU percent 百分比Percent 使用的 CPU 百分比。The percentage of CPU in use.
memory_percentmemory_percent 内存百分比Memory percent 百分比Percent 使用的内存百分比。The percentage of memory in use.
io_consumption_percentio_consumption_percent IO 百分比IO percent 百分比Percent 使用的 IO 百分比。The percentage of IO in use. (不适用于基本层服务器。)(Not applicable for Basic tier servers.)
storage_percentstorage_percent 存储百分比Storage percentage 百分比Percent 所用存储占服务器最大存储的百分比。The percentage of storage used out of the server's maximum.
storage_usedstorage_used 已用的存储量Storage used 字节Bytes 使用的存储量。The amount of storage in use. 服务使用的存储可能包括数据库文件、事务日志和服务器日志。The storage used by the service may include the database files, transaction logs, and the server logs.
storage_limitstorage_limit 存储限制Storage limit 字节Bytes 此服务器的最大存储。The maximum storage for this server.
serverlog_storage_percentserverlog_storage_percent 服务器日志存储空间百分比Server Log storage percent 百分比Percent 所用服务器日志存储占服务器最大服务器日志存储的百分比。The percentage of server log storage used out of the server's maximum server log storage.
serverlog_storage_usageserverlog_storage_usage 服务器日志已用的存储量Server Log storage used 字节Bytes 使用的服务器日志存储量。The amount of server log storage in use.
serverlog_storage_limitserverlog_storage_limit 服务器存储空间上限Server Log storage limit 字节Bytes 此服务器的最大服务器日志存储。The maximum server log storage for this server.
active_connectionsactive_connections 活动连接数Active Connections 计数Count 服务器的活动连接数。The number of active connections to the server.
connections_failedconnections_failed 失败的连接数Failed Connections CountCount 所建立的失败的连接数。The number of established connections that failed.
network_bytes_egressnetwork_bytes_egress 网络传出Network Out 字节Bytes 跨活动连接的网络传出。Network Out across active connections.
network_bytes_ingressnetwork_bytes_ingress 网络传入Network In 字节Bytes 跨活动连接的网络传入。Network In across active connections.
backup_storage_usedbackup_storage_used 使用的备份存储Backup Storage Used 字节Bytes 已使用的备份存储量。The amount of backup storage used. 此指标表示根据为服务器设置的备份保留期保留的所有完整数据库备份、差异备份和日志备份所消耗的存储的总和。This metric represents the sum of storage consumed by all the full database backups, differential backups, and log backups retained based on the backup retention period set for the server. 备份的频率由服务管理,并在概念文章中进行了说明。The frequency of the backups is service managed and explained in the concepts article. 对于异地冗余存储,备份存储使用率是本地冗余存储的两倍。For geo-redundant storage, backup storage usage is twice that of the locally redundant storage.
pg_replica_log_delay_in_bytespg_replica_log_delay_in_bytes 副本的最大滞后时间Max Lag Across Replicas 字节Bytes 主服务器与滞后时间最长的副本之间的延迟(以字节为单位)。The lag in bytes between the primary and the most-lagging replica. 此指标仅适用于主服务器。This metric is available on the primary server only.
pg_replica_log_delay_in_secondspg_replica_log_delay_in_seconds 副本滞后时间Replica Lag Seconds 自上次重放事务以来所经历的时间。The time since the last replayed transaction. 此指标仅适用于副本服务器。This metric is available for replica servers only.

服务器日志Server logs

可以在服务器上启用日志记录。You can enable logging on your server. 这些资源日志可发送到 Azure Monitor 日志、事件中心和存储帐户。These resource logs can be sent to Azure Monitor logs, Event Hubs, and a Storage Account. 若要了解有关日志记录的详细信息,请访问服务器日志页。To learn more about logging, visit the server logs page.

查询存储Query Store

查询存储可以随着时间的推移跟踪查询性能,包括查询运行时统计信息和等待事件。Query Store keeps track of query performance over time including query runtime statistics and wait events. 此功能将查询运行时性能信息保留在 query_store 架构下名为 azure_sys 的一个系统数据库中。The feature persists query runtime performance information in a system database named azure_sys under the query_store schema. 你可以通过各种配置旋钮控制数据的收集和存储。You can control the collection and storage of data via various configuration knobs.

Query Performance InsightQuery Performance Insight

Query Performance Insight 与查询存储协同工作以提供可以从 Azure 门户访问的可视化效果。Query Performance Insight works in conjunction with Query Store to provide visualizations accessible from the Azure portal. 这些图表使你能够识别对性能造成影响的关键查询。These charts enable you to identify key queries that impact performance. Query Performance Insight 可以从 Azure Database for PostgreSQL 服务器门户页的“支持 + 疑难解答”部分中进行访问。Query Performance Insight is accessible from the Support + troubleshooting section of your Azure Database for PostgreSQL server's portal page.

性能建议Performance Recommendations

性能建议功能可以确定提高工作负荷性能的机会。The Performance Recommendations feature identifies opportunities to improve workload performance. 性能建议为你提供了有关创建新索引的建议,这些索引可能会提高工作负荷的性能。Performance Recommendations provides you with recommendations for creating new indexes that have the potential to improve the performance of your workloads. 若要生成索引建议,该功能会考虑各种数据库特征,包括其架构以及如“查询存储”报告的工作负载。To produce index recommendations, the feature takes into consideration various database characteristics, including its schema and the workload as reported by Query Store. 实施任何性能建议后,客户应测试性能以评估这些更改的影响。After implementing any performance recommendation, customers should test performance to evaluate the impact of those changes.

计划内维护通知Planned maintenance notification

“计划内维护通知”允许你接收有关 Azure Database for PostgreSQL - 单一服务器即将进行的计划内维护的警报。Planned maintenance notifications allow you to receive alerts for upcoming planned maintenance to your Azure Database for PostgreSQL - Single Server. 这些通知与服务运行状况计划内维护集成,允许你在同一位置查看你的订阅的所有计划内维护。These notifications are integrated with Service Health's planned maintenance and allow you to view all scheduled maintenance for your subscriptions in one place. 它还有助于将通知扩展到不同资源组的适当受众,因为你可能有不同的联系人负责不同的资源。It also helps to scale the notification to the right audiences for different resource groups, as you may have different contacts responsible for different resources. 你将在事件发生前的 72 小时收到有关即将进行的维护的通知。You will receive the notification about the upcoming maintenance 72 hours before the event.

计划内维护通知文档中详细了解如何设置通知。Learn more about how to set up notifications in the planned maintenance notifications document.

后续步骤Next steps