Skip to content

Commit 682fca9

Browse files
author
Jon Wayne Parrott
authored
Update monitoring library to use new generated client (#5212)
1 parent 278386b commit 682fca9

72 files changed

Lines changed: 13333 additions & 5615 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/google-cloud-monitoring/.coveragerc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
branch = True
33

44
[report]
5-
fail_under = 100
5+
omit =
6+
*/gapic/*
7+
*/proto/*
68
show_missing = True
9+
710
exclude_lines =
811
# Re-enable the standard pragma
912
pragma: NO COVER
1013
# Ignore debug-only repr
1114
def __repr__
15+
# Ignore abstract methods
16+
raise NotImplementedError
Lines changed: 77 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,103 @@
1-
Python Client for Stackdriver Monitoring
2-
========================================
1+
Python Client for Stackdriver Monitoring API (`Alpha`_)
2+
=======================================================
33

4-
Python idiomatic client for `Stackdriver Monitoring`_
4+
`Stackdriver Monitoring API`_: Manages your Stackdriver Monitoring data and configurations. Most projects
5+
must be associated with a Stackdriver account, with a few exceptions as
6+
noted on the individual method pages.
57

6-
.. _Stackdriver Monitoring: https://cloud.google.com/monitoring/
8+
- `Client Library Documentation`_
9+
- `Product Documentation`_
710

8-
|pypi| |versions|
9-
10-
- `Documentation`_
11-
12-
.. _Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/monitoring/usage.html
11+
.. _Alpha: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
12+
.. _Stackdriver Monitoring API: https://cloud.google.com/monitoring
13+
.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/monitoring/usage.html
14+
.. _Product Documentation: https://cloud.google.com/monitoring
1315

1416
Quick Start
1517
-----------
1618

17-
.. code-block:: console
19+
In order to use this library, you first need to go through the following steps:
20+
21+
1. `Select or create a Cloud Platform project.`_
22+
2. `Enable billing for your project.`_
23+
3. `Enable the Stackdriver Monitoring API.`_
24+
4. `Setup Authentication.`_
25+
26+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
27+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
28+
.. _Enable the Stackdriver Monitoring API.: https://cloud.google.com/monitoring
29+
.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/latest/core/auth.html
30+
31+
Installation
32+
~~~~~~~~~~~~
1833

19-
$ pip install --upgrade google-cloud-monitoring
34+
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
35+
create isolated Python environments. The basic problem it addresses is one of
36+
dependencies and versions, and indirectly permissions.
2037

21-
For more information on setting up your Python development environment,
22-
such as installing ``pip`` and ``virtualenv`` on your system, please refer
23-
to `Python Development Environment Setup Guide`_ for Google Cloud Platform.
38+
With `virtualenv`_, it's possible to install this library without needing system
39+
install permissions, and without clashing with the installed system
40+
dependencies.
2441

25-
.. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup
42+
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
2643

27-
Authentication
28-
--------------
2944

30-
With ``google-cloud-python`` we try to make authentication as painless as
31-
possible. Check out the `Authentication section`_ in our documentation to
32-
learn more. You may also find the `authentication document`_ shared by all
33-
the ``google-cloud-*`` libraries to be helpful.
45+
Mac/Linux
46+
^^^^^^^^^
3447

35-
.. _Authentication section: https://google-cloud-python.readthedocs.io/en/latest/core/auth.html
36-
.. _authentication document: https://github.com/GoogleCloudPlatform/google-cloud-common/tree/master/authentication
48+
.. code-block:: console
49+
50+
pip install virtualenv
51+
virtualenv <your-env>
52+
source <your-env>/bin/activate
53+
<your-env>/bin/pip install google-cloud-monitoring
54+
55+
56+
Windows
57+
^^^^^^^
58+
59+
.. code-block:: console
3760
38-
Using the API
39-
-------------
61+
pip install virtualenv
62+
virtualenv <your-env>
63+
<your-env>\Scripts\activate
64+
<your-env>\Scripts\pip.exe install google-cloud-monitoring
4065
41-
`Stackdriver Monitoring`_ (`Monitoring API docs`_) collects metrics,
42-
events, and metadata from Google Cloud Platform, Amazon Web Services (AWS),
43-
hosted uptime probes, application instrumentation, and a variety of common
44-
application components including Cassandra, Nginx, Apache Web Server,
45-
Elasticsearch and many others. Stackdriver ingests that data and generates
46-
insights via dashboards, charts, and alerts.
66+
Preview
67+
~~~~~~~
4768

48-
This package currently supports all Monitoring API operations other than
49-
writing custom metrics.
69+
MetricServiceClient
70+
^^^^^^^^^^^^^^^^^^^
5071

51-
.. _Monitoring API docs: https://cloud.google.com/monitoring/api/ref_v3/rest/
72+
.. code:: py
5273
53-
List available metric types:
74+
from google.cloud import monitoring_v3
5475
55-
.. code:: python
76+
client = monitoring_v3.MetricServiceClient()
5677
57-
from google.cloud import monitoring
58-
client = monitoring.Client()
59-
for descriptor in client.list_metric_descriptors():
60-
print(descriptor.type)
78+
name = client.project_path('[PROJECT]')
6179
62-
Display CPU utilization across your GCE instances during the last five minutes:
6380
64-
.. code:: python
81+
# Iterate over all results
82+
for element in client.list_monitored_resource_descriptors(name):
83+
# process element
84+
pass
6585
66-
metric = 'compute.googleapis.com/instance/cpu/utilization'
67-
query = client.query(metric, minutes=5)
68-
print(query.as_dataframe())
86+
# Or iterate over results one page at a time
87+
for page in client.list_monitored_resource_descriptors(name, options=CallOptions(page_token=INITIAL_PAGE)):
88+
for element in page:
89+
# process element
90+
pass
6991
70-
See the ``google-cloud-python`` API `monitoring documentation`_ to learn how
71-
to connect to Stackdriver Monitoring using this Client Library.
92+
Next Steps
93+
~~~~~~~~~~
7294

73-
.. _monitoring documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/monitoring/usage.html
95+
- Read the `Client Library Documentation`_ for Stackdriver Monitoring API
96+
API to see other available methods on the client.
97+
- Read the `Stackdriver Monitoring API Product documentation`_ to learn
98+
more about the product and see How-to Guides.
99+
- View this `repository’s main README`_ to see the full list of Cloud
100+
APIs that we cover.
74101

75-
.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-monitoring.svg
76-
:target: https://pypi.org/project/google-cloud-monitoring/
77-
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-monitoring.svg
78-
:target: https://pypi.org/project/google-cloud-monitoring/
102+
.. _Stackdriver Monitoring API Product documentation: https://cloud.google.com/monitoring
103+
.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst

0 commit comments

Comments
 (0)