Edit on GitHub
Report issue
Page history

Submitted by @{[ TutorialCtrl.tutorial.github_username ]} {[ TutorialCtrl.tutorial.date_published | date:'mediumDate' ]}

title: Using Matplotlib to Visualize Stackdriver Monitoring Metrics for Cloud Bigtable description: Learn about using Matplotlib to plot Stackdriver Monitoring metrics for Cloud Bigtable. author: waprin tags: Stackdriver, Bigtable, matplotlib date_published: 2017-06-13


Stackdriver Monitoring is a service that collects metrics, events, and metadata from Google Cloud Platform (GCP) or Amazon Web Services (AWS).

Stackdriver Monitoring comes with a built-in console for exploring metrics and plotting figures. To see this console:

  1. Open the Google Cloud Platform Console.
  2. Click on the top left menu navigation.
  3. In the Stackdriver section, click Monitoring.
  4. Sign in and create or select an account, if prompted.

Many useful charts are automatically created for you, and many more custom graphs can be built within the Stackdriver console. For Google Cloud Bigtable, some charts can be found in the Cloud Bigtable console, as well as in the Stackdriver 'Metrics Explorer'.

As an alternative approach, you can use the Python library Matplotlib in conjunction with the Google Cloud Python client library, and its built-in integration with the pandas data science library, to make sophisticated graphs.

This tutorial demonstrates some simple plotting to help you get started, in conjunction with the sample code for programmatically scaling Cloud Bigtable.

The Stackdriver Python client library can be used either in standard Jupyter notebooks or with Google Cloud Datalab. This tutorial focuses on vanilla Jupyter.

Jupyter notebooks allow you to create interactive, annotated notebooks that can be shared with others. Because the sample notebook relies on default authentication and project configurations, plots and figures created using your data are automatically repopulated with the data of the users you share the notebook with, when they run your notebook.

You can read a more in-depth introduction to Stackdriver Monitoring client using Cloud Datalab.

This tutorial explores Cloud Bigtable metrics during a loadtest and while running the sample code for scaling Cloud Bigtable programmatically.

Prerequisites

This tutorial assumes some familiarity with Python development, including virtualenv and pip. Previous knowledge of Google Cloud Platform, Jupyter, pandas, and Matplotlib is helpful.

Objectives

  1. Install Jupyter and the Python Stackdriver dependencies.
  2. Explore basic plotting of Cloud Bigtable metrics during a scaling event.

Costs

This tutorial uses billable components of GCP, including:

  • Google Cloud Bigtable
  • Stackdriver Monitoring

Use the Pricing Calculator to generate a cost estimate based on your projected usage.

Before you begin

  1. Create a project in the Cloud Platform Console.
  2. Enable billing for your project.
  3. Install the Google Cloud SDK.
  4. Create a client ID to run the sample code:

    gcloud auth application-default login
    

Getting started

  1. Install Jupyter by following the installation instructions.

  2. Install virtualenv by following the installation instructions.

  3. Create and activate a virtualenv virtual environment.

  4. Download the requirements.txt and use pip to install the requirements:

    pip install -r requirements.txt
    

Loading the notebook

Download the tutorial notebook.

With the necessary dependencies installed into the virtualenv environment, start a new Jupyter notebook:

jupyter notebook

Open the Jupyter notebook in the browser. From there you can follow the tutorial to see how basic Cloud Bigtable metrics were plotted, and how they responded to programmatic scaling.

monitoring_metrics.ipynb

See more by @{[ TutorialCtrl.tutorial.github_username ]} and more tagged {[ tag ]}{[ $last ? '' : ', ' ]}

Submit a Tutorial

Share step-by-step guides

SUBMIT A TUTORIAL

Request a Tutorial

Ask for community help

SUBMIT A REQUEST

GCP Tutorials

Tutorials published by GCP

VIEW TUTORIALS

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

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.