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
  • Ingress/Egress bytes
  • MySQL queries
  • MySQL questions
  • Read/write InnoDB pages
  • InnoDB data fsyncs
  • InnoDB log fsyncs
  • Active connections

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.

Binary logs use storage space. Binary logs are automatically deleted with their associated automatic backup, which generally happens after about 7 days. You cannot manually delete binary logs, nor change the 7-day time period.

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

You can disable and then reenable binary logging, which deletes binary logs. 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 several hundred 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.
MySQL queries (queries/sec) The number of statements executed by the server. To see what statements are measured as queries, see Server Status Variables in the MySQL Reference Manual.
MySQL questions (questions/sec) The number of statements executed by the server sent by clients. To see what statements are measured as questions, see Server Status Variables in the MySQL Reference Manual.
Read/write InnoDB pages (pages/sec) The number of InnoDB pages read and written. For more information, see InnoDB Startup Options and System Variables in the MySQL Reference Manual.
InnoDB data fsyncs (operations/sec) The number of InnoDB fsync() calls. For more information, see InnoDB Startup Options and System Variables in the MySQL Reference Manual.
InnoDB log fsyncs (operations/sec) The number of InnoDB fsync() calls to the log file. For more information, see InnoDB Startup Options and System Variables in the MySQL Reference Manual.
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.
Slave I/O thread running state Indicates whether the I/O thread for reading the primary instance's binary log is running on the replica. Possible values are:
  • Yes
  • No
  • Connecting
The values are exposed through the 'cloudsql.googleapis.com/database/mysql/replication/slave_io_running_state' field.
Slave SQL Thread Running Indicates whether the SQL thread for executing events in the relay log is running on the replica. Possible values are:
  • Yes
  • No
  • Connecting
The values are exposed through the 'cloudsql.googleapis.com/database/mysql/replication/slave_sql_running_state' field.

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