[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# About database observability\n\n\u003cbr /\u003e\n\n[MySQL](/sql/docs/mysql/observability \"View this page for the MySQL database engine\") \\| PostgreSQL \\| [SQL Server](/sql/docs/sqlserver/observability \"View this page for the SQL Server database engine\")\n\n\u003cbr /\u003e\n\nDatabase observability is a measure of how accurately you can infer the internal\nstate of a database system based on the data, or telemetry, that it generates in\nlogs, metrics, and traces.\n\nDiagnosing and troubleshooting issues in an application can be particularly\ndifficult and time-consuming when a database is involved. Telemetry collection\nis crucially important. Telemetry, when enriched with application context, can\nmake database instances more understandable, observable, and easier to maintain.\nYou can identify issues and problematic trends easily and remedy them early,\nwithout having to incur costly downtime. Moreover, by using such data, you can\nconfigure newer database instances to collect the right kind of data from the\nmoment they start.\n\nYou can use data effectively and proactively to prevent issues and focus\non strategic innovation. Good telemetry collection is particularly useful\nin the [DevOps model](https://cloud.google.com/devops), where database\ngeneralists need to independently analyze telemetry to monitor, evaluate, and\noptimize the performance and health of their rapidly evolving applications.\n\nGoogle Cloud offers several powerful features spanning the four iterative\nobservability stages to help you maintain the health of your Cloud SQL\ndatabase.\n\nAutomated telemetry collection\n------------------------------\n\nTo achieve observability goals, we start by collecting telemetry,\npreferably through an automated process. When collected over a period,\ntelemetry helps establish a baseline for metrics under different load conditions.\n\nGoogle Cloud services automatically generate observability data, including metrics,\nlogs, and traces, which can help provide a complete observability overview.\n\n- [Cloud Monitoring](/monitoring/docs/monitoring-overview) collects measurements\n of your service and of the Google Cloud resources that you use. Cloud SQL uses\n built-in memory custom agents to collect query telemetry, resulting in a lower\n impact on performance and eliminating the need for agent maintenance or security overhead.\n\n- [Cloud Logging](/logging/docs/overview) collects logging data from\n common application components. For Cloud SQL, see also\n [View instance logs](/sql/docs/postgres/logging).\n\n- [Cloud Trace](/trace/docs/overview) collects latency data and executed\n query plans from applications to help you track how requests propagate through\n your application. You can compare these latency distributions over time or\n across versions. Cloud Trace alerts you when it detects a\n significant shift in the latency profile of your application when it's\n instrumented to use Cloud Trace.\n\n[Sqlcommenter](https://google.github.io/sqlcommenter/spec/),\nan [OpenTelemetry](https://cloud.google.com/learn/what-is-opentelemetry) library\nfor databases helps you monitor your databases through the lens of an\napplication. Sqlcommenter automatically instruments ORMs to augment SQL\nstatements with tags and allows OpenTelemetry trace context information to be\npropagated to the database.\n\nWith tags and trace application context in databases, it's easy to correlate\napplication code with database performance and troubleshoot microservices-based\narchitectures.\n\nDatabase monitoring\n-------------------\n\nProper monitoring helps you determine whether your application is working optimally.\nImplement monitoring early, such as before you initiate a migration or\ndeploy a new application to a production environment. Disambiguate between\napplication issues and underlying cloud issues.\n\nThe [Cloud SQL System Insights dashboard](/sql/docs/postgres/use-system-insights)\nconsiders several important signals of overall database health and performance.\n\nThe dashboard shows graphs for several important metrics, which\nhelp you gain insights into issues, such as throughput, latency, and\ncost. These insights help you respond proactively as your application needs\nchange. You can compare current performance against past trends and identify\nanomalies that might need investigation.\n\nThe Cloud SQL [Overview page](/sql/docs/postgres/monitor-instance#monitoring-overview) shows graphs for some of the key metrics.\n\nCloud SQL also helps you [compare metrics](/sql/docs/postgres/monitor-instance#monitoring-multiple) for selected instances.\n\nYou can use Cloud Monitoring to create [custom dashboards](/monitoring/charts/dashboards)\nthat help you monitor metrics and to [set up alert policies](/monitoring/alerts/using-alerting-ui#viewing_policies)\nso that you can receive timely notifications.\n\nDatabase and query analysis\n---------------------------\n\nThe Cloud SQL [Query Insights](/sql/docs/postgres/using-query-insights) tool\nprovides monitoring and diagnostics that let you detect and fix\nquery performance problems.\n\nQuery Insights dashboards help you identify query performance problems early and\nlet you move from detection to resolution by using a single interface. Built-in,\nvisual query plans assist you in troubleshooting issues to find the root cause.\nYou can also use in-context, end-to-end application tracing to find the source\nof a problematic query.\n\nQuery Insights provides application-centric monitoring that helps you\ndiagnose performance problems for applications built using object-relational\nmappings (ORMs). You can tag queries with business logic that the query is\nassociated with, such as payment, inventory, business analytics, or shipping.\nQuery Insights can integrate with your existing APM tools, letting you monitor\nand troubleshoot query problems using your favorite tool.\n\nThe Query Insights tool uses [sqlcommenter](https://google.github.io/sqlcommenter/spec/)\nto automatically instrument your ORMs. This instrumentation helps you identify\nthe application code that's causing problems. Query Insights supports\n[OpenTelemetry](https://opentelemetry.io/) standards and makes the query metrics\nand traces data available for your APM tools through the\n[Google Cloud Observability](https://cloud.google.com/products/operations) API.\n\nQuery Insights integrates with [Cloud Monitoring](https://cloud.google.com/monitoring),\nletting you create custom dashboards and alerts on query metrics or tags and receive\nnotifications using email, SMS, Slack, PagerDuty, and more.\n\nDatabase tuning\n---------------\n\nYou can iteratively [troubleshoot and tune](/sql/docs/postgres/best-practices#tuning-monitoring)\nyour database.\n\nCloud SQL recommenders help you analyze the current usage of your database\nand provide [recommendations](/recommender/docs/key-concepts#recommendations)\nand [insights](/recommender/docs/insights/using-insights#insights) based on\nheuristic methods and machine learning.\n\nCloud SQL recommenders are briefly described as follows:\n\nWhat's next\n-----------\n\n- View the list of [Cloud SQL metrics](/sql/docs/postgres/admin-api/metrics).\n- [Use Query Insights to improve query performance](/sql/docs/postgres/using-query-insights).\n- [Use System Insights to improve instance performance](/sql/docs/postgres/use-system-insights).\n- View the video: [Introducing Cloud SQL insights](https://www.youtube.com/watch?v=qN7x3ngwz1o).\n- Read the launch blog: [Database observability for developers: introducing Cloud SQL insights](https://cloud.google.com/blog/products/databases/get-ahead-of-database-performance-issues-with-cloud-sql-insights).\n- Read the blog: [Boost your query performance troubleshooting skills with Cloud SQL Insights](https://cloud.google.com/blog/topics/developers-practitioners/boost-your-query-performance-troubleshooting-skills-cloud-sql-insights).\n- Read the blog: [Enable query tagging with Sqlcommenter](https://cloud.google.com/blog/topics/developers-practitioners/enable-query-tagging-sqlcommenter-understand-application-impact-database-performance).\n- Learn more about [Cloud Logging](/logging/docs/overview) and [Cloud Monitoring](/monitoring/docs/monitoring-overview). See also [View instance logs](/sql/docs/postgres/logging).\n- [Troubleshoot and tune](/sql/docs/postgres/best-practices#tuning-monitoring) your database instance.\n- Learn more about [Google Cloud recommenders](/recommender/docs/overview)."]]