[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# About database observability\n\n\u003cbr /\u003e\n\nMySQL \\| [PostgreSQL](/sql/docs/postgres/observability \"View this page for the PostgreSQL database engine\") \\| [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/mysql/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 [Overview page](/sql/docs/mysql/monitor-instance#monitoring-overview) shows graphs for some of the key metrics.\n\nCloud SQL also helps you [compare metrics](/sql/docs/mysql/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/mysql/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/mysql/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/mysql/admin-api/metrics).\n- Learn more about [Cloud Logging](/logging/docs/overview) and [Cloud Monitoring](/monitoring/docs/monitoring-overview). See also [View instance logs](/sql/docs/mysql/logging).\n- [Troubleshoot and tune](/sql/docs/mysql/best-practices#tuning-monitoring) your database instance.\n- Learn more about [Google Cloud recommenders](/recommender/docs/overview)."]]