Creating a notification channel that invokes a function
Written by
Updated at April 17, 2025
You can specify a Cloud Functions function for notification method. This function will be invoked when an alert fires or in an escalation as a standard notification channel.
To set up notifications with Cloud Functions:
Management console
- In the management console
, go to the folder containing the resources you monitor in Monitoring. - From the list of services, select Cloud Functions.
- Create a function and a function version.
- In the settings, enable asynchronous invocation.
- Create a service account with the
functions.functionInvoker
andfunctions.viewer
roles. You will need that account to invoke your function. - From the list of services, select Monitoring.
- Click Create channel.
- Enter a name for your notification channel.
- From the Method list, select Cloud Functions.
- From the Service account list, select an account for running the function.
- Click Create.
Message format when invoking a function in Cloud Functions
When invoking a function in Cloud Functions, the alert or escalation will send a JSON message with details of the triggered alert to the event
argument in the function entry point:
{
"alertId": "",
"alertName": "",
"folderId": "",
"status": "",
"annotations": {
"key1": "value1",
"key2": "value2"
}
}
alertId
: ID of the triggered alert (text).alertName
: Name of the triggered alert (text).folderId
: ID of the folder the alert was triggered in (text).status
: Alert status (text).annotations
: Values of annotations for the triggered alert (key:value
dictionary).
For an example of invoking a function, see Webhook using Cloud Functions.