π Notify on anomalous Google Drive access and send weekly email summaries
β‘ 4 views Β· π SecOps & Security Automation
Description
Quick Overview
This workflow monitors Google Workspace Drive audit logs on an hourly and weekly schedule, detecting bulk downloads, access bursts, and new access IPs, then emailing security alerts and a weekly activity digest while also logging both messages to a separate compliance/audit workflow.
How it works
- Runs on two schedules: hourly for anomaly detection and weekly for a firm-wide access summary.
- Pulls Google Drive activity from the Google Workspace Admin Reports API and normalizes each event (user, file name, matter reference pattern, timestamp, and IP address).
- Filters the log to access-only events (view, download, and print) and aggregates counts per user.
- Tracks each userβs known IP addresses over time and flags access from a newly observed IP after a baseline exists.
- Checks each userβs activity against configured thresholds and a cooldown window to decide whether an alert is required.
- For flagged users, generates a formatted alert email, logs the alert by calling a separate n8n compliance workflow, and sends the email via SMTP.
- On the weekly schedule, aggregates the last 7 days into a top-users summary, logs it via the same compliance workflow, and emails the weekly digest.
Setup
- Create Google Workspace Admin Reports API access and add a Google OAuth2/API credential with domain-wide delegation and the
admin.reports.audit.readonlyscope. - Configure an SMTP email credential and set the sender address in
FIRM_FROM_EMAIL. - Set n8n variables for
FIRM_EMAIL(and optionallySECURITY_ALERT_EMAIL) and the anomaly thresholds (LOOKBACK_HOURS,BULK_DOWNLOAD_THRESHOLD,ACCESS_BURST_THRESHOLD,ALERT_COOLDOWN_HOURS). - Update
GUARDRAIL_WORKFLOW_IDto point to the n8n workflow that logs messages for compliance/audit purposes. - If needed, adjust the matter reference regex in the normalization code and the cron expressions for the hourly and weekly schedules.
π Nodes Used
Send Email, HTTP Request, Execute Sub-workflow, Schedule Trigger, Filter
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File