Monitor Cloud SQL instances

This page describes how you can monitor Cloud SQL instances in the following ways:

Use the Cloud SQL System Insights dashboard

The Cloud SQL System Insights dashboard helps you detect and analyze system performance problems.

For more information, see Use System Insights to improve system performance.

Monitor an instance by using the Cloud Monitoring dashboard

Cloud Monitoring offers predefined dashboards for several Google Cloud products, including a default Cloud SQL monitoring dashboard. You can use this dashboard to monitor the general health of your primary and replica instances. You can also create your own custom dashboards to display data that's of interest to you.

Set up alerts

You can use Cloud Monitoring to set up alerts for a project or a specified instance.

For example, you can set up an alert for a message to be sent to specific email IDs when the Memory usage metric for a Cloud SQL instance exceeds the threshold of 80%.

View metrics on the Cloud SQL instance Overview page

View some of the key metrics for a Cloud SQL instance on its Overview page as follows:

  1. In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  2. To open the Overview page of an instance, click the instance name.
  3. The default metrics chart appears at the top of the page.

  4. Optional: Select another metric from the Chart drop-down list.

    The chart shows the data for the selected metric.

Available metrics

The usage charts help you respond proactively as your application needs change. From these metrics, you can gain insights into issues of throughput and latency as well as instance usage costs.

MetricDescription
Storage usage (GB)

You can use the storage usage metric to help you understand your storage costs. For more information about storage usage charges, see Storage and Networking Pricing.

Point-in-time recovery uses write-ahead logging (WAL) archiving. For new Cloud SQL instances that have point-in-time recovery enabled or for existing instances that enable point-in-time recovery after this feature for storing WAL logs in Cloud Storage is available, logs are no longer stored on disk; instead they're stored in Cloud Storage in the same region as the instances.

To see whether an instance's logs are stored in Cloud Storage, check the bytes_used_by_data_type metric for the instance. If the value for the archived_wal_log data type is 0, the instance's logs are stored in Cloud Storage.

After you use a PostgreSQL client such as psql or pgAdmin to connect to a database of the instance, run the following command: show archive_command. If any WALs are archived in Cloud Storage, then you see -async_archive -remote_storage.

All other existing instances that have point-in-time recovery enabled continue to have their logs stored on disk. The change to storing logs in Cloud Storage is available at a later time.

The write-ahead logs used in point-in-time recovery are deleted automatically with their associated automatic backup, which generally happens after the value set for transactionLogRetentionDays is met. This is the number of days of transaction logs that Cloud SQL retains for point-in-time recovery, from 1 to 35 for Cloud SQL Enterprise Plus edition and 1 to 7 for Cloud SQL Enterprise edition.

When you restore a backup on a Cloud SQL instance before enabling point-in-time recovery, you lose the WAL logs that allow the operability of point-in-time recovery.

For instances that have write-ahead logs stored in Cloud Storage, the logs are stored in the same region as the primary instance. This log storage (up to seven days, the maximum length for point-in-time recovery) generates no additional cost per instance.

If your instance has point-in-time recovery enabled, and if the size of your write-ahead logs on disk is causing an issue for your instance, then deactivate point-in-time recovery and re-enable it to ensure that new logs are stored in Cloud Storage in the same region as the instance. This deletes existing write-ahead logs, so you can't perform a point-in-time-restore earlier than the time that you re-enabled point-in-time recovery. However, although the existing logs are deleted, the disk size remains the same.

To avoid unexpected storage issues, we recommend enabling automatic storage increases for all instances when using point-in-time recovery. This recommendation applies only if your instance has point-in-time recovery enabled and your logs are stored on disk.

To delete the logs and recover storage, you can deactivate point-in-time recovery. Note, however, that decreasing the write-ahead logs used doesn't shrink the size of the disk provisioned for the instance.

Data usage is included in the storage usage metric. As part of data usage, when a transaction modifies a database, before Cloud SQL modifies the original data, a copy is made of this data. The copy of the data is undo data.

CPU usage

You can use this metric to monitor whether your instance has sufficient CPU for your application needs. If this value is running too high, you can increase the size of your machine type to give your instance more CPU capability.

Memory usage

The amount of memory being used by your instance.

Read/write operations

The Number of Reads metric is the number of read operations served from disk that do not come from cache. You can use this metric to help you understand whether your instance is correctly sized for your environment. If needed, you can move to a larger machine type to serve more requests from cache and reduce latency.

The Number of Writes metric is the number of write operations to disk. Write activity is generated even if your application is not active, because Cloud SQL instances write to a system table approximately every second (except for replicas).

Ingress/Egress bytes (bytes/sec) The amount of network traffic coming into or leaving the instance.

Compare metrics from multiple instances

  1. In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  2. From the Cloud SQL Instances page, choose up to five instances to compare by selecting the checkbox to the left of the instance name.
  3. On the Info Panel on the right, select the Monitoring tab.
  4. From the metrics drop-down, select the metric to use for comparing instances.

    You can see the data for a specific moment by holding the pointer over the chart.

What's next