The API Gateway LogGroup is experiencing duplication issues and lacks critical details

I've been encountering difficulties setting up CloudWatch logs for my RestApi using cdk.

Here is the code I'm using:

const logGroup = new LogGroup(this, `apiLogs`, {
        logGroupName: `apiLogs`,
        retention: RetentionDays.ONE_WEEK
});

const api = new apigw.RestApi(this, `apiName`, {
        // set up CORS            
        defaultCorsPreflightOptions: {
            statusCode: 200,
            allowMethods: ['OPTIONS', 'GET', 'POST', 'DELETE'],
            allowOrigins: apigw.Cors.ALL_ORIGINS
        },
        deploy: true,
        restApiName: `apiName`,
        deployOptions: {
            accessLogDestination: new apigw.LogGroupLogDestination(logGroup),
            loggingLevel: apigw.MethodLoggingLevel.INFO,
            dataTraceEnabled: true
        }}
);

In the AWS console, the specific logs I need are labeled as "Log full request/responses data", which is a crucial part of my setup.

deployOptions: {
            accessLogDestination: new apigw.LogGroupLogDestination(logGroup),
            loggingLevel: apigw.MethodLoggingLevel.INFO,
            dataTraceEnabled: true
        }

Although this configuration functions correctly and displays the desired outcome in the screenshot provided: https://i.sstatic.net/J5NXa.png

Upon checking CloudWatch after sending requests to the API, I notice the creation of two distinct logGroups with logs:

  1. The first logGroup named apiLogs, as specified in my code, produces logs that lack detailed information as shown here: https://i.sstatic.net/jr1ys.png

  2. The second logGroup has a default name incorporating the endpoint ID and contains the precise details that I require as illustrated here: https://i.sstatic.net/HUVTr.png

I'm puzzled by the creation of two separate logGroups and why apiLogs doesn't display the desired level of detail in its logs.

Has anyone encountered this issue before?

Answer №1

API Gateway generates two main categories of logs:

Execution logs

Access logs

When it comes to execution logs, users have limited control as it is managed by AWS in a dedicated log group, much like Lambda functions. However, configuration options are available for access log behavior.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Vite HMR causes Vue component to exceed the maximum number of recursive updates

After making changes to a nested component in Vue and saving it, I noticed that the Vite HMR kept reloading the component, resulting in a warning from Vue: Maximum recursive updates exceeded... Check out the online demo on stackblitz. Make a change in Chi ...

How to use RxJs BehaviorSubject in an Angular Interceptor to receive incoming data

Being a newcomer to rxjs, I grasp most operators except for the specific use case involving BehaviorSubject, filter, and take. I am working on renewing an oauth access and refresh token pair within an Angular interceptor. While reviewing various codes fro ...

TypeScript requires that the `includes` function must have the same type parameter for both input and

When working with TypeScript, I've encountered an interesting dilemma regarding the use of the Array.Prototype.includes function. It seems that this function requires me to pass in the same type as in the original array, but isn't the purpose of ...

Mastering Generic Types in Functions in Typescript

My current structure looks like this: export interface Complex { getId<T>(entity: T): string } const test: Complex = { getId<Number>(entity){return "1"} // encountering an error 'entity is implicitly any' } I am wondering w ...

Displaying buttons based on the existence of a token in Angular - A guide

Can you assist me with a coding issue I'm facing? I have implemented three methods: login, logout, and isAuthenticated. My goal is to securely store the token in localStorage upon login, and display only the Logout button when authenticated. However, ...

Creating Unique Names for DataMembers in WCF Generics

I currently have a WCF REST / JSON service that provides various types of data lists. I want to enhance each response by adding a revision number attribute. Let's take the example of a 'Car' class [DataContract] public class Car { [Dat ...

What is the best method to display a service property within a controller?

If we consider the scenario where I have a controller named ctrlA with a dependency called serviceB, which in turn has a property known as propertyC. My development environment involves Angular and Typescript. When interacting with the user interface, the ...

Executing asynchronous methods in a Playwright implementation: A guide on constructor assignment

My current implementation uses a Page Object Model to handle browser specification. However, I encountered an issue where assigning a new context from the browser and then assigning it to the page does not work as expected due to the asynchronous nature of ...

I plan to securely store the verification code from Cognito into our database for future use and send the email at a later time

exports.handler = async event => { console.log(event); try { const { userName } = event; const { codeParameter } = event.request; let userParams = { userId: userName, codeParameter }; // Determine the reason for this function being i ...

Angular6 table using *ngFor directive to display objects within an object

Dealing with Angular 6 tables and encountering a challenge with an item in the *ngFor loop. Here is my HTML view: <table class="table table-bordered text-center"> <tr> <th class="text-center">Cuenta</th> <th class="te ...

A guide to incorporating Material-UI ThemeProvider and WithStyles with Typescript

I've been feeling frustrated lately as I've been dedicating the past few days to migrating my React application from JavaScript to TSX. While I appreciate the type checking that TSX provides, I'm struggling with understanding how to implemen ...

The TypeScript error message is saying that it cannot find the property 'push' of an undefined value, resulting in a error within the

Issue: Unable to access property 'push' of undefined in [null]. class B implements OnInit { messageArr: string[]; ngOnInit() { for(let i=0; i<5; i++) { this.messageArr.push("bbb"); } } } ...

An issue occurred while trying to use a function that has a return type of NextPage

After successfully implementing the code below: const HomePage: NextPage = () => ( <div> <div>HomePage</div> </div> ); I wanted to adhere to Airbnb's style guide, which required using a named function. This led me t ...

Error encountered while attempting to utilize 'load' in the fetch function of a layer

I've been exploring ways to implement some pre-update logic for a layer, and I believe the fetch method within the layer's props could be the key. Initially, my aim is to understand the default behavior before incorporating custom logic, but I&ap ...

While utilizing Typescript, it is unable to identify changes made to a property by a

Here is a snippet of code I am working with: class A { constructor(private num: number = 1) { } private changeNum() { this.num = Math.random(); } private fn() { if(this.num == 1) { this.changeNum(); if(this.num == 0.5) { ...

Xamarin Android REST API for PassSlot failing due to name resolution issue

I'm currently utilizing a REST API to interact with PassSlot for the purpose of generating a pass or coupon. However, I seem to be encountering an issue when executing the program as it throws the following error: "Error: NameResolutionFailure". Here ...

Finding the root directory of a Node project when using a globally installed Node package

I've developed a tool that automatically generates source code files for projects in the current working directory. I want to install this tool globally using npm -g mypackage and store its configuration in a .config.json file within each project&apos ...

Angular is notifying that an unused expression was found where it was expecting an assignment or function call

Currently, I am working on creating a registration form in Angular. My goal is to verify if the User's username exists and then assign that value to the object if it is not null. loadData(data: User) { data.username && (this.registrationD ...

Obtain the popup URL following a fresh request using JavaScript with Playwright

I'm having trouble with a button on my page that opens a popup in a new tab. I have set up a listener to capture the URL of the popup when it opens: page.on('popup', async popup => { console.log('popup => ' + await pop ...

Closing Popover Instance from another Component (Ionic, Typescript)

I've been dealing with an issue where a function that I imported from another class isn't getting called and the parser isn't recognizing it. The Popover in my code also can't be closed. I've tried various similar solutions, but no ...