Monitoring production
Now that our app is running in production, we need to keep it working. This means we need to monitor for issues, notably errors and slow performance, as both lead to a poor user experience. To do so, I find it easiest to use Sentry (sentry.io), which can monitor errors and performance in the frontend and backend code.
Monitoring the backend
To monitor the backend, we should create a new project in Sentry and call it backend
. This is where we’ll see any errors and can monitor the performance. The project will have its own data source name (DSN) value, which we’ll need to provide to the app in production. The DSN is found on the project’s configuration page on sentry.io.
To make the DSN available to our app, we need it to be an environment variable in the running container. This is achieved by adding the following to the existing aws_ecs_task_definition
section in infrastructure/aws_cluster.tf:
resource "aws_ecs_task_definition...