Search code examples
google-cloud-platformgoogle-cloud-functionsgoogle-cloud-logging

How to get notified when there is an "ERROR" log in Google Cloud Logging for each running Cloud Function?


I would simply like to know if it's possible and how to get notified when my Cloud Function is logging an entry using logging.error in python.

The field actually appears as : "ERROR:root:the custom log"

I have checked about Alert policies but i don't understand the queries / filters and the "time between notification", since i only want to push for example to a Slack channel + email only once a notification when an error is logged.

How can i simply do that for each of my Functions ? or having : policies number = Alert policies x function number, in the worst case scenario..

Thanks in advance


Solution

  • You can do something like :

    (resource.type=“cloud_function” resource.labels.function_name=(“function_name”) resource.labels.region=“europe-west1”)) AND
    textPayload:ERROR AND timestamp > “2023-08-01"