8000 Add bigtable regions (#982) · maxkferg/python-docs-samples@3a01559 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a01559

Browse files
authored
Add bigtable regions (GoogleCloudPlatform#982)
* Add bigtable regions * fix lint
1 parent 88700c3 commit 3a01559

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bigtable/autoscaler/autoscaler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ def get_cpu_load():
3030
Returns:
3131
float: The most recent Bigtable CPU usage metric
3232
"""
33+
# [START bigtable_cpu]
3334
client = monitoring.Client()
3435
query = client.query('bigtable.googleapis.com/cluster/cpu_load', minutes=5)
3536
time_series = list(query)
3637
recent_time_series = time_series[0]
3738
return recent_time_series.points[0].value
39+
# [END bigtable_cpu]
3840

3941

4042
def scale_bigtable(bigtable_instance, bigtable_cluster, scale_up):
@@ -50,6 +52,7 @@ def scale_bigtable(bigtable_instance, bigtable_cluster, scale_up):
5052
bigtable_cluster (str): Cloud Bigtable cluster id to scale
5153
scale_up (bool): If true, scale up, otherwise scale down
5254
"""
55+
# [START bigtable_scale]
5356
bigtable_client = bigtable.Client(admin=True)
5457
instance = bigtable_client.instance(bigtable_instance)
5558
instance.reload()
@@ -74,6 +77,7 @@ def scale_bigtable(bigtable_instance, bigtable_cluster, scale_up):
7477
cluster.update()
7578
print('Scaled from {} up to {} nodes.'.format(
7679
current_node_count, new_node_count))
80+
# [END bigtable_scale]
7781

7882

7983
def main(

0 commit comments

Comments
 (0)
0