Paths with most access denied responses

Get list of paths that returned most of 401 and 403 response status codes in your API Gateway access log group.

Cloudwatch Log Insights snippet that returns top 10 of the API paths with the most 401 and 403 response status codes.
See snippet GitHub repository for the logging setup instructions.

Copy the code into CloudWatch Logs Insights

stats count(*) as accessDeniedCount by status, path, httpMethod
| filter status=403 or status=401
| limit 10
                                


< Back to snippets

GitHub icon View this snippet on GitHub


Running the CloudWatch snippet

Click on the button below to open up the snippet directly into your AWS account.

Manually running the CloudWatch snippet

2. Select Logs, and then choose Logs Insights.
3. In the Select log group(s) drop down, choose one or more log groups to query.
4. Copy snippet into query text area.
5. Click "Run Query"

Created by:

Giedrius Praspaliauskas

Giedrius Praspaliauskas

Giedrius is a senior solutions architect focusing on serverless at Amazon Web Services based in the US.

Follow on LinkedIn