Skip to content

Security Detections

Avinash Gupta edited this page Oct 18, 2026 · 1 revision

Security detections on RDS logs

"Tell me when someone drops a table" needs two things. The engine has to write the statement to a log, and something has to watch that log. rdstail moves the log; the watching happens in the Loki stack (real-time alerts), Athena or DuckDB (investigation). This page covers the first part, plus the patterns to watch for.

1. Make the engine log what you want to catch

By default RDS logs errors, not statements. A DROP TABLE that succeeds leaves no trace in the default logs.

PostgreSQL (RDS / Aurora)

Pick one. Both are parameter-group changes.

Setting Logs Cost Restart
log_statement = ddl every CREATE/ALTER/DROP/TRUNCATE, as LOG: statement: DROP TABLE … tiny no
pgAudit (recommended for audit): add pgaudit to shared_preload_libraries, CREATE EXTENSION pgaudit;, set pgaudit.log = 'ddl,role' DDL plus GRANT/REVOKE/role changes as AUDIT: SESSION,…,DDL,DROP TABLE,… small with ddl,role; large with write/read yes (preload)
  • Failed logins (FATAL: password authentication failed for user "…", no pg_hba.conf entry) are logged by default.
  • log_connections = 1 adds every successful login. That's useful for "who logged in from where", but noisy.
  • rdstail lifts pgAudit's classification into a structured audit field (class, command, object_type, object_name). Query audit.class IN ('DDL','ROLE') instead of regex where you can.
  • To catch DELETE/UPDATE without WHERE you need DML logging (pgaudit.log including write, or log_statement = mod). Check the volume first: see Performance.

MySQL / MariaDB (RDS)

Setting Logs Cost
MariaDB Audit Plugin (option group MARIADB_AUDIT_PLUGIN) with SERVER_AUDIT_EVENTS = CONNECT,QUERY_DDL,QUERY_DCL logins (incl. FAILED_CONNECT), DDL, GRANT/REVOKE/user changes, one CSV line each small
+ QUERY_DML every INSERT/UPDATE/DELETE large on busy DBs
log_error_verbosity = 3 (parameter group) Access denied for user … in the error log tiny
general_log = 1 every statement very large; avoid in production
  • Set include_audit: true on the rdstail source. Audit-plugin files (audit/server_audit.log*) are opt-in because they can be high-volume.
  • Check the RDS documentation for audit-plugin support on your exact engine version.

2. What to watch for

The same patterns are used by the Loki alert rules, the Grafana dashboard, and the Athena/DuckDB queries. They're regexes over the raw line, so they work across all three engines.

Detection Pattern (case-insensitive) Needs Suggested response
Destructive DDL drop (table|database|schema|view|index|function|procedure|trigger), truncate DDL logging page someone
Privilege change grant, revoke, create/alter/drop/rename user|role, set password pgAudit role / audit QUERY_DCL / log_statement=ddl review same day
Failed-login burst password authentication failed, no pg_hba.conf entry, FAILED_CONNECT, Access denied for user; ≥ 10 in 5 min default (PG), audit CONNECT (MySQL) check client IP; possible brute force or a broken deploy
Whole-table write delete from / update … set with no where DML logging review
Connection exhaustion too many connections, remaining connection slots are reserved default page: an outage is in progress
FATAL / PANIC severity FATAL/PANIC, auth failures excluded default investigate
Repeated deadlocks deadlock detected, Deadlock found default app bug; not urgent unless rising

Ideas that need only a query, not new logging:

  • Logins from a new client IP or user: group failed and successful logins by client, compare to the last 30 days (Athena/DuckDB)
  • DDL outside the deploy window: destructive-DDL query filtered on hour(ts) NOT BETWEEN 9 AND 18
  • Privilege escalation: GRANT … TO naming a superuser/admin role, or ALTER ROLE … SUPERUSER

3. Limits to be honest about

  • Detection, not prevention. Alerts arrive 1–3 minutes after the statement (rdstail poll + ruler interval). Use IAM, least-privilege DB roles and deletion protection to prevent damage.
  • Regex matches text. A DROP TABLE inside a string literal or comment matches too. ETL jobs that drop scratch tables need an exclusion (see the tuning example).
  • Whoever can change the parameter group can turn logging off. Watch the control plane too: a CloudTrail/EventBridge rule on ModifyDBParameterGroup, ModifyOptionGroup and ModifyDBInstance for your production databases. rdstail doesn't read CloudTrail.
  • RDS can lose the last few KB of logs on a crash or failover, before any reader sees them. rdstail recovers everything RDS kept (details).
  • For compliance-grade retention (immutable, provable), see audit logs → immutable S3.

Clone this wiki locally