Python idiomatic client for Stackdriver Monitoring
$ pip install --upgrade google-cloud-monitoringWith google-cloud-python we try to make authentication as painless as
possible. Check out the Authentication section in our documentation to
learn more. You may also find the authentication document shared by all
the google-cloud-* libraries to be helpful.
Stackdriver Monitoring (Monitoring API docs) collects metrics, events, and metadata from Google Cloud Platform, Amazon Web Services (AWS), hosted uptime probes, application instrumentation, and a variety of common application components including Cassandra, Nginx, Apache Web Server, Elasticsearch and many others. Stackdriver ingests that data and generates insights via dashboards, charts, and alerts.
This package currently supports all Monitoring API operations other than writing custom metrics.
List available metric types:
from google.cloud import monitoring
client = monitoring.Client()
for descriptor in client.list_metric_descriptors():
print(descriptor.type)Display CPU utilization across your GCE instances during the last five minutes:
metric = 'compute.googleapis.com/instance/cpu/utilization'
query = client.query(metric, minutes=5)
print(query.as_dataframe())See the google-cloud-python API monitoring documentation to learn how
to connect to Stackdriver Monitoring using this Client Library.