express
express copied to clipboard
Express Metrics & Insights
Now that we have component instances monitored on the dashboard, we could take advantage of CloudWatch Insights for components that uses Lambda by running queries specific to each use case. This issue describes the express use case.
Because the express component is not super high level and could be used for multiple use cases, we could offer value mainly at the request, response & error level. However if we're creative enough, I think we can offer great value just by logging the requests, responses and errors. Imo the most relevant data for tracking things down are requests, more so than responses.
Here are some queries, express with function calls, that I think are relevant for express users. These are just off the top of my head and I already feel the value. The more I learn about CloudWatch insights and the kind of queries I can make, the more useful functions we could add here.
Stats Queries
These are queries that provides numbers, metrics or counts.
countRequestsByPathAndMethod(path, method)countAuthenticatedRequests()countUnauthenticatedRequests()countRequestsByStatusCode(500)countRequestsByJsonBody({ foo: bar })countRequestsByErrorMessage('something bad happened')countRequestsByErrorCode('NotFound')countFailedRequests()getAverageResponseTime()getMaximumResponseTime()getAverageMemoryUsed()getMaximumMemoryUsed()
Data Queries
These are queries that shows full log data, rather than just metrics.
getRequestsByPathAndMethods('/users', 'POST')getAuthenticatedRequests()getUnAuthenticatedRequests()getRequestsByJsonBody({ foo: bar })- requests that includes this json data in body.getRequestsByStatusCode(500)getRequestsByMinimumResponseTime(200)- requests that took more than 200getRequestsByErrorMessage('internal server error')getRequestsByErrorCode('NotFound')getErrors()