Skip to main content

More Info:

Ensures all Kubernetes clusters have logging enabled. This setting should be enabled to ensure Kubernetes control plane logs are properly recorded.

Risk Level

Medium

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • HITRUST CSF
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST CSF
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • PCI
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Logging Should Be Enabled” for GCP using GCP console, please follow the below steps:
  1. Login to GCP console (https://console.cloud.google.com/).
  2. Select the project for which you want to enable logging.
  3. In the left navigation menu, select “Logging”.
  4. Click on “Log Exports” tab.
  5. Click on “Create Export” button.
  6. Select the logs which you want to export to Stackdriver Logging.
  7. Choose the destination where you want to export logs to (e.g. BigQuery, Pub/Sub, Cloud Storage).
  8. Configure the export settings as per your requirement.
  9. Click on “Create” button.
Once the above steps are completed, logging will be enabled for your GCP project and you will be able to view logs in the Stackdriver Logging console.

To remediate the misconfiguration “Logging Should Be Enabled” for GCP using GCP CLI, follow these steps:
  1. Open the Cloud Shell in the GCP Console.
  2. Run the following command to enable Stackdriver Logging for all resources in the current project:
  3. If you want to enable Stackdriver Logging for a specific resource, run the following command:
    Replace <resource-type> with the type of resource (e.g. gce_instance, cloud_function) and <resource-name> with the name of the resource.
  4. Verify that Stackdriver Logging is enabled by going to the Logging page in the GCP Console. You should see logs for the resources that you enabled logging for.
  5. Repeat steps 2-4 for all projects and resources in your GCP environment to ensure that logging is enabled for all resources.
By following these steps, you should be able to remediate the “Logging Should Be Enabled” misconfiguration for GCP using GCP CLI.
To remediate the misconfiguration “Logging should be enabled” for GCP using Python, you can follow the below steps:
  1. First, you need to create a service account with the required permissions to enable logging. You can create a service account using the GCP console or using the following Python code:
  1. Next, you need to enable logging for the GCP project. You can use the google-cloud-logging library to enable logging using the following Python code:
  1. Replace project_id with the ID of the GCP project for which you want to enable logging.
  2. Finally, run the Python script to enable logging for the GCP project.
These steps will remediate the misconfiguration “Logging should be enabled” for GCP using Python.
Changing logging_config on an existing google_container_cluster is an in‑place update and should not force cluster replacement.To verify, terraform plan should show either creation of the cluster with the logging_config block set as above, or an in‑place update adding/modifying the logging_config.enable_components list on the existing cluster.

Additional Reading: