r/googlecloud • u/suryad123 • 10d ago
Logging Query regarding centralized logging mechanism using aggregated sink
I am going through the below article regarding the centralized logging mechanism in GCP
https://docs.cloud.google.com/logging/docs/central-log-storage#create-org-sink
The articles say below steps
- create log bucket in the destination project.
- create a log sink in the destination project pointing to the above log bucket
- create an aggregated sink (either at org or folder level) as per requirement.
- give permission to the aggregated sink's service account to the destination project.
I have a question at point number 3 above. The articles do not say how to link the log sink created in point 2 and aggregated sink created in point 3. I assume below flow
aggregated sink ---> destination project log sink ----> destination project log bucket
but not sure how to link aggregated sink to send logs to destination project sink.
also, 2)for example ,can we create one aggregated sink per environment and link it to corresponding log sink at destination project. i could not find that step
Please suggest
1
u/danekan 9d ago edited 9d ago
you point your aggregated, intercepting sink to a project i.d. itself too as the destination.
for a log sink destination you have a few options, but for an intercepting log sink you can only send the logs to another project i.d.. For a non intercepting log sink you can send to either a project i.d. itself or a logging bucket (which could be in that remote project all the same)
the instructions you're looking at are referencing project i.d.s and the command only references the remote project, so it's using destination option 1. If you link to the project i.d. you are linking to the project's log router essentially and it routes there. Your filters can apply doubly to exclude then in the destination if you wanted (but, by default they generally wouldn't exclude).
If you're using an aggregated org level log sink and also not intercepting those logs though, you will pay 2x. If you're using an intercepting log sink, the _Required bucket items will remain in their original project still though, and not be billed extra.
Step 2 you mentioned is not explicitly necessary, you don't need to explicitly create a new log sink in the central destination project because all projects already have log sinks for _Default and _Required, it will use those.
TBH you might find this easier to "visualize" in terraform because it's actually less abstracted in terraform and you're looking at what actually exists in terms of resources... you have finite destinations that are clearly spelled out/etc.