Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Error Monitoring and Alerting: Include stack trace (textPayload) in notifications

I can query the log explorer to identify my errors I want to alert against:

 
resource.type = "cloud_function"
resource.labels.function_name = "my_function"
resource.labels.region = "us-central1"
 severity>=ERROR
 
I've then configured an alert based on this trigger to send both an email and slack message. I'd like these messages to include the stack trace (found in textPayload). 
 
I found a solution here: https://medium.com/google-cloud/embedding-google-cloud-logging-textpayload-into-email-c4aac0f6f8d1 -- is this really the only way? No other way to include this right in the email?
1 REPLY 1

Hello @david_rise4,

Welcome to Google Cloud Community!

You mentioned that you already configured a log based alert with an email notification. You may find it in this document using the JSON payload. 

If you want to apply this for the textpayload, you might want to use the label extractor key log.extracted_label.KEY. From the cloud console,  go to Monitoring>Alerting>Policies to download the policy definition as JSON then add your label extractors. See this link for your reference

Top Solution Authors