Cloud SQL instance for PostgreSQL is not appearing in the metric category "Cloud SQL Instance Database" in Metrics Explorer

Problem

A Cloud SQL for PostgreSQL instance is not appearing in the metric category "Cloud SQL Instance Database" in Metrics Explorer.

Environment

  • Cloud SQL for PostgreSQL

Solution

  1. Sign in to the Google Cloud console.
  2. Navigate to the Cloud SQL Instances page.
  3. To open the Overview page of an instance, click the instance name.
  4. On the Configuration tile, click Edit configuration.
  5. In the Configuration options section, expand Query Insights.
  6. Select the Enable Query Insights checkbox.
  7. Optional: Select one or more of the following Query Insights options:
    • Store client IP addresses. Stores the client IP addresses where queries are coming from and helps you group that data to run metrics against it. Queries come from more than one host. Reviewing graphs for queries from client IP addresses can help identify the source of a problem.
    • Store application tags. Stores application tags that help you determine the APIs and model-view-controller (MVC) routes that are making requests and group the data to run metrics against it. This option requires you to comment queries with a specific set of tags. You can do this by using the sqlcommenter open source object-relational mapping (ORM) auto-instrumentation library. This information helps Query Insights identify the source of the issue and the MVC where the issue is coming from. Application paths help you with application monitoring.
    • Customize query lengths. Sets the default query length limit to a specified value from 256 to 4500 bytes. The default query length is 1024 bytes. Higher query lengths are more useful for analytical queries, but they also require more memory. Changing the query length requires you to restart the instance. You can still add tags to queries that exceed the length limit.
    • Set the maximum sampling rate. By default, a maximum of 5 executed query plan samples are captured per minute across all databases on the instance. Change this value to a number from 0 (to disable sampling) to 20. Increasing the sampling rate is likely to give you more data points but might add a performance overhead.
  8. Click Save.

Note: When enabling the Query Insights dashboard, all other operations are temporarily suspended. This includes health checks, logging, monitoring, and other instance operations. However, the instance itself does not restart, and you will still have uninterrupted access to the database during the process.

Cause

Query Insight's PostgreSQL extension records query metrics and execution plans implemented using Postgres hooks. The metrics and execution plans are stored as a Postgres table in a shared memory table. Once the Query Insights are enabled, it starts recording the data and therefore, you can view it in the Logs Explorer.