Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python monitoring migration #8472

Merged
merged 79 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d282153
move monitoring samples from python-docs-samples (#51)
arithmetic1728 Sep 28, 2020
f42fb46
feat!: move to use microgen (#54)
arithmetic1728 Oct 6, 2020
25cc22b
chore(deps): update dependency google-cloud-monitoring to v2 (#56)
renovate-bot Oct 7, 2020
8d9e5d3
fix: remove gRPC send/recv limits and expose client transport (#62)
yoshi-automation Dec 29, 2020
2f1a4f4
chore(deps): update dependency google-cloud-monitoring to v2.0.1 (#85)
renovate-bot Feb 20, 2021
ead8954
chore(deps): update dependency tabulate to v0.8.9 (#84)
renovate-bot Feb 22, 2021
7447182
feat: Adding labels to the metric descriptor in the snippets.py (#88)
vinbs Mar 2, 2021
1a1c7b5
fix: fix `as_dataframe` (#91)
busunkim96 Mar 12, 2021
14a9845
chore: Updating testing, linting, etc (#94)
yoshi-automation Mar 12, 2021
ae039ba
chore(deps): update dependency google-cloud-monitoring to v2.1.0 (#96)
renovate-bot Mar 16, 2021
46707b7
chore(deps): update dependency google-cloud-monitoring to v2.2.0 (#104)
renovate-bot Mar 25, 2021
d3b3bc4
chore(deps): update dependency google-cloud-monitoring to v2.2.1 (#108)
renovate-bot Mar 29, 2021
b6ae2c4
chore: add constraints file check for python samples (#118)
yoshi-automation Apr 11, 2021
79a7fb4
chore(deps): update dependency pytest to v6.2.3 (#122)
renovate-bot Apr 13, 2021
3262877
chore(deps): update dependency mock to v4.0.3 (#134)
renovate-bot May 12, 2021
e61ab23
chore(deps): update dependency pytest to v6.2.4 (#135)
renovate-bot May 15, 2021
6efcc18
chore: new owl bot post processor docker image (#142)
gcf-owl-bot[bot] May 22, 2021
24c6303
chore: fix flaky samples test due to truncated string (#156)
parthea Jun 18, 2021
d42123b
chore: only enable/disable a single policy in test_enable_alert_polic…
parthea Jun 18, 2021
0e2cc18
chore(deps): update dependency google-cloud-monitoring to v2.3.0 (#158)
renovate-bot Jun 18, 2021
83c152f
chore: add retry in test_list_alert_policies snippets test (#163)
parthea Jun 21, 2021
499c5da
chore: attempt to fix flaky snippet test test_list_alert_policies (#167)
parthea Jun 26, 2021
9a4e951
chore: clean up alert policies older than 1 hour in snippets test (#170)
parthea Jun 29, 2021
47da665
chore(deps): update dependency backoff to v1.11.0 (#174)
renovate-bot Jul 12, 2021
b978995
chore(deps): update dependency google-cloud-monitoring to v2.4.0 (#172)
renovate-bot Jul 12, 2021
35f5438
feat: add Samples section to CONTRIBUTING.rst (#184)
gcf-owl-bot[bot] Jul 22, 2021
ae7c686
chore(deps): update dependency google-cloud-monitoring to v2.4.1 (#187)
renovate-bot Jul 22, 2021
863d821
chore(deps): update dependency backoff to v1.11.1 (#181)
renovate-bot Jul 22, 2021
15bc691
chore(deps): update dependency google-cloud-monitoring to v2.4.2 (#193)
renovate-bot Jul 28, 2021
9ce16cb
chore: fix INSTALL_LIBRARY_FROM_SOURCE in noxfile.py (#197)
gcf-owl-bot[bot] Aug 11, 2021
712d80d
chore: drop mention of Python 2.7 from templates (#199)
gcf-owl-bot[bot] Aug 13, 2021
16faf66
docs(samples): include example writing of label data (#202)
bws0013 Aug 27, 2021
ce44cbf
chore(deps): update dependency google-cloud-monitoring to v2.5.0 (#210)
renovate-bot Aug 31, 2021
70325ce
chore(deps): update dependency pytest to v6.2.5 (#208)
renovate-bot Aug 31, 2021
24798b9
chore(smaples): added imports into snippet (#216)
daniel-sanche Sep 14, 2021
bc9ec5c
chore: blacken samples noxfile template (#217)
gcf-owl-bot[bot] Sep 17, 2021
ed5abaf
chore(deps): update dependency google-cloud-monitoring to v2.5.1 (#223)
renovate-bot Sep 27, 2021
fb5f810
chore: fail samples nox session if python version is missing (#226)
gcf-owl-bot[bot] Sep 30, 2021
313f3e2
chore(deps): update dependency google-cloud-monitoring to v2.6.0 (#232)
renovate-bot Oct 7, 2021
54d2e47
chore(python): Add kokoro configs for python 3.10 samples testing (#237)
gcf-owl-bot[bot] Oct 9, 2021
1a0b4fc
chore(deps): update dependency google-cloud-monitoring to v2.7.0 (#249)
renovate-bot Nov 11, 2021
dfaa974
chore(deps): update dependency google-cloud-monitoring to v2.8.0 (#255)
renovate-bot Nov 20, 2021
c51e992
chore: update python-docs-samples link to main branch (#256)
gcf-owl-bot[bot] Dec 21, 2021
8dd24a5
chore(samples): Add check for tests in directory (#263)
gcf-owl-bot[bot] Jan 11, 2022
6596190
chore(python): Noxfile recognizes that tests can live in a folder (#267)
gcf-owl-bot[bot] Jan 19, 2022
61d0015
chore(deps): update dependency pytest to v7 (#275)
renovate-bot Feb 26, 2022
f1c617e
chore(deps): update all dependencies (#279)
renovate-bot Mar 1, 2022
aead93c
chore: Adding support for pytest-xdist and pytest-parallel (#287)
gcf-owl-bot[bot] Mar 4, 2022
c8f20ed
chore(deps): update dependency google-cloud-monitoring to v2.9.1 (#290)
renovate-bot Mar 8, 2022
5697207
chore(deps): update dependency pytest to v7.1.0 (#292)
renovate-bot Mar 13, 2022
7a23543
chore(deps): update dependency pytest to v7.1.1 (#293)
renovate-bot Mar 19, 2022
aaf9c0a
chore(python): use black==22.3.0 (#299)
gcf-owl-bot[bot] Mar 28, 2022
77f0747
chore(python): add nox session to sort python imports (#311)
gcf-owl-bot[bot] Apr 21, 2022
1d9a44a
chore(deps): update dependency pytest to v7.1.2 (#314)
renovate-bot Apr 25, 2022
47d4d7c
chore(deps): update dependency backoff to v2 (#315)
renovate-bot Apr 26, 2022
e3fdebc
chore(deps): update dependency backoff to v2.0.1 (#317)
renovate-bot Apr 27, 2022
b276146
fix: require python 3.7+ (#459)
gcf-owl-bot[bot] Jul 6, 2022
b091ad6
chore(deps): update all dependencies (#445)
renovate-bot Jul 7, 2022
8e830db
chore(deps): update all dependencies (#467)
renovate-bot Aug 2, 2022
7b61ee1
docs(samples): add docstrings to explain the project ID format (#469)
Shabirmean Aug 6, 2022
af9175e
chore(deps): update all dependencies (#473)
renovate-bot Aug 9, 2022
e2c4cec
chore(deps): update dependency google-cloud-monitoring to v2.11.1 (#479)
renovate-bot Aug 16, 2022
c40b913
chore(deps): update dependency pytest to v7.1.3 (#489)
renovate-bot Sep 6, 2022
8492470
chore: detect samples tests in nested directories (#494)
gcf-owl-bot[bot] Sep 13, 2022
9e94626
chore(deps): update dependency google-cloud-monitoring to v2.11.2 (#498)
renovate-bot Oct 4, 2022
73690ea
chore(deps): update dependency backoff to v2.2.1 (#499)
renovate-bot Oct 6, 2022
1e23252
fix: add missing argument description (#504)
minherz Oct 10, 2022
c73eb17
chore(deps): update dependency tabulate to v0.9.0 (#501)
renovate-bot Oct 18, 2022
9d80149
chore(deps): update dependency google-cloud-monitoring to v2.11.3 (#506)
renovate-bot Oct 18, 2022
fb5cd49
chore(deps): update dependency pytest to v7.2.0 (#507)
renovate-bot Oct 26, 2022
0286f46
fix: add metric label example to the snippet (#509)
minherz Oct 28, 2022
e7acbf8
Merge remote-tracking branch 'migration/main' into python-monitoring-…
arbrown Nov 7, 2022
55060ff
chore: Update company name in license header
arbrown Nov 8, 2022
c1e4eaf
Remove 2.7 from ignored version (test not run)
arbrown Nov 8, 2022
060bfb0
Wrangle noxfile into submission
arbrown Nov 8, 2022
d5444ef
Minor format change
arbrown Nov 8, 2022
a6deaa9
Merge branch 'main' into python-monitoring-migration
arbrown Nov 8, 2022
92e4a39
Update blunderbuss and CODEOWNERS
arbrown Nov 9, 2022
19361b2
Fix blunderbuss config
arbrown Nov 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions monitoring/AUTHORING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md
1 change: 1 addition & 0 deletions monitoring/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/CONTRIBUTING.md
1 change: 1 addition & 0 deletions monitoring/snippets/v3/alerts-client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
backup.json
138 changes: 138 additions & 0 deletions monitoring/snippets/v3/alerts-client/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
.. This file is automatically generated. Do not edit this file directly.

Google Stackdriver Alerting API Python Samples
===============================================================================

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=monitoring/api/v3/alerts-client/README.rst


This directory contains samples for Google Stackdriver Alerting API. Stackdriver Monitoring 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's Alerting API allows you to create, delete, and make back up copies of your alert policies.




.. _Google Stackdriver Alerting API: https://cloud.google.com/monitoring/alerts/

To run the sample, you need to enable the API at: https://console.cloud.google.com/apis/library/monitoring.googleapis.com

To run the sample, you need to have `Monitoring Admin` role.

Please visit [the Cloud Console UI of this API](https://console.cloud.google.com/monitoring) and [create a new Workspace with the same name of your Cloud project](https://cloud.google.com/monitoring/workspaces/create).


Setup
-------------------------------------------------------------------------------


Authentication
++++++++++++++

This sample requires you to have authentication setup. Refer to the
`Authentication Getting Started Guide`_ for instructions on setting up
credentials for applications.

.. _Authentication Getting Started Guide:
https://cloud.google.com/docs/authentication/getting-started

Install Dependencies
++++++++++++++++++++

#. Clone python-docs-samples and change directory to the sample directory you want to use.

.. code-block:: bash

$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.

.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

.. code-block:: bash

$ virtualenv env
$ source env/bin/activate

#. Install the dependencies needed to run the samples.

.. code-block:: bash

$ pip install -r requirements.txt

.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------

Snippets
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=monitoring/api/v3/alerts-client/snippets.py,monitoring/api/v3/alerts-client/README.rst




To run this sample:

.. code-block:: bash

$ python snippets.py

usage: snippets.py [-h]
{list-alert-policies,list-notification-channels,enable-alert-policies,disable-alert-policies,replace-notification-channels,backup,restore}
...

Demonstrates AlertPolicy API operations.

positional arguments:
{list-alert-policies,list-notification-channels,enable-alert-policies,disable-alert-policies,replace-notification-channels,backup,restore}
list-alert-policies
list-notification-channels
enable-alert-policies
Enable or disable alert policies in a project.
Arguments: project_name (str) enable (bool): Enable or
disable the policies. filter_ (str, optional): Only
enable/disable alert policies that match this filter_.
See
https://cloud.google.com/monitoring/api/v3/sorting-
and-filtering
disable-alert-policies
Enable or disable alert policies in a project.
Arguments: project_name (str) enable (bool): Enable or
disable the policies. filter_ (str, optional): Only
enable/disable alert policies that match this filter_.
See
https://cloud.google.com/monitoring/api/v3/sorting-
and-filtering
replace-notification-channels
backup
restore

optional arguments:
-h, --help show this help message and exit





The client library
-------------------------------------------------------------------------------

This sample uses the `Google Cloud Client Library for Python`_.
You can read the documentation for more details on API usage and use GitHub
to `browse the source`_ and `report issues`_.

.. _Google Cloud Client Library for Python:
https://googlecloudplatform.github.io/google-cloud-python/
.. _browse the source:
https://github.com/GoogleCloudPlatform/google-cloud-python
.. _report issues:
https://github.com/GoogleCloudPlatform/google-cloud-python/issues


.. _Google Cloud SDK: https://cloud.google.com/sdk/
33 changes: 33 additions & 0 deletions monitoring/snippets/v3/alerts-client/README.rst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is used to generate README.rst

product:
name: Google Stackdriver Alerting API
short_name: Stackdriver Alerting API
url: https://cloud.google.com/monitoring/alerts/
description: >
Stackdriver Monitoring 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's Alerting API allows you to create,
delete, and make back up copies of your alert policies.

required_api_url: https://console.cloud.google.com/apis/library/monitoring.googleapis.com
required_role: Monitoring Admin
other_required_steps: >
Please visit [the Cloud Console UI of this
API](https://console.cloud.google.com/monitoring) and create a new
Workspace with the same name of your Cloud project.

setup:
- auth
- install_deps

samples:
- name: Snippets
file: snippets.py
show_help: true

cloud_client_library: true

folder: monitoring/api/v3/alerts-client
42 changes: 42 additions & 0 deletions monitoring/snippets/v3/alerts-client/noxfile_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Default TEST_CONFIG_OVERRIDE for python repos.

# You can copy this file into your directory, then it will be inported from
# the noxfile.py.

# The source of truth:
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py

TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
'ignored_versions': ['2.7'],

# Declare optional test sessions you want to opt-in. Currently we
# have the following optional test sessions:
# 'cloud_run' # Test session for Cloud Run application.
'opt_in_sessions': [],

# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
# to use your own Cloud project.
# 'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',

# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
'envs': {},
}
3 changes: 3 additions & 0 deletions monitoring/snippets/v3/alerts-client/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest==7.2.0
retrying==1.3.3
flaky==3.7.0
2 changes: 2 additions & 0 deletions monitoring/snippets/v3/alerts-client/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
google-cloud-monitoring==2.11.3
tabulate==0.9.0
Loading