Search code examples
google-cloud-platformterraform-provider-gcp

How to send logs from one gcp project to another gcp project to view in cloud logging


How to send logs from one gcp project to another gcp project so that I can view the logs of the source project in the destination project cloud logging.

I'm thinking about using pub/sub, What I have currently done is

  1. I created log sink in the source project and then I created a topic in the source project to which the logs are sent.
  2. I have created a subscription in the destination project to pull the logs from the topic created in the source project.
  3. now I'm stuck on how to make those logs available for viewing in 'cloud logging' in 'destination project'.

Please advise


Solution

  • You are close, but you didn't select the correct sink. Use the Cloud Logging Bucket sink destination, then select a bucket in another project.

    enter image description here


    EDIT 1:

    When you create your sink, a service account should be created. Grant that service account the role log Writer in the destination project to allow it to write the logs in the foreign project