|
| 1 | +Python Client for Stackdriver Monitoring |
| 2 | +======================================== |
| 3 | + |
| 4 | + Python idiomatic client for `Stackdriver Monitoring`_ |
| 5 | + |
| 6 | +.. _Stackdriver Monitoring: https://cloud.google.com/monitoring/ |
| 7 | + |
| 8 | +- `Homepage`_ |
| 9 | +- `API Documentation`_ |
| 10 | + |
| 11 | +.. _Homepage: https://googlecloudplatform.github.io/google-cloud-python/ |
| 12 | +.. _API Documentation: http://googlecloudplatform.github.io/google-cloud-python/ |
| 13 | + |
| 14 | +Quick Start |
| 15 | +----------- |
| 16 | + |
| 17 | +:: |
| 18 | + |
| 19 | + $ pip install --upgrade google-cloud-monitoring |
| 20 | + |
| 21 | +Authentication |
| 22 | +-------------- |
| 23 | + |
| 24 | +With ``google-cloud-python`` we try to make authentication as painless as |
| 25 | +possible. Check out the `Authentication section`_ in our documentation to |
| 26 | +learn more. You may also find the `authentication document`_ shared by all |
| 27 | +the ``google-cloud-*`` libraries to be helpful. |
| 28 | + |
| 29 | +.. _Authentication section: http://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html |
| 30 | +.. _authentication document: https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication |
| 31 | + |
| 32 | +Using the API |
| 33 | +------------- |
| 34 | + |
| 35 | +`Stackdriver Monitoring`_ (`Monitoring API docs`_) collects metrics, |
| 36 | +events, and metadata from Google Cloud Platform, Amazon Web Services (AWS), |
| 37 | +hosted uptime probes, application instrumentation, and a variety of common |
| 38 | +application components including Cassandra, Nginx, Apache Web Server, |
| 39 | +Elasticsearch and many others. Stackdriver ingests that data and generates |
| 40 | +insights via dashboards, charts, and alerts. |
| 41 | + |
| 42 | +This package currently supports all Monitoring API operations other than |
| 43 | +writing custom metrics. |
| 44 | + |
| 45 | +.. _Stackdriver Monitoring: https://cloud.google.com/monitoring/ |
| 46 | +.. _Monitoring API docs: https://cloud.google.com/monitoring/api/ref_v3/rest/ |
| 47 | + |
| 48 | +List available metric types: |
| 49 | + |
| 50 | +.. code:: python |
| 51 | +
|
| 52 | + from google.cloud import monitoring |
| 53 | + client = monitoring.Client() |
| 54 | + for descriptor in client.list_metric_descriptors(): |
| 55 | + print(descriptor.type) |
| 56 | +
|
| 57 | +Display CPU utilization across your GCE instances during the last five minutes: |
| 58 | + |
| 59 | +.. code:: python |
| 60 | +
|
| 61 | + metric = 'compute.googleapis.com/instance/cpu/utilization' |
| 62 | + query = client.query(metric, minutes=5) |
| 63 | + print(query.as_dataframe()) |
| 64 | +
|
| 65 | +See the ``google-cloud-python`` API `monitoring documentation`_ to learn how |
| 66 | +to connect to Stackdriver Monitoring using this Client Library. |
| 67 | + |
| 68 | +.. _monitoring documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/monitoring-usage.html |
0 commit comments