A simple command-line diagnostic tool that helps you identify whether SELECT queries are hitting the writer instance in your Amazon Aurora PostgreSQL cluster. Use this tool to quickly confirm routing problems and take action.
==============================
Aurora Query Routing Checker
==============================
1) Check instance role
2) Show SELECT queries
3) Exit
Select an option: _
Example output from Option 2:
----------------------------------------
Aurora SELECT Query Report
Saved to: aurora_session_log.txt
Timestamp: 2025-06-27 14:42:01 UTC
----------------------------------------
[Instance Role: WRITER]
1. app_user 10.1.4.28 SELECT id, name FROM produ...
2. metrics_bot 10.1.7.33 SELECT count(*) FROM logs ...
(2 queries shown — limited view)
Note: SELECTs are hitting the WRITER. Consider routing them to read replicas.
mkdir aurora_diag
cd aurora_diagpython3 -m venv venvsource venv/bin/activatepip install psycopg2-binaryCreate a file named aurora_query_check.py and paste in the full script contents from the Gist.
nano aurora_query_check.pyPaste, save, and exit.
export DB_HOST=your-db-host.rds.amazonaws.com
export DB_PORT=5432
export DB_NAME=your_db_name
export DB_USER=your_db_user
export DB_PASS=your_passwordpython aurora_query_check.pydeactivateLog output is saved to aurora_session_log.txt in the same folder.
This tool was designed to help engineers quickly detect routing problems in Aurora PostgreSQL clusters—especially in environments where read/write traffic separation is unclear or inconsistent. If you find SELECTs going to your writer, you’ll want to review query endpoints, app logic, and connection pooling strategies.