Review audit-configuration change logs and alerts

Record changes to audit coverage and notify the responsible operators.

Description

Alert the operations team when someone changes which Google Cloud audit events are recorded.

Potential impact

If an audit change reduces coverage, later investigations may lack records from that period.

Remediation

Check a real audit entry for SetIamPolicy and auditConfigDeltas, then match those fields in the log metric. Reference the metric in the alert condition and set notification_channels. Make an authorized test change and confirm the log entry, metric count and notification.

Examples

The first example has the wrong method and an incomplete condition. In the second, set var.audit_monitored_resource_type to a resource type the metric reports. Adjust the 10-minute window for ingestion delay.

Before

hcl
resource "google_logging_metric" "audit_config_change" {
  name        = "audit_config_change"
  description = "Detects changes to audit configurations via SetIamPolicy"
  filter      = "protoPayload.methodName=\"wrong_method\" AND protoPayload.serviceData.policyDelta.auditConfigDeltas:*"
}

resource "google_monitoring_alert_policy" "audit_config_alert" {
  display_name = "Audit Config Change Alert"
  combiner     = "OR"

  conditions {
    display_name = "Audit Config Change Condition"

    condition_threshold {
      filter = "resource.type=\"gce_instance\" AND metric.type=\"logging.googleapis.com/user/audit_config_change\""
    }
  }
}

After

hcl
resource "google_logging_metric" "audit_config_change" {
  name        = "audit_config_change"
  description = "Detects changes to audit configurations via SetIamPolicy"
  filter      = "protoPayload.methodName=\"SetIamPolicy\" AND protoPayload.serviceData.policyDelta.auditConfigDeltas:*"
}

resource "google_monitoring_alert_policy" "audit_config_alert" {
  display_name          = "Audit Config Change Alert"
  combiner              = "OR"
  notification_channels = [google_monitoring_notification_channel.security_ops.name]

  conditions {
    display_name = "Matching audit events"
    condition_threshold {
      filter = "metric.type=\"logging.googleapis.com/user/${google_logging_metric.audit_config_change.name}\" AND resource.type=\"${var.audit_monitored_resource_type}\""
      comparison      = "COMPARISON_GT"
      threshold_value = 0
      duration        = "0s"
      aggregations {
        alignment_period   = "600s"
        per_series_aligner = "ALIGN_SUM"
      }
    }
  }
}

References