Add view cron jobs and alerting#379
Conversation
|
Is there a place in dpc-app where these view and export SQL scripts can be stored? CDAP shouldn't need to own and review these. |
@gsf We decided a while back to keep all the view and export scripts in the CDAP repo as a source of truth for all the DASG data sources, so the files in this PR are alongside those of AB2D and BCDA. |
jdettmannnava
left a comment
There was a problem hiding this comment.
LGTM
I will say our approach seems pretty different from the other teams', and our file naming scheme uses underscores instead of dashes, but if it doesn't bother cdap it doesn't bother me!
Yeah, this was built in a complete vacuum without knowing the other teams were doing something similar. I also don't think they had the requirement to alert on a failed export. |
What's the final verdict on this? Are we going to keep these in the CDAP repo or move them back to DPC? |
|
I still hold that these SQL files specific to each app should be in app repos because they are managed by app teams. |
|
Closing and moving back to DPC repo. |
🎫 Ticket
https://jira.cms.gov/browse/DPC-5113
🛠 Changes
Adds two new sql scripts:
schedule_view_exports.sql:
pg_cronto schedule exports of the views we created for QuickSight once a day to thedpc-prod-aurora-export-20251028154132844600000001S3 bucket.config_cron_alerts.sql:
check_cron_statusthat checks the status of apg_cronjob to see if it failed. If so, it uses thebcda-prod-alarm-to-slackLambda to send a message to the #dpc_alerts Slack channel.check_cron_statuswhenever a row is inserted/updated to thecron.job_run_detailstable.ℹ️ Context
We've been asked to export these views to the S3 bucket every six hours so they can be imported into QuickSight.
Some quick notes:
aws_s3andaws_lambdaextensions in Postgres.pg_cronwas already installed.dpc-prod-aurora-lambda-rolethat has permissions (dpc-prod-aurora-lambda) to call our Slack lambda and added it to the IAM roles assigned to our RDS instance. This should be moved to OpenTofu when the infra is built there.🧪 Validation
Currently running, you can open up the S3 bucket and see the exports:

dpc-prod DB has a new role attached (

dpc-prod-aurora-lambda-role) giving it access to call our Lambda:Alerts are being sent to Slack when an export fails. To test, go into the

cron.job_run_detailsand update the status on a row: