Skip to content

AppSync API not logging to CloudWatch

0

My AppSync API is not sending logs to CloudWatch or creating a log group. I turned on logging and set the Field resolver log level to "All". When I send queries, the log group is not created. When I click the link to the Cloudwatch log group, it says "Log group does not exist".

I have previously (last week) set up logging for an older AppSync API and it worked fine.

What I have tried: Creating the log group manually Sending various queries directly from the AppSync console Making sure the regions are correct Making sure the logging role has the correct permissions Disabling and re-enabling logging Waiting over 24 hours

Any help would be appreciated

1 Answer
0

It sounds like you're experiencing an issue with your AppSync API not logging to CloudWatch as expected. This can be frustrating, especially since you've had success with a previous API. Let's go through some potential causes and solutions:

  1. IAM Role Permissions: Even though you've checked the logging role permissions, it's worth double-checking. The role needs specific permissions to write logs to CloudWatch. Make sure the role has a policy that includes the following actions:

    • logs:CreateLogGroup
    • logs:CreateLogStream
    • logs:PutLogEvents
  2. Service Role: Ensure that AppSync has the correct service role to assume when writing logs. If you're using an existing IAM role, you need to provide the service role ARN to AppSync.

  3. API Configuration: Verify in the AppSync console that logging is indeed enabled for your API and that the field resolver log level is set to "All" as you mentioned.

  4. Execution: Confirm that your API has been queried or mutated after enabling logging. Log groups are typically created only after the first execution that generates logs.

  5. CloudWatch Console: In the CloudWatch console, check for a log group with the name format "/aws/appsync/apis/{your_api_id}". Sometimes the direct link might not work, but the log group could still exist.

  6. Region Consistency: Ensure that you're looking for the log group in the same region where your AppSync API is deployed.

  7. Service Limits: Although unlikely, check if you've hit any service limits for the number of log groups in your account.

  8. API Gateway Logs: If you're using API Gateway in conjunction with AppSync, make sure you're not confusing API Gateway logs with AppSync logs.

  9. Wait Time: While you've already waited 24 hours, in some rare cases, it might take a bit longer for the logs to appear.

If none of these steps resolve the issue, it's possible there might be an underlying problem with your AWS account or the AppSync service in your region. In this case, it would be advisable to contact AWS Support for further assistance. They can look into your specific account and API configuration to identify any potential issues that aren't immediately apparent.

Remember, once the logging is properly set up, you should be able to see detailed information about your API operations, including request and response data, error messages, and performance metrics in CloudWatch Logs.

Sources
Resolve empty log issues in CloudWatch | AWS re:Post
Using CloudWatch to monitor and log GraphQL API data - AWS AppSync GraphQL
Using CloudWatch to monitor and log Event API data - AWS AppSync Events
Log Groups not found | AWS re:Post
Configuring CloudWatch Logs on Event APIs - AWS AppSync Events

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.