Prune “log” table to clear excessive REST API logging activity from OCEAN

Share this

So I was running out of disk space on our EMR a little too fast, and after investigating, it seems like our “log” table in the database was bloated by REST API calls from OCEAN doing stuff like checking out all our provider’s schedule for the next 7 days, every 20 minutes:

We use OCEAN for eReferral and it has been great. We don’t use it for appointment booking. We use Veribook, which is great as well (not excessive logging here compared to OCEAN).

All this activity generated 8,797,955 lines of “log” table SQL entries amounting to ~4.5 GB of space in this year 2023 alone. This was how our SQL database grew bloated more than the actual storage rate of patient data accumulated over the years.

Sample log data:

REST WS: ProviderService.getProvidersAsJSONhttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/providerService/providers_jso
REST WS: ScheduleService.getAppointmentTypeshttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/types
REST WS: ScheduleService.getAppointmentReasonshttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/reasons
REST WS: ScheduleService.getScheduleTemplateCodeshttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/codes
REST WS: ScheduleService.getAppointmentStatuseshttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/statuses
REST WS: ScheduleService.getAppointmentsForDayhttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/87/day/2023-12-16
REST WS: ScheduleService.getAppointmentsForDayhttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/87/day/2023-12-17
REST WS: ScheduleService.getAppointmentsForDayhttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/87/day/2023-12-18
REST WS: ScheduleService.getAppointmentsForDayhttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/87/day/2023-12-19
REST WS: ScheduleService.getAppointmentsForDayhttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/87/day/2023-12-20
REST WS: ScheduleService.getAppointmentsForDayhttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/87/day/2023-12-21
REST WS: ScheduleService.getAppointmentsForDayhttps://oscarserver-xxxxx.ca:8443/oscar/ws/services/schedule/87/day/2023-12-22

For those of you who use OCEAN, and are noticing rapid database/disk space usage, consider pruning your “log” table.

Here is my suggestions to prune “log” table for excessive API logs:

~$ df -h

~$ mysql -uroot -p --default-character-set=utf8 --opt --single-transaction --skip-add-drop-table --no-create-info --skip-triggers oscar_15 log > /usr/share/oscar-emr/OscarDocument/oscar/audit_log_purge/backup_audit-log.sql

~$ mysql -uroot -p

mysql> use oscar_15

mysql> delete from log where action like "%REST WS%" and (demographic_no IS NULL or contentId IS NULL or securityId IS NULL) and ip IN ("35.182.46.13","3.98.235.196","15.222.173.33","15.222.94.245",15.222.173.33","15.222.94.245");

msyql> SET GLOBAL innodb_file_per_table=ON

mysql> check table log

mysql> optimize table log

mysql> exit

~$ df -h

Reference:

Security Log Report (Audit Log) – World OSCAR

URLs, and IPs That Need to be Allowlisted for Ocean – OceanMD (cognisantmd.com)