Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google Cloud Functions: monitor errors correctly.

I have a series of Google Cloud Functions that may throw domain errors. They represent a failure to the customer but they do not mean a failure in the code execution. Example:

`throw new https.HttpsError("not-found", "Purchase not found");`
 
I want to create a monitoring dashboard that shows and alerts only errors that are not predicted by my code, but all errors including http errors are finished with status 'error'. How do I properly filter it using MQL or the dashboard UI?
 
Screenshot 2023-08-21 at 00.31.22.png
0 2 357
2 REPLIES 2

rayjohnn
Former Googler

If you go the path using Dashboard UI, you need to go to Logging > Logs Explorer then use the built-in filters to suit your preference. Here is where you define your code to cater what you need to filter out. I attached a link as reference.[1] MQL is more appropriate with Metrics than with Logs, but if you have used metrics from your logs, then you can use MQL to further refine your metrics queries.  Here is a documentation link to help your use case if you choose MQL [2]

[1] https://cloud.google.com/logging/docs/view/logs-explorer-interface

[2] https://cloud.google.com/monitoring/mql/query-editor

I'd like to go with MQL but as I mentioned, with the built-in queries, when I filter all functions with error, it returns every error, including the predicted ones. My difficulty is to filter out the predicted errors, and not using MQL editor itself.