How to setup web hooks to send message to Slack when Firebase functions crash?

Viewed 368

I need to actively receive crash notifications for firebase functions.

Is there any way to set up Slack webhooks to receive a message when Firebase Functions throw an Error, functions crash, or something like that?

I would love to receive issue messages by velocity ie: Firebase Functions crash 50 times a day.

Thank you so much.

1 Answers

First you have to create a log based (counter) metric that will be counting specific error occurencies and second - you create alerting policy with Slack notification channel.

Let's start from finding corresponding logs that appear when the function throws an error. Since I didn't have one that would crash I used logs that indicated that it was started.

enter image description here

Next you have to create a log based metric. Ignore the next screen and go to Monitoring > Alerting. Click on "Create new policy", find your metric and select "Rolling Window" to whatever time period you need. For testing I used 1 minute. Then set "Rollind windows function" to "mean".

enter image description here

Now configure when the alert has to be triggered - I chose over 3 (within 1 minute window).

enter image description here

On the next screen you select notification channel. In case of Slack it has to be configured first in "Notification Channels".

You can save policy the policy now.

After a few minutes I gathered enough data to generate two incidents: enter image description here

And here's some alerting related documentation that may help you understand how to use them.

Related