We have an API Gateway setup with a MockIntegration method. Our deployed stage also has detailed metrics enabled and we can see the following metrics in Cloudwatch:
Count
Latency
5xx errors
4xx errors
However, according to this documentation, API Gateway should also be reporting IntegrationLatency. This metric is missing in Cloudwatch.
Does MockIntegration not support IntegrationLatency? When we eventually move to an actual backend integration, will the metric appear in Cloudwatch?
Related
I have created an API Gateway in AWS with two resources (endpoints). Let's say /foo and /bar. Each endpoint has a POST method.
I want to monitor how many times each endpoint got invoked - /foo and /bar in our example. And the metrics to show the 2xx, 4xx, and 5xx responses.
I know API Gateway got a generic "API Calls" metric that shows the total invocations of the API. But how do I monitor how many times each endpoint got called?
You can filter API Gateway metrics for the API method with the specified API name, stage, resource, and method.
API Gateway will not send these metrics unless you have explicitly enabled detailed CloudWatch metrics. You can do this in the console by selecting Enable Detailed CloudWatch Metrics under a stage Logs/Tracing tab. Alternatively, you can call the update-stage AWS CLI command to update the metricsEnabled property to true.
Enable Detailed CloudWatch Metrics on AWS Console:
Documentation:
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-metrics-and-dimensions.html#api-gateway-metricdimensions
I am unable to figure out the difference what does enable detailed cloud watch metrics does in aws - api gateway - logs/traces
Detailed CloudWatch metrics for API Gateway will include individual metric data to breakdown each resource/method combination too.
With this enabled you can visualise performance for specific requests such as a /search request latency, or alarm if you return 5XX errors for your /book request.
By default CloudWatch metrics are limited to API and stage.
Enabling this has no effect on logs/traces.
Currently, AWS API Gateway provides a mechanism for setting up Usage Plans, associations with API keys, and quota limitations for each plan or more fine-grained limits for methods. But this quota is "hard", i.e. it will restrict further API access with HTTP 429 if reached. Is there any recommended way to configure "soft" quotas – for instance, how can one just monitor events caused such limitation exceeding?
As I understand, there is nothing to with API Gateway's custom gateway responses, as they are bound to HTTP 4XX and 5XX error status codes. According to underlying idea, reaching "soft" limit is not considered as an error and API access should be still enabled.
I am preparing for AWS exam and I found some documentation about AWS CloudTrail and AWS X-RAY where it creates confusion on their usage requirement.
I have came across following question where requirement was to trace and analyse the user request as it travels through Amazon API Gateway APIs to underlying services.
As per my understanding, we can use CludTrail to trace and analyse the user request. But the correct answer was AWS XRAY.
The documents which have referred mentions that, we can use AWS CloudTrail logs for tracing,Security Analysis, Resource Change Tracking and Compliance/Auditing. On the other hand, we can use AWS X-RAY to analyse and debug applications running on distributed micro service architecture.
XRAY and CloudTrail usage both have the term Analyse and trace. So it is quite confusing to which service should we choose under such requirement to trace and analyse the user request
X-Ray is more detailed in the information it provides for the request's flow and state. It scans the request all the way through its lifetime from when it is received in the api gateway to whatever services are called and executed after that. So I imagine that is why it is the preferred option.
I am using AWS Api Gateway and I'd like to trace full request and response. Some of my integrations are lambdas and some other http endpoints.
I enabled stage > Logs > "Log full requests/responses data" and I can see logs on CloudWatch.
This seemed to be perfect until I discovered bodies were being TRUNCATED... There is a limitation of 1024 bytes in ApiGateway sending logs to cloudwatch.
Is there any solution to this?
I am considering using a lambda as a proxy (with http-proxy) as my last option...
As you stated, there is no current known solution to this problem and AWS is aware of the problem.
API Gateway currently limits log events to 1024 bytes. Log events larger than 1024 bytes, such as request and response bodies, will be truncated by API Gateway before submission to CloudWatch Logs.
You can see additional known issues at the AWS documentation page for API Gateway here.
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html
According to the AWS documentation, full logging should not be turned on in AWS API Gateway, in production, because of PII (source).
This is purely for development troubleshooting purposes. So the log limitation 1024 bytes continue to exists, because of this.