This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use this product. Samples, quickstarts, and other documentation are available at cloud.google.com.
This sample demonstrates how to use Stackdriver Monitoring to scale Cloud Bigtable based on CPU usage.
To run this sample:
-
If this is your first time working with GCP products, you will need to set up the Cloud SDK or utilize Google Cloud Shell. This sample may require authetication and you will need to enable billing.
-
Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use.
-
Install the dependencies needed to run the samples.
pip install -r requirements.txt -
Run the sample using
python metricscaler.py
usage: metricscaler.py [-h] [--high_cpu_threshold HIGH_CPU_THRESHOLD] [--low_cpu_threshold LOW_CPU_THRESHOLD] [--short_sleep SHORT_SLEEP] [--long_sleep LONG_SLEEP] bigtable_instance bigtable_cluster
usage: metricscaler.py [-h] [--high_cpu_threshold HIGH_CPU_THRESHOLD]
[--low_cpu_threshold LOW_CPU_THRESHOLD]
[--short_sleep SHORT_SLEEP] [--long_sleep LONG_SLEEP]
bigtable_instance bigtable_cluster
Scales Cloud Bigtable clusters based on CPU usage.
positional arguments:
bigtable_instance ID of the Cloud Bigtable instance to connect to.
bigtable_cluster ID of the Cloud Bigtable cluster to connect to.
optional arguments:
-h, --help show this help message and exit
--high_cpu_threshold HIGH_CPU_THRESHOLD
If Cloud Bigtable CPU usage is above this threshold,
scale up
--low_cpu_threshold LOW_CPU_THRESHOLD
If Cloud Bigtable CPU usage is below this threshold,
scale down
--short_sleep SHORT_SLEEP
How long to sleep in seconds between checking metrics
after no scale operation
--long_sleep LONG_SLEEP
How long to sleep in seconds between checking metrics
after a scaling operation
You can read the documentation for more details on API usage and use GitHub to browse the source and report issues.
View the contributing guidelines, the Python style guide for more information.