Skip to main content

Logging & Monitoring

TSC mapping: CC2 (Information Quality), CC4 (Monitoring Activities), CC7.1 (Vulnerability Detection), CC7.2 (Security Event Monitoring), CC7.3 (Incident Evaluation)

SOC 2 auditors look for three things: that logs exist, that they are tamper-protected, and that someone is actively watching them. All three must be evidenced.


1. Cloud Audit Logs โ€” API Audit Trailโ€‹

Cloud Audit Logs are the foundational audit record for all GCP API activity. Admin Activity logs are always on and cannot be disabled โ€” they are the primary evidence source for CC2 and CC7.2.

There are four log types:

Log typeEnabled by defaultWhat it captures
Admin ActivityYes (always)Resource configuration and metadata changes
Data AccessNo (must enable)API calls that read/write user data
System EventYes (always)GCP system-driven resource changes
Policy DeniedYes (always)Requests denied by VPC Service Controls

Enable Data Access audit logs for sensitive servicesโ€‹

# Enable Data Access logs for Secret Manager, Cloud Storage, BigQuery, and Cloud SQL at the org level
gcloud organizations get-iam-policy <org-id> --format=json > org-policy.json

# Add the following to org-policy.json under auditConfigs, then update:
gcloud organizations set-iam-policy <org-id> org-policy.json
{
"auditConfigs": [
{
"service": "secretmanager.googleapis.com",
"auditLogConfigs": [
{"logType": "DATA_READ"},
{"logType": "DATA_WRITE"},
{"logType": "ADMIN_READ"}
]
},
{
"service": "storage.googleapis.com",
"auditLogConfigs": [
{"logType": "DATA_READ"},
{"logType": "DATA_WRITE"}
]
},
{
"service": "bigquery.googleapis.com",
"auditLogConfigs": [
{"logType": "DATA_READ"},
{"logType": "DATA_WRITE"},
{"logType": "ADMIN_READ"}
]
},
{
"service": "cloudsql.googleapis.com",
"auditLogConfigs": [
{"logType": "DATA_ACCESS"},
{"logType": "ADMIN_READ"}
]
}
]
}

Export all audit logs to a locked log bucketโ€‹

# Create a centralised log bucket with a locked retention policy (1 year)
gcloud logging buckets create soc2-audit-logs \
--project=<log-project-id> \
--location=global \
--retention-days=365 \
--locked # Prevents reducing retention โ€” required for tamper protection

# Create an aggregated log sink at the organisation level
gcloud logging sinks create org-audit-sink \
logging.googleapis.com/projects/<log-project-id>/locations/global/buckets/soc2-audit-logs \
--organization=<org-id> \
--include-children \
--log-filter='logName=~"cloudaudit.googleapis.com"'

# Grant the sink's writer identity access to the destination bucket
SINK_IDENTITY=$(gcloud logging sinks describe org-audit-sink \
--organization=<org-id> \
--format="value(writerIdentity)")

gcloud projects add-iam-policy-binding <log-project-id> \
--member="$SINK_IDENTITY" \
--role="roles/logging.bucketWriter"

Reference: Cloud Audit Logs overview โ†’ ยท Aggregated log sinks โ†’


2. Security Command Center (SCC) โ€” Security Postureโ€‹

Security Command Center is the centralised security and risk platform for GCP. Enable SCC Premium at the organization level to get continuous misconfiguration detection, vulnerability scanning, and threat detection.

# Enable Security Command Center at the organization level
gcloud services enable securitycenter.googleapis.com \
--project=<project-id>

# List all active SCC findings for an organization
gcloud scc findings list <org-id> \
--filter="state=ACTIVE AND severity=HIGH OR severity=CRITICAL" \
--format="table(name,category,severity,resourceName,eventTime)"

# Mute a finding (with justification โ€” document the reason)
gcloud scc findings update <finding-name> \
--organization=<org-id> \
--mute=MUTED

# List Security Health Analytics findings (misconfigurations)
gcloud scc findings list <org-id> \
--source=<sha-source-id> \
--filter="state=ACTIVE" \
--format="table(category,resourceName,severity)"

SCC Premium services to enable:

ServiceWhat it detects
Security Health AnalyticsMisconfigurations (public buckets, open firewall ports, disabled audit logs)
Event Threat DetectionBrute force, cryptomining, data exfiltration, IAM anomalies
Container Threat DetectionRuntime attacks against GKE workloads
VM Threat DetectionMemory-resident malware on Compute Engine VMs
Web Security ScannerOWASP Top 10 vulnerabilities on App Engine and GKE

Reference: Security Command Center โ†’ ยท SCC Premium โ†’


3. VPC Flow Logsโ€‹

VPC Flow Logs capture network traffic metadata (source/destination, port, protocol, bytes) for every VM interface. Required for CC7.2 (monitoring) evidence and SCC threat detection.

# Enable VPC Flow Logs on all subnets in a VPC
for subnet in $(gcloud compute networks subnets list \
--network=prod-vpc \
--project=<project-id> \
--format="value(name,region)"); do
name=$(echo $subnet | awk '{print $1}')
region=$(echo $subnet | awk '{print $2}')
gcloud compute networks subnets update $name \
--region=$region \
--enable-flow-logs \
--logging-aggregation-interval=interval-5-sec \
--logging-flow-sampling=1.0 \
--logging-metadata=include-all \
--project=<project-id>
echo "Enabled flow logs for $name ($region)"
done

# Verify flow logs are enabled
gcloud compute networks subnets list \
--project=<project-id> \
--format="table(name,region,enableFlowLogs)"

Reference: VPC Flow Logs โ†’


4. Cloud Monitoring โ€” Alerting Policiesโ€‹

Configure alerting policies for the security events that SOC 2 auditors expect to be actively monitored.

# Create a notification channel (email)
gcloud beta monitoring channels create \
--display-name="Security Alerts Email" \
--type=email \
--channel-labels=email_address=[email protected] \
--project=<project-id>

CHANNEL_ID=$(gcloud beta monitoring channels list \
--filter="displayName='Security Alerts Email'" \
--format="value(name)" \
--project=<project-id>)

# Alert: IAM policy change on any project
gcloud alpha monitoring policies create \
--display-name="IAM Policy Change" \
--condition-filter='resource.type="audited_resource" AND protoPayload.methodName=~"SetIamPolicy"' \
--condition-display-name="IAM SetIamPolicy called" \
--notification-channels=$CHANNEL_ID \
--project=<project-id>

Log-based metric + alert for critical events (using log sinks):

# Create a log-based metric for project ownership changes
gcloud logging metrics create iam-owner-changes \
--description="Tracks assignment of Owner role" \
--log-filter='protoPayload.serviceName="cloudresourcemanager.googleapis.com" AND
ProjectOwnership OR projectOwnerInvitee OR
protoPayload.serviceData.policyDelta.bindingDeltas.action="ADD" AND
protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner"' \
--project=<project-id>

Required alerts for SOC 2:

AlertLog filter keyword
Project ownership / Owner role changesSetIamPolicy + roles/owner
Audit log configuration changesUpdateSink ยท DeleteSink
VPC firewall rule changescompute.firewalls.insert ยท compute.firewalls.delete
Cloud Storage public access grantedstorage.setIamPolicy + allUsers
Secret Manager access spikessecretmanager.versions.access โ€” rate threshold
SCC HIGH/CRITICAL findingsSCC notification feed via Pub/Sub
Failed login attemptsCloud Identity sign-in audit logs
Service account key creationgoogle.iam.admin.v1.CreateServiceAccountKey

Reference: Cloud Monitoring alerting โ†’ ยท Log-based metrics โ†’


5. Event Threat Detectionโ€‹

Event Threat Detection (ETD) is a built-in SCC Premium service that continuously analyses Cloud Audit Logs and VPC Flow Logs for over 40 threat indicators.

# List ETD findings
gcloud scc findings list <org-id> \
--filter="state=ACTIVE AND sourceProperties.detector_name:ETD" \
--format="table(category,severity,resourceName,eventTime)"

Key detectors:

DetectorWhat it flags
ACCOUNT_LOCKOUTMultiple failed authentication attempts
CRYPTOMININGCompute Engine VMs with mining pool connections
DATA_EXFILTRATIONUnusual large Cloud Storage reads or BigQuery exports
OUTGOING_DOSVMs participating in denial-of-service attacks
PRIVILEGED_ACCESSUnusual use of sensitive IAM roles
MALWARE_BAD_IPConnections to known malicious IPs

Reference: Event Threat Detection โ†’


SOC 2 Evidence for Logging & Monitoringโ€‹

Evidence itemHow to collect
Audit log sink configurationgcloud logging sinks list --organization=<org-id>
Log bucket retention and lock statusgcloud logging buckets list --project=<log-project-id>
Data Access log configurationgcloud organizations get-iam-policy <org-id> --format=json โ†’ auditConfigs section
SCC findings list (past 90 days)gcloud scc findings list <org-id> --filter="state=ACTIVE"
VPC Flow Logs subnet configgcloud compute networks subnets list --format="table(name,enableFlowLogs)"
Cloud Monitoring alert policiesgcloud alpha monitoring policies list
ETD finding historyGCP Console โ†’ Security Command Center โ†’ Findings โ†’ Source: ETD