Created
April 10, 2019 08:06
-
-
Save diasjorge/cfddfb600051e7c0e9c03e825eb789f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from google.cloud import monitoring_v3 | |
# # Using a service account with credentials in a json file: | |
# JSON_CREDS = 'monitoring.json' | |
# from oauth2client.service_account import ServiceAccountCredentials | |
# scopes = ["https://www.googleapis.com/auth/monitoring",] | |
# credentials = ServiceAccountCredentials.from_json_keyfile_name( | |
# JSON_CREDS, scopes) | |
# # From inside a GCE instance, with default account: | |
# from oauth2client.contrib.gce import AppAssertionCredentials | |
# credentials = AppAssertionCredentials([]) | |
# 'project' is project ID, not name | |
myproject = 'useful-proposal-454' | |
client = monitoring_v3.MetricServiceClient() | |
name = client.project_path(myproject) | |
# Delete ALL custom metrics from this project. | |
filter_='metric.type = starts_with("custom.googleapis.com/spinnaker/rosco")' | |
for page in client.list_metric_descriptors(name=name, filter_=filter_, retry=None).pages: | |
for element in page: | |
print(element.type) | |
# metric_name = client.metric_descriptor_path(myproject, element.type) | |
# client.delete_metric_descriptor(name=metric_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment