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, which opens the Create new alerting policy page.

    Create an alerting policy

  2. In the Conditions section, click Add Condition.

  3. Choose a metric on the Select Condition Type page.
    For this example, choose Metric Threshold by clicking on its associated Select button.

  4. On the Add Metric Threshold Condition page:

    1. Set Resource type to "Cloud Spanner."
    2. Set If metric to "CPU utilization."
    3. Set Condition to "above."
    4. Set Threshold to a number, such as 0.75, representing the percentage of CPU utilization.
    5. Set For to "10 minutes."
      This represents the time interval that the If metric must be over the Threshold for an alert to trigger.
    6. Leave any remaining default values and click Save Condition.

    Add threshold condition for CPU utilization

  5. On the Create new Alerting Policy page, click Add Notification to configure your notification settings. You can elect to receive notifications by email, SMS, and several other options.

  6. You can customize the notification message by clicking the Add Documentation button in the Documentation section.

  7. Finally, name your policy and click Save Policy.

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 2 TB limit) for a given instance.

  1. In the top menu of the Stackdriver Monitoring Console, select Alerting > Create a Policy, which opens the Create new alerting policy page.

    Create an alerting policy

  2. In the Conditions section, click Add Condition.

  3. On the Select Condition Type page, choose Metric Threshold by clicking on its associated Select button.

  4. On the Add Metric Threshold Condition page:

    1. Set Resource type to "Cloud Spanner."
    2. Set If metric to "Storage used."
    3. Set Condition to "above."
    4. Set Threshold to a number of bytes.
      For this example, multiply the number of nodes in the instance that you want to monitor by 1649000000000 (the number of bytes in 1.5 TB) and set Threshold to the result. Stackdriver accepts numbers in regular notation as well as e-notation.
    5. Set For to "10 minutes."
      This represents the time interval that the If metric must be over the Threshold for an alert to trigger.
    6. Set Instance_ID to the instance you wish to monitor.
    7. Leave any remaining default values and click Save Condition.

    Add threshold condition for storage used

  5. On the Create new Alerting Policy page, click Add Notification to configure your notification settings. You can elect to receive notifications by email, SMS, and several other options.

  6. You can customize the notification message by clicking the Add Documentation button in the Documentation section.

  7. Finally, name your policy and click Save Policy.

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

Send feedback about...

Cloud Spanner Documentation