Monitoring Cloud SQL instances

This page describes how to monitor a Cloud SQL instance.

Cloud SQL offers two ways to monitor an instance:

  • In the Google Cloud Console
  • In Cloud Monitoring

Comparing metrics from multiple instances

  1. Go to the Cloud SQL Instances page in the Google Cloud Console.

    Go to the Cloud SQL Instances page

  2. From the SQL instances overview page, select up to 5 instances you want to compare by checking the checkbox to the left of the instance name.
  3. In the Info Panel on the right, select the Monitoring tab.
  4. Select the metric you want to compare from the metric dropdown.

    You can see the exact data for a specific time by hovering over the graph.

Cloud SQL instance monitoring in the console

Cloud SQL provides some performance monitoring in the INFO PANEL on the SQL instances overview page, and also in the instance details page for a selected instance. A drop-down menu in those charts presents the following options:

  • CPU utilization
  • Storage usage
  • Memory usage
  • Read/write operations
  • Active connections
  • Transactions/sec
  • Ingress/Egress bytes

Additionally, a read replica offers the option Replication delay.

Console

  1. Go to the Cloud SQL Instances page in the Google Cloud Console.

    Go to the Cloud SQL Instances page

  2. Click the instance to open its Instance overview page.
  3. The metrics chart is prominent on the top of the page.

Available metrics

The usage charts can help you respond proactively as your application needs change. From these metrics, you can gain insight 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 (PITR) uses write-ahead log (WAL) archiving. These logs update regularly, and use storage space. Write-ahead logs are automatically deleted with their associated automatic backup, which generally happens after about 7 days.

If the size of your write-ahead logs are causing an issue for your instance, you can increase your storage size, but the write-ahead log size increase in disk usage might be temporary. To avoid unexpected storage issues, we recommend enabling automatic storage increases when using PITR.

To delete the logs and recover storage, you can disable point-in-time recovery. Note, however, that decreasing the storage used does not shrink the size of the storage provisioned for the instance.

Temp data is included in the storage usage metric. Temp data is removed as part of maintenance and is allowed to increase beyond user-defined capacity limits to avoid a disk full event, at no charge to the user.

A newly created database uses about 100 MB for system tables and files.

CPU usage

You can use this metric to monitor whether your instance has sufficient CPU for your application's 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).

Active connections Number of open connections to the Cloud SQL instance.
Ingress/Egress bytes (bytes/sec) The amount of network traffic coming into or leaving the instance.
Transactions/sec The number of transactions that have been committed or rolled back on the instance. These values correspond to the xact_commit and xact_rollback statistics.
Instance state The state of your instance is indicated by the status icon, next to the instance name. You can also monitor the cloudsql.googleapis.com/database/instance_state metric.

Figure 1 points out the different parts of a usage chart.

Graph showing example Cloud SQL metric data.
Figure 1: Example instance usage data

where

  • Callout 1: The metric data displayed in the chart.

  • Callout 2: The time range for which to view the metric data.

  • Callout 3: The value of the metric at the cursor.

  • Callout 4: The data cursor. Use the cursor to find the value of a metric at a specific time.

Cloud Monitoring

GCP Monitoring includes a default Cloud SQL monitoring dashboard, which includes the most commonly used metrics. 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 is of interest to you.

GCP Monitoring also includes many other metrics on its metrics explorer page:

Console

    To view the metrics for a monitored resource using Metrics Explorer, do the following:

    1. In the Google Cloud Console, go to Monitoring or use the following button:
      Go to Monitoring
    2. In the Monitoring navigation pane, click Metrics Explorer.
    3. Enter the monitored resource name in the Find resource type and metric text box.

    For Resource Type select Cloud SQL Database.

You can also create an alert for when the metric exceeds a given value. See more information on how to use GCP Monitoring.

What's next