Reputation: 13
I am trying to trigger a google cloud function from stackdriver log, say if my VM goes down I need to perform some operation using function. Similar to how we do in AWS with cloudwatch events triggering lambda.
Upvotes: 0
Views: 1062
Reputation: 4544
It's not possible to directly invoke a function from a log, but you can piece it together in two parts:
Export the logs you care about to Cloud Pub/Sub
Subscribe a Cloud Function to the topic
https://cloud.google.com/functions/docs/calling/pubsub and https://cloud.google.com/functions/docs/tutorials/pubsub
Upvotes: 2
Reputation: 598847
You'll want to configure StackDriver to call a webhook, which you then implement as a HTTP-triggered Cloud Function.
Upvotes: 0