Managing operations · Topic 2 of 3
Network Logs, Cloud IDS and a Secure Logging Strategy
Analyze VPC Flow Logs, firewall and Cloud NGFW logs, Packet Mirroring and Cloud IDS in Log Analytics, and plan a logging strategy with secure access.
- 5 min
- VPC Flow Logs are per subnet and sampled; firewall logging is per rule.
- Cloud IDS detects using mirrored traffic; Cloud NGFW Enterprise prevents inline.
- Log Analytics queries log buckets with SQL; link a BigQuery dataset to join data.
What it is
Network logs show who talked to whom, which firewall rule decided it, and whether the traffic looked malicious. A logging strategy decides which logs to collect, where to keep them, for how long, and who may read them.
How it works
Network log sources
| Source | Records | Turn on |
|---|---|---|
| VPC Flow Logs | Sampled connection records: IPs, ports, bytes, packets, VM and network metadata | Per subnet, with sampling rate and aggregation interval |
| Firewall Rules Logging | Each connection allowed or denied by a rule, with the rule name | Per rule or policy rule (--enable-logging) |
| Cloud NGFW threat logs | Threats detected or blocked by intrusion prevention | Generated by Cloud NGFW Enterprise security profiles |
| Cloud IDS | Threat alerts for traffic mirrored to an IDS endpoint | IDS endpoint plus a Packet Mirroring policy |
| Packet Mirroring | Full copies of packets sent to collectors | Mirroring policy by subnet, network tag or instance |
| Cloud DNS, Cloud NAT, load balancer and Cloud Armor logs | Queries, translations, requests and rule matches | Per policy, gateway or backend service |
gcloud compute networks subnets update app-subnet --region=europe-west1 \
--enable-flow-logs --logging-aggregation-interval=interval-5-sec \
--logging-flow-sampling=0.5
gcloud compute firewall-rules update allow-ssh-from-iap --enable-logging
Packet Mirroring and Cloud IDS
Packet Mirroring clones traffic of chosen VMs to a collector group behind an internal passthrough Network Load Balancer, for deep packet inspection by your own tools. Cloud IDS is a managed intrusion detection service built on Palo Alto Networks threat technology. It receives mirrored traffic at an IDS endpoint and writes threat logs to Cloud Logging.
| Need | Choose |
|---|---|
| Detect threats, alert only, managed | Cloud IDS |
| Detect and block threats inline | Cloud NGFW Enterprise intrusion prevention |
| Send full packets to a third-party tool | Packet Mirroring to your collectors |
| Understand traffic volumes and paths | VPC Flow Logs |
| Prove which rule allowed or denied a connection | Firewall Rules Logging |
Analyzing logs with Log Analytics
Upgrade a log bucket to use Log Analytics and query logs with SQL. A linked BigQuery dataset lets you join logs with other data.
SELECT
JSON_VALUE(json_payload.connection.src_ip) AS src_ip,
JSON_VALUE(json_payload.connection.dest_ip) AS dest_ip,
COUNT(*) AS flows
FROM `net-logs.global._Default._AllLogs`
WHERE log_id = 'compute.googleapis.com/vpc_flows'
AND timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
GROUP BY src_ip, dest_ip
ORDER BY flows DESC
LIMIT 20;
Designing an effective logging strategy
| Decision | Good practice |
|---|---|
| What to collect | Admin Activity always; Data Access for sensitive services; network logs for regulated and internet-facing networks |
| Where | Centralize with aggregated sinks into a dedicated logging project |
| How long | Match regulation: short in hot storage, longer in Cloud Storage or locked log buckets |
| Cost | Sampling and filtering for flow logs; exclusion filters for noisy, low-value logs |
| Integrity | Locked retention on log buckets and Cloud Storage; restricted write access |
| Use | Log-based metrics and alerts, SIEM export, Log Analytics for investigation |
Turning on everything is expensive and noisy. Turning on too little leaves you blind during an incident.
Designing secure access to logs
| Control | Use |
|---|---|
Logs Viewer (roles/logging.viewer) | Read most logs, but not Data Access audit logs |
Private Logs Viewer (roles/logging.privateLogViewer) | Also read Data Access audit logs, which may contain sensitive request details |
Log views with View Accessor (roles/logging.viewAccessor) | Give a team access to a filtered subset of a bucket, such as one project's logs |
| Logging project | Separate project for central logs; few people have admin rights |
| CMEK on log buckets | Customer control of the keys protecting stored logs |
| Bucket lock | Retention that even administrators cannot shorten |
Grant log access to groups, and keep the people who administer workloads separate from those who can change or delete the security logs about them.
A worked example
After a suspected breach, the security team needs to know which internal VMs talked to an unknown external address. Flow logs were off in most subnets, so there is no record.
The engineer enables flow logs with 50 percent sampling on all production subnets, firewall logging on deny rules, and Cloud IDS for the database subnet. An aggregated sink sends network and audit logs to a locked bucket in the logging project, upgraded for Log Analytics, and app teams get log views for their own projects only.
How the exam asks about this
- "Identify which firewall rule blocked a connection between two VMs." Turn on Firewall Rules Logging for the relevant rules and check the logs.
- "Detect malware and exploit traffic to sensitive VMs without deploying or managing appliances, alert only." Cloud IDS with Packet Mirroring.
- "Let an application team read logs for its own project from the central log bucket, but not other teams' logs." A log view on the bucket, granted with View Accessor.
What to remember for the exam
- VPC Flow Logs are per subnet and sampled; firewall logging is per rule.
- Cloud IDS detects using mirrored traffic; Cloud NGFW Enterprise prevents inline.
- Log Analytics queries log buckets with SQL; link a BigQuery dataset to join data.
- Centralize logs in a logging project with retention, locking and CMEK as required.
- Logs Viewer cannot see Data Access logs; Private Logs Viewer can; log views narrow access.
Cloud IDS does not block traffic. If the requirement says "prevent" or "block" threats in network traffic, choose Cloud NGFW Enterprise intrusion prevention.
Common mistakes
Expecting flow logs to show payloads. Flow logs hold connection metadata only. Packet contents need Packet Mirroring.
Granting Private Logs Viewer widely. Data Access logs can reveal who read what and sometimes request content. Grant it only to investigators.
Turning on full logging everywhere without a plan. Costs rise and signals drown. Choose logs by risk, sample flow logs, and exclude noise.
Check yourself
Which logs record whether a specific firewall rule allowed or denied a connection?
Firewall Rules Logging, enabled on that rule or firewall policy rule.
How does Cloud IDS receive traffic to inspect?
Through a Packet Mirroring policy that sends copies of traffic to the IDS endpoint.
Which role is needed to read Data Access audit logs?
Private Logs Viewer, because Logs Viewer excludes Data Access logs.
Topic 2 of 3 in Managing operations
Test yourself on Managing operations
The full Google Cloud Professional Cloud Security Engineer question bank has 749 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Google Cloud. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.