I want to log all the log-based metrics I have in my gcp project with a cloud function in python. I'm trying to run the following code sample:
for metric in client.list_metrics(): # API call(s)
#do_something_with(metric)
print(metric)
I have the following log output:
"<google.cloud.logging_v2.metric.Metric object at 0x3e9bfe2fb4c0>"
How do I read this? I tried list()
, json.loads()
, json.dumps()
but nothing seems to work.
You are getting back a python object:
"<google.cloud.logging_v2.metric.Metric object at 0x3e9bfe2fb4c0>"
According to this documentation it has some properties.
So something like
print(metric.name)
should work for you.