Monitor instances with Cloud Monitoring

This document describes how to use the Cloud Monitoring console to monitoryour Spanner instances.

The Cloud Monitoring console provides several monitoring tools forSpanner:

If you prefer to monitor Spanner programmatically, use theCloudClient Libraries for Cloud Monitoring toretrieve metrics.

Note: You can also monitor your instances byviewing charts in theGoogle Cloud console. Use the Google Cloud console to get aquick view of the most important metrics for your instance.

Use the Cloud Monitoring curated dashboard

Cloud Monitoring provides you with a curated dashboard that summarizes keyinformation about your Spanner instances, including:

  • Incidents: User-created monitoring alerts that are open, active, orresolved
  • Events: A list of Spanneraudit logs (ifenabled and available)
  • Instances: A high-level summary of your Spanner instances,includingcompute capacity, database count, and instance health
  • Aggregated charts of throughput and storage use

To view the Spanner dashboard, do the following:

  1. In the Google Cloud console, selectMonitoring, or use the following button:

    Go to Monitoring

  2. IfResources is shown in the navigation pane, then selectResourcesand then selectCloud Spanner. Otherwise, selectDashboards and thenselect the dashboard namedCloud Spanner.

View instance and database details

When you open the curated dashboard for Spanner, it showsaggregated data for all of your instances. You can view more details about aspecific instance by clicking the instance's name underInstances.

The dashboard displays information such as instance metadata, databases in theinstance, and charts of various metrics broken down by region.

From the instance dashboard page, you can also see charts for a specificdatabase in the instance:

  1. On the right-hand side, above the instance metrics charts, clickDatabasemetrics.

  2. In theSelect a breakdown drop-down list, select the database that youwant to examine.

    The Cloud Monitoring console displays charts for the database.

Create custom charts for Spanner metrics

You can use Cloud Monitoring to create custom charts forSpanner metrics. You can use the Metrics Explorer to createtemporary, ad-hoc charts, or you can create charts that appear on customdashboards.

In particular, Cloud Monitoring lets you create a custom chart that showswhether two or more metrics are correlated with each other. For example, you cancheck for a correlation betweenCPU utilization andlatency in a Spanner instance, which might indicatethat your instance needs morecompute capacity or that some of yourqueries are causing high CPU utilization.

To get started with this example, follow these steps:

  1. In the Google Cloud console, selectMonitoring, or use the following button:

    Go to Monitoring

  2. IfMetrics Explorer is shown in the navigation pane, select it.Otherwise, selectResources and then selectMetrics Explorer.

  3. Click theView options tab, then select theLog scale on Y-axischeckbox. This option helps you compare multiple metrics when one metric hasmuch larger values than the others.

  4. In the drop-down list above the right pane, selectLine.

  5. Click theMetrics tab. You can now add metrics to the chart.

To add latency metrics to the chart, follow these steps:

  1. In theFind resource type and metric box, enter the valuespanner.googleapis.com/api/request_latencies, then click the row thatappears below the box.
  2. In theFilter box, enter the valueinstance_id, then enter theinstance ID you want to examine and clickApply.
  3. In theAggregator drop-down list, clickmax.
  4. Optional: Change the latency percentile:

    1. ClickShow advanced options.
    2. Click theAligner drop-down list, then click the latency percentilethat you want to view.

    In most cases, you should look at either the 50th percentile latency, to understand the typical amount of latency, or the 99th percentile latency, to understand the latency for the slowest 1% of requests.

To add CPU utilization metrics to the chart, follow these steps:

  1. Click Add metric.
  2. In theFind resource type and metric box, enter the valuespanner.googleapis.com/instance/cpu/utilization, then click the row thatappears below the box.
  3. In theFilter box, enter the valueinstance_id, then enter theinstance ID you want to examine and clickApply.
  4. In theAggregator drop-down list, clickmax.

You now have a chart that shows the CPU utilization and latency metrics for aSpanner instance. If both metrics are higher than expected at thesame time, you cantake additional steps to correct the issue.

For more information about creating custom charts, see theCloud Monitoringdocumentation.

Create alerts for Spanner metrics

When you create a Spannerinstance, you choose thecompute capacity for the instance. As the instance's workload changes,Spanner does not automatically adjust compute capacity of theinstance. As a result, you need to set up several alerts to ensure that theinstance stays within therecommended maximums for CPU utilization and therecommended limit for storage.

The following examples show how to set up alerting policies for someSpanner metrics. For a full list of available metrics, seemetricslist for Spanner.

High-priority CPU

To create an alerting policy that triggers when your high priority cpu utilization forSpanner is above a recommended threshold, use the following settings.

Steps to create an alerting policy.

To create an alerting policy, do the following:

  1. In the Google Cloud console, go to the Alerting page:

    Go toAlerting

    If you use the search bar to find this page, then select the result whose subheading isMonitoring.

  2. If you haven't created your notification channels and if you want to be notified, then clickEdit Notification Channels and add your notification channels. Return to theAlerting page after you add your channels.
  3. From theAlerting page, selectCreate policy.
  4. To select the resource, metric, and filters, expand theSelect a metric menu and then use the values in theNew condition table:
    1. Optional: To limit the menu to relevant entries, enter the resource or metric name in the filter bar.
    2. Select aResource type. For example, selectVM instance.
    3. Select aMetric category. For example, selectinstance.
    4. Select aMetric. For example, selectCPU Utilization.
    5. SelectApply.
  5. ClickNext and then configure the alerting policy trigger. To complete these fields, use the values in theConfigure alert trigger table.
  6. ClickNext.
  7. Optional: To add notifications to your alerting policy, clickNotification channels. In the dialog, select one or more notification channels from the menu, and then clickOK.

    To be notified when incidents are openend and closed, checkNotify on incident closure. By default, notifications are sent only when incidents are openend.

  8. Optional: Update theIncident autoclose duration. This field determines when Monitoring closes incidents in the absence of metric data.
  9. Optional: ClickDocumentation, and then add any information that you want included in a notification message.
  10. ClickAlert name and enter a name for the alerting policy.
  11. ClickCreate Policy.
New condition
Field

Value
Resource and MetricIn theResources menu, selectSpanner Instance.
In theMetric categories menu, selectInstance.
In theMetrics menu, selectCPU Utilization by priority.

(The metric.type isspanner.googleapis.com/instance/cpu/utilization_by_priority).
Filterinstance_id =YOUR_INSTANCE_ID
priority = high
Across time series
Time series group by
location for multi-region instances;
leave it blank for regional instances.
Across time series
Time series aggregation
sum
Rolling window10 m
Rolling window functionmean
Configure alert trigger
Field

Value
Condition typeThreshold
Alert triggerAny time series violates
Threshold positionAbove threshold
Threshold value45% for multi-region instances;
65% for regional instances.
Retest window10 minutes

24 hour rolling average CPU

To create an alerting policy that triggers when the 24 hour rolling average of your cpu utilization forSpanner is above a recommended threshold, use the following settings.

Steps to create an alerting policy.

To create an alerting policy, do the following:

  1. In the Google Cloud console, go to the Alerting page:

    Go toAlerting

    If you use the search bar to find this page, then select the result whose subheading isMonitoring.

  2. If you haven't created your notification channels and if you want to be notified, then clickEdit Notification Channels and add your notification channels. Return to theAlerting page after you add your channels.
  3. From theAlerting page, selectCreate policy.
  4. To select the resource, metric, and filters, expand theSelect a metric menu and then use the values in theNew condition table:
    1. Optional: To limit the menu to relevant entries, enter the resource or metric name in the filter bar.
    2. Select aResource type. For example, selectVM instance.
    3. Select aMetric category. For example, selectinstance.
    4. Select aMetric. For example, selectCPU Utilization.
    5. SelectApply.
  5. ClickNext and then configure the alerting policy trigger. To complete these fields, use the values in theConfigure alert trigger table.
  6. ClickNext.
  7. Optional: To add notifications to your alerting policy, clickNotification channels. In the dialog, select one or more notification channels from the menu, and then clickOK.

    To be notified when incidents are openend and closed, checkNotify on incident closure. By default, notifications are sent only when incidents are openend.

  8. Optional: Update theIncident autoclose duration. This field determines when Monitoring closes incidents in the absence of metric data.
  9. Optional: ClickDocumentation, and then add any information that you want included in a notification message.
  10. ClickAlert name and enter a name for the alerting policy.
  11. ClickCreate Policy.
New condition
Field

Value
Resource and MetricIn theResources menu, selectSpanner Instance.
In theMetric categories menu, selectInstance.
In theMetrics menu, selectSmoothed CPU utilization.

(The metric.type isspanner.googleapis.com/instance/cpu/smoothed_utilization).
Filterinstance_id =YOUR_INSTANCE_ID
Across time series
Time series aggregation
sum
Rolling window10 m
Rolling window functionmean
Configure alert trigger
Field

Value
Condition typeThreshold
Alert triggerAny time series violates
Threshold positionAbove threshold
Threshold90%
Retest window10 minutes

Storage

To create an alerting policy that triggers when your storage for yourSpanner instance is above a recommended threshold, use the following settings.

Steps to create an alerting policy.

To create an alerting policy, do the following:

  1. In the Google Cloud console, go to the Alerting page:

    Go toAlerting

    If you use the search bar to find this page, then select the result whose subheading isMonitoring.

  2. If you haven't created your notification channels and if you want to be notified, then clickEdit Notification Channels and add your notification channels. Return to theAlerting page after you add your channels.
  3. From theAlerting page, selectCreate policy.
  4. To select the resource, metric, and filters, expand theSelect a metric menu and then use the values in theNew condition table:
    1. Optional: To limit the menu to relevant entries, enter the resource or metric name in the filter bar.
    2. Select aResource type. For example, selectVM instance.
    3. Select aMetric category. For example, selectinstance.
    4. Select aMetric. For example, selectCPU Utilization.
    5. SelectApply.
  5. ClickNext and then configure the alerting policy trigger. To complete these fields, use the values in theConfigure alert trigger table.
  6. ClickNext.
  7. Optional: To add notifications to your alerting policy, clickNotification channels. In the dialog, select one or more notification channels from the menu, and then clickOK.

    To be notified when incidents are openend and closed, checkNotify on incident closure. By default, notifications are sent only when incidents are openend.

  8. Optional: Update theIncident autoclose duration. This field determines when Monitoring closes incidents in the absence of metric data.
  9. Optional: ClickDocumentation, and then add any information that you want included in a notification message.
  10. ClickAlert name and enter a name for the alerting policy.
  11. ClickCreate Policy.
New condition
Field

Value
Resource and MetricIn theResources menu, selectSpanner Instance.
In theMetric categories menu, selectInstance.
In theMetrics menu, selectStorage used.

(The metric.type isspanner.googleapis.com/instance/storage/utilization).
Filterinstance_id =YOUR_INSTANCE_ID
Across time series
Time series aggregation
sum
Rolling window10 m
Rolling window functionmax
Configure alert trigger
Field

Value
Condition typeThreshold
Condition triggers ifAny time series violates
Threshold positionAbove threshold
Threshold valueYou don't need to set a specific threshold for the maximum storage per node. However, we recommendedthat you set up an alert for when you are approaching the maximum storage limit. To learn more, seeStorage utilization metrics.
Retest window10 minutes

Note: Spanner usage amounts are calculated inbinary terabytes,where 1 TB is 240 bytes. This unit ofmeasurement is also known as atebibyte (TiB).

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.