Log entries should have log sinks configured for exporting
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel,
n'hésitez pas à nous contacter.
Description
It is recommended to create a sink that will export copies of all log entries. This can help aggregate logs from multiple projects and export them to a Security Information and Event Management (SIEM).
Rationale
Log entries are held in Cloud Logging. To aggregate logs, export them to a SIEM. To keep them longer, it is recommended to set up a log sink. To export logs, create a filter that selects the log entries to export, and then choose a destination, such as Cloud Storage, BigQuery, or Cloud Pub/Sub, to which to export them. The filter and destination are held in an object called a sink. To ensure all log entries are exported to sinks, ensure that there is no filter configured for a sink. Sinks can be created in projects, organizations, folders, and billing accounts.
Note:
- A sink created by these commands, exports logs to storage buckets. However, sinks can be configured to export logs to BigQuery, or Cloud Pub/Sub, or a
Custom Destination
. - While creating a sink, do not use the sink option
--log-filter
to ensure the sink exports all log entries. - A sink can be created at a folder or organization level that collects the logs of all the projects underneath, bypassing the option
--include-children
in the gcloud
command.
Impact
There are no costs or limitations in Cloud Logging for exporting logs, but the destinations to which the logs are exported charge for storing or transmitting the log data.
Default value
By default, there are no sinks configured.
Finding notes
Currently findings are only audited at the project level. Folder and Organization level log sinks will be audited in the near future. Due to this, a fail
finding may be generated if the log sink is configured at the folder or organization level. In this case the rule may be muted to ensure accurate CSM scoring.
- Go to
Logs Router
by visiting https://console.cloud.google.com/logs/router. - For every sink, click the 3-dot button for Menu options and select
View sink details
. - Ensure there is at least one sink with an
empty
Inclusion filter. - Additionally, ensure that the resource configured as
Destination
exists.
From the console
- Go to the Logs Router page by visiting https://console.cloud.google.com/logs/router.
- Click CREATE SINK.
- Fill out the fields for the Sink details sections.
- Select Cloud Logging bucket in the Select sink destination dropdown menu.
- Select a log bucket in the Sink destination drop down menu.
- If an inclusion filter is not provided for this sink, all ingested logs will be routed to the destination provided above. This may result in higher than expected resource usage.
- Click Create Sink.
From the command line
- To create a sink to export all log entries in a Google Cloud Storage bucket:
gcloud logging sinks create <sink-name>
storage.googleapis.com/DESTINATION_BUCKET_NAME
- Sinks can be created for a folder or organization, which will include all projects.
gcloud logging sinks create <sink-name>
storage.googleapis.com/DESTINATION_BUCKET_NAME --include-children -- folder=FOLDER_ID | --organization=ORGANIZATION_ID
References
- https://cloud.google.com/logging/docs/reference/tools/gcloud-logging
- https://cloud.google.com/logging/quotas
- https://cloud.google.com/logging/docs/routing/overview
- https://cloud.google.com/logging/docs/export/using_exported_logs
- https://cloud.google.com/logging/docs/export/configure_export_v2
- https://cloud.google.com/logging/docs/export/aggregated_exports
- https://cloud.google.com/sdk/gcloud/reference/beta/logging/sinks/list