0

I am using Cloud Functions on Google Cloud Platform. I have set up a Stackdriver alerting policy to send me notifications when those functions exceed an execution time threshold.

I would like to specifically get the logs for function instances that violate this policy. But when I click on the "Logs" link on the Policy Violation page of the Stackdriver user interface, it shows me all the logs for that function.

How can I filter Cloud Function logs to only get logs of instances which violate a Stackdriver alerting policy?

Update:

To clarify, my intention is to get the text logs of instances that violate a policy, rather than a summary metric.

1 Answers1

0

If you want to filter on Cloud Function logs of an instance which violate a stackdriver alerting policy, then you need to create a "custom metric" (Stackdriver > Logs-based metrics > Create Metric) to get the execution time of a particular function.

You can find more detailed information in this article, Getting Google Cloud Functions times in Stackdriver.

However, the custom metric will parse the logs and give Stackdriver a number you can put in a chart. After that, you can set an alert for that chart.

BSMP
  • 4,596
  • 8
  • 33
  • 44
Mahboob
  • 1,877
  • 5
  • 19
  • Thank you for your input Mahboob, but my understanding is that this will return a summary metric/visualization of the execution times. My intention is to get the text from the logs that violate the policy. Are you aware of a way to do this? – Paul Billing-Ross Sep 16 '19 at 17:54
  • Thank you for your information. Would you please describe the issue more, this will allow me to simulate the issue on test environment? – Mahboob Sep 19 '19 at 01:26