Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set stackdriver alerts for specific error messages

Cannot find a clean way to set Stackdriver alert notifications on errors in cloud functions

I am using a cloud function to process data to cloud data store. There are 2 types of errors that I want to be alerted on:

  1. Technical exceptions which might cause function to 'crash'
  2. Custom errors that we are logging from the cloud function

I have done the below,

  • Created a log metric searching for specific errors (although this will not work for 'crash' as the error message can be different each time)
  • Created an alert for this metric in Stackdriver monitoring with parameters as in below code section

This is done as per the answer to the question, how to create alert per error in stackdriver

For the first trigger of the condition I receive an email. However, on subsequent triggers lets say on the next day, I don't. Also the incident is in 'opened' state.

Resource type: cloud function
Metric:from point 2 above
Aggregation: Aligner: count, Reducer: None, Alignment period: 1m
Configuration: Condition triggers if: Any time series violates, Condition: 
is above, Threshold: 0.001, For: 1 min

So I have 3 questions,

  1. Is this the right way to do to satisfy my requirement of creating alerts?

  2. How can I still receive alert notifications for subsequent errors?

  3. How to set the incident to 'resolved' either automatically/ manually?

like image 508
Prasad Sawant Avatar asked Jun 01 '26 19:06

Prasad Sawant


1 Answers

I was having a similar problem and managed to at least get a mail every time. The "trick" seems to be to use sum instead of count in combination with for most recent value - see the screenshot below.

This causes Stackdriver to send a mail everytime a matching log entry is found and closing the issue a minute later.

enter image description here

like image 132
Yourstruly Avatar answered Jun 04 '26 10:06

Yourstruly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!