Skip to main content

Triage and Remediation

Remediation

Using Console

Here’s how to set OCI Logging retention to at least 90 days for Monitoring logs using the OCI Console:
  1. Sign in & choose the correct compartment
    • Log in to the OCI Console.
    • At the top-left, select the Compartment where your Monitoring logs are located.
  2. Open Logging
    • In the left-side menu, go to:
      Observability & Management → Logging → Log Groups.
  3. Select the relevant Log Group
    • In your chosen compartment, click the Log Group that contains your Monitoring logs (for example, monitoring-log-group, or where you configured Monitoring service logs).
  4. Open the Monitoring Log
    • Inside the log group, go to the Logs tab.
    • Locate the Monitoring log (Type will usually be “Service” and Source something like monitoring).
    • Click the name of that log.
  5. Edit the retention period
    • On the log details page, click Edit (or Edit Log).
    • Find the Retention period setting.
    • Change it to 90 days or higher (e.g., 90, 180, etc.).
  6. Save the changes
    • Click Save changes.
    • Confirm the update if prompted.
  7. Repeat for other Monitoring logs / compartments
    • If you have multiple Monitoring logs in other log groups or compartments, repeat the steps so that each relevant Monitoring log has a retention of ≥ 90 days.
This updates the retention for Monitoring logs in the OCI Logging service to meet the 90‑day requirement.
Here’s how to set at least 90 days retention for OCI Logging (Monitoring logs) using the OCI CLI.
Note: In OCI, retention is set on the log group, not the individual log. So you must update the log group where your Monitoring logs are stored.

1. Identify the Log Group for Monitoring Logs

If you already know the log group OCID, skip to step 2.List log groups in the compartment where your Monitoring logs reside:
Find the id of the log group that contains your Monitoring logs
(e.g., id: "ocid1.loggroup.oc1....").
If you need to confirm which logs are Monitoring logs in that group:
Look for logs where source_service is oci_monitoring or similar.

2. Check Current Retention on the Log Group

In the output, check the retention-duration (in days).

3. Update Retention to at Least 90 Days

Set retention to 90 days (or higher if you prefer):
You can also use a higher value, e.g., --retention-duration 180.

4. Verify the Change

Ensure the returned value is >= 90.

If You Also Need Audit Log Retention (Root Tenancy)

For Audit service retention at the tenancy level:
Verify:
Below is how to remediate this with Python using the OCI SDK by updating log retention to at least 90 days for Monitoring-related logs in OCI Logging.

1. Prerequisites

  1. Install the SDK:
  1. Configure your OCI CLI credentials (if not already):
This creates ~/.oci/config with your tenancy, user OCID, key, etc.

2. Concept: What You Actually Change

Retention is set per log in the Logging service.
  • Resource: Log (under a LogGroup)
  • Field: retention_in_days
  • API: LoggingManagementClient.update_log
You need to:
  1. Find the right log group(s) and log(s) (e.g., logs for Monitoring / Audit).
  2. For each log, check retention_in_days.
  3. If < 90, update it to 90 (or more).

3. Python Example: Set Retention for Monitoring Logs to ≥ 90 Days

This script:
  • Uses your default OCI profile.
  • Works in one region (set in your config).
  • Searches all log groups in a compartment.
  • For each log where source_service == "monitoring" (i.e., Monitoring service logs), sets retention to 90 if it’s currently lower.

4. Adapting This for “Audit” Logs in Logging (If You’re Shipping Audit → Logging)

If your organization forwards Audit events into Logging (e.g., via Service Connector):
  • Change the filter to match how you identify those logs, e.g.:
    • By source_service == "audit", or
    • By log_type == "SERVICE" and log.display_name pattern, etc.
Example filter tweak:

5. If You Actually Meant Native OCI Audit Service Retention

If the requirement is specifically “Audit logs retention ≥ 90 days” using the Audit service (not Logging), you must:
  • Use oci.audit.AuditClient.update_configuration.
  • Set retention_period_days in the Audit configuration for the tenancy/compartment.
Minimal example:

If you clarify whether your “Audit” logs are:
  • native Audit service logs, or
  • logs in Logging sourced from Audit/Monitoring,
I can narrow this down to exactly one final script for your setup.
Changing retention_period_days does not force resource replacement; it updates in place.To verify, terraform plan should show the existing retention_period_days changing from its current value (e.g., 30) to 90: