Other Articles

General – Configure a Log Sink

Secure Configuration Checks > GCP

This check ensures that the project has an enabled user-defined log sink with a destination. The built-in _Default and _Required sinks do not count.

Check Details

  • Resource: Google Cloud Project
  • Check: Configure a log sink
  • Risk: Without a log sink, logs stay in the project and expire after the default retention period. You cannot keep them for audits or send them to a security tool.

Remediation via Google Cloud Console

  1. Log in to the Google Cloud Console and navigate to Monitoring > Log Router. Log Router page
  2. Click Create sink.
  3. Enter a Sink name and a description. Click Next. Log sink details
  4. Under Sink destination, select a service, such as a Cloud Storage bucket, and select the destination. Click Next. Log sink destination
  5. Under Choose logs to include in sink, leave the filter empty to include all logs. Click Next.
  6. Click Create sink.
  7. If a user-defined sink already exists but is disabled, click More actions next to it and select Enable sink.

Remediation via Google Cloud CLI

  1. Open the Google Cloud Console and launch Cloud Shell. GCP Cloud Shell
  2. Create a log sink that sends logs to a Cloud Storage bucket:

    gcloud logging sinks create <SINK_NAME> \
    storage.googleapis.com/<BUCKET_NAME>
    

    Replace <SINK_NAME> with a name for the sink and <BUCKET_NAME> with your bucket name. For BigQuery, use bigquery.googleapis.com/projects/<PROJECT_ID>/datasets/<DATASET>. For Pub/Sub, use pubsub.googleapis.com/projects/<PROJECT_ID>/topics/<TOPIC>.

  3. Allow the sink to write to the bucket:

    WRITER=$(gcloud logging sinks describe <SINK_NAME> \
      --format="value(writerIdentity)")
    
    gcloud storage buckets add-iam-policy-binding gs://<BUCKET_NAME> \
    --member="$WRITER" \
    --role="roles/storage.objectCreator"
    

    For BigQuery, grant roles/bigquery.dataEditor on the dataset. For Pub/Sub, grant roles/pubsub.publisher on the topic.

  4. If the sink already exists but is disabled, enable it:

    gcloud logging sinks update <SINK_NAME> --no-disabled
    
  5. Verify the sinks of the project:

    gcloud logging sinks list --format="table(name,destination,disabled)"
    

    The list shows your sink next to _Default and _Required. Your sink must have a destination and must not be disabled.

Default Value

Every project has the built-in _Required and _Default sinks. They route logs to the project's own log buckets. No user-defined sink exists unless you create one.

Updated on 09 November, 2026