Repository navigation
Security Detections
Avinash Gupta edited this page Oct 18, 2026
·
1 revision
"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.
By default RDS logs errors, not statements. A DROP TABLE that succeeds
leaves no trace in the default logs.
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 = 1adds every successful login. That's useful for "who logged in from where", but noisy. - rdstail lifts pgAudit's classification into a structured
auditfield (class,command,object_type,object_name). Queryaudit.class IN ('DDL','ROLE')instead of regex where you can. - To catch
DELETE/UPDATEwithoutWHEREyou need DML logging (pgaudit.logincludingwrite, orlog_statement = mod). Check the volume first: see Performance.
| 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: trueon 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.
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 … TOnaming a superuser/admin role, orALTER ROLE … SUPERUSER
- 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 TABLEinside 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,ModifyOptionGroupandModifyDBInstancefor 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.