-
-
Save arnecls/9908e7dbe168fec3a8b062fcee50af75 to your computer and use it in GitHub Desktop.
script to delete all custom metrics from a stackdriver account
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 | |
''' | |
Requires you to be logged in via `gcloud auth application-default login`. | |
''' | |
project_id = 'my-project-id' # change project id here | |
metrics_prefix = 'custom.googleapis.com' | |
client = monitoring_v3.MetricServiceClient() | |
project = client.project_path(project_id) | |
# Delete ALL custom metrics from this project. | |
all = client.list_metric_descriptors(project, filter_='metric.type=starts_with("'+metrics_prefix+'")') | |
for a in all: | |
print("deleting: "+a.type) | |
client.delete_metric_descriptor(a.name) | |
print("done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update this seems to be working more recently