Monitoring Using Stackdriver

This document describes the default dashboard that Stackdriver Monitoring provides for Cloud Spanner resources, as well as how to monitor Cloud Spanner resources using Stackdriver Monitoring by creating alerts for Cloud Spanner metrics such as high CPU utilization and storage use.

Before you begin

Before you use Stackdriver Monitoring, ensure that you have the following:

  • A Stackdriver account. If you do not have a Stackdriver account, follow the steps in the Create a Stackdriver Account section of the Stackdriver Setting Up Accounts documentation.
  • A Google Cloud Platform account.
  • A GCP project with billing enabled.

One way to ensure that you have a Google Cloud Platform account and a GCP project with billing enabled is by completing the Quickstart Using the Console.

Using the Stackdriver Monitoring dashboard

Stackdriver Monitoring provides you with a curated dashboard that summarizes key information about your Cloud Spanner resources, including:

  • Incidents - user-created monitoring alerts that are open, active, or resolved
  • Events - a list of Cloud Spanner audit logs (if enabled and available)
  • Instances - a high-level summary of your Cloud Spanner instances, including node count, database count, and instance health
  • Aggregated graphs of throughput and storage use

To see basic information about the performance of your Cloud Spanner instances, use the Cloud Spanner dashboard.

Go to the dashboard

Alternatively, to view the dashboard from the Stackdriver Monitoring Console:

  1. Go to the Stackdriver Monitoring Console.

    Go to Stackdriver Monitoring

  2. Click the GCP project containing your Cloud Spanner instances, if it is not already selected.

  3. In the top left corner, click Resources.

  4. In the Infrastructure section of the menu, click Cloud Spanner.

Viewing instance and database details in Stackdriver

After you open the Cloud Spanner dashboard, you can view more details about a specific instance by clicking the instance's name under Instances.

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

From the instance dashboard page, you can also see graphs for a specific database in that instance:

  1. On the right-hand side, above the instance metrics graphs, click Database metrics.

  2. In the Select a breakdown drop-down list, select the database whose graphs you wish to view.

    Stackdriver Monitoring displays graphs for the database.

Creating alerts for Cloud Spanner metrics

This section explains how to create alerts for a few Cloud Spanner metrics that are especially useful to monitor. For a full list of available metrics, see Metrics List for Cloud Spanner.

Creating a high CPU utilization alert

As described in Instances, you choose a number of nodes to use when you create an instance. As your workload scales, Cloud Spanner does not automatically scale the number of nodes for you, so you should monitor your CPU utilization to ensure that you're staying under 75% for regional configurations and 45% for multi-region configurations.

Below is an example of how to get alerts for high CPU utilization.

  1. In the top menu of the Stackdriver Monitoring console, select Alerting > Create a Policy:

    Create an alerting policy

  2. In the Conditions section, click Add Condition.

    1. In the Find resource type and metric panel fields:

      • For the Resource type field, select "Cloud Spanner Instance."
      • For the Metric field, select "CPU utilization".
    2. Fill in the Aggregation pane fields to capture the average value of each time series in a 10 minute period.

      • Leave the Aligner field at its default value of mean.
      • Leave the Reducer field at its default value of none.
      • For the Alignment Period, enter 10 m.
    3. Fill in the Configuration pane fields to trigger if any time series exceeds a utilization of 75%.

      • Leave the Condition triggers if field at its default value of Any time series violates.
      • Leave the Condition field at its default value of is above.
      • For the threshold, enter 0.75.
      • In the For drop-down list, select 10 minutes.
    4. Click Save.

    Add threshold condition for CPU utilization

  3. Optional: To configure your notification settings, click Add Notification Channel. You can elect to receive notifications by email, SMS, and several other options.

  4. Optional: Enter a notification message in the Documentation section.

  5. Name your policy and click Save.

Creating a storage use alert

Another useful indicator of when to add an additional node is when storage per node is over 1.5 TB (75% of the 2TB limit) for a given instance:

  1. In the top menu of the Stackdriver Monitoring console, go to Alerting > Create a Policy:

    Create an alerting policy

  2. In the Conditions section, click Add Condition.

    1. In the Find resource type and metric panel fields:

      • For the Resource type field, select "Cloud Spanner Instance."
      • For the Metric field, select "Bytes received by Cloud Spanner".
    2. Fill in the Aggregation pane fields to generate a new time series whose values are determined by adding together the maximum value of each time series in the alignment period:

      • For the Aligner drop-down list, select max.
      • For the Reducer drop-down list, select sum.
      • For the Alignment Period, enter 10 m.
    3. Fill in the Configuration pane fields to trigger when the number of bytes exceeds 1.5 TB (1649000000000 bytes). Be sure to multiply this value by the number of nodes in the instance that you want to monitor. Stackdriver accepts numbers in regular notation as well as e-notation.

      • Leave the Condition triggers if field at its default value of Any time series violates.
      • Leave the Condition field at its default value of is above.
      • For the threshold, enter 1649000000000 B.
      • In the For drop-down list, select 10 minutes.
    4. Click Save.

      Add threshold condition for storage used

  3. Optional: To configure your notification settings, click Add Notification Channel. You can elect to receive notifications by email, SMS, and several other options.

  4. Optional: Enter a notification message in the Documentation section.

  5. Name your policy and click Save.

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Spanner Documentation