Using Matplotlib to visualize Stackdriver Monitoring metrics for Cloud Bigtable
Stackdriver Monitoring comes with a built-in console for exploring metrics and plotting figures. To see this console:
- Open the Google Cloud Platform Console.
- Click on the top left menu navigation.
- In the Stackdriver section, click Monitoring.
- 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.
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.
This tutorial explores Cloud Bigtable metrics during a loadtest and while running the sample code for scaling Cloud Bigtable programmatically.
This tutorial assumes some familiarity with Python development, including
pip. Previous knowledge of Google Cloud Platform, Jupyter,
pandas, and Matplotlib is helpful.
- Install Jupyter and the Python Stackdriver dependencies.
- Explore basic plotting of Cloud Bigtable metrics during a scaling event.
This tutorial uses billable components of GCP, including:
- Cloud Bigtable
- Stackdriver Monitoring
Use the Pricing Calculator to generate a cost estimate based on your projected usage.
Before you begin
- Create a project in the GCP Console.
- Enable billing for your project.
- Install the Cloud SDK.
Create a client ID to run the sample code:
gcloud auth application-default login
Install Jupyter by following the installation instructions.
virtualenvby following the installation instructions.
Create and activate a
pipto install the required components:
pip install -r requirements.txt
Loading the notebook
Download the tutorial notebook.
With the necessary dependencies installed into the
virtualenv environment, start a new
Open the Jupyter notebook in the browser. From there you can follow the tutorial to see how basic Cloud Bigtable metrics are plotted and how they respond to programmatic scaling.