In our multitenant environment, I would like to setup an alert notification(e.g. email) when our user's code has an exception. I was thinking of using the stackdriver error reporting api to send an error notification. Something like
from google.cloud import error_reporting
client = error_reporting.Client()
try:
raise NameError
except Exception:
client.report_exception()
How can I set this up (using a python api)
- create an alert for a tenant id/service id to send notifications to. I could input user's contact email in this step.
- Report an exception for a tenant id/service id using something like
client.report_exception()
and notify the alert mechanism
Other solutions: This post suggests that I use logging and log errors, create a filter and create an alert policy. That would be an option but I feel it may be expensive as that would mean for each of the services of our users, it will be running the log search query every few seconds/minutes? I was wondering if there was a push approach (vs the logging pull approach) or have I misunderstood that the logging notification is actually a push approach?
If I'm on the wrong path, please feel free to suggest better ways.