Praveen
Praveen

Reputation: 13

How to trigger google function from stackdriver logs, similar to how we do in AWS with cloudwatch events triggering lambda?

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

Answers (2)

Kirk Kelsey
Kirk Kelsey

Reputation: 4544

It's not possible to directly invoke a function from a log, but you can piece it together in two parts:

  1. Export the logs you care about to Cloud Pub/Sub

    https://cloud.google.com/logging/docs/export/

  2. 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

Frank van Puffelen
Frank van Puffelen

Reputation: 598847

You'll want to configure StackDriver to call a webhook, which you then implement as a HTTP-triggered Cloud Function.

Upvotes: 0

Related Questions