Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CloudWatch Client Side Logging

I am running an react app. I want to log error to my aws cloudwatch without hard coding the access key and secret key on my client side code. I am using 'Error Boundary Component' for catching error.

Thank you for your help.

like image 313
Merlin Joseph Avatar asked May 07 '20 11:05

Merlin Joseph


People also ask

How does AWS AppSync manage Cloudwatch Logs?

If you turn on logging, AWS AppSync manages the CloudWatch Logs. The process includes creating log groups and log streams, and reporting to the log streams with these logs. When you enable logging on a GraphQL API and make requests, AWS AppSync creates a log group and log streams under the log group.

How do the Cloudwatch Logs plugins work?

These logging plugins are all built on top of the AWS SDK for .NET, and use the same behavior used by the SDK to find AWS credentials. The credentials used by the logging plugins must have the following permissions to access CloudWatch Logs.

How do I use nlog with AWS Cloudwatch Logs?

For example to use CloudWatch Logs with a .NET application using NLog, add the AWS.Logger.NLog NuGet package, and then add the AWS target into your NLog.config file. Here is an example of an NLog.config file that enables both CloudWatch Logs and the console as output for the log messages.

How do I retrieve data from Cloudwatch Logs?

You can then retrieve the associated log data from CloudWatch Logs using the CloudWatch console, CloudWatch Logs commands in the Amazon Web Services CLI, CloudWatch Logs API, or CloudWatch Logs SDK. You can use CloudWatch Logs to:


Video Answer


1 Answers

I assume by "react app" you mean a React-based web application, often called an SPA for Single Page Application.

In that case you are correct, you do not want to hard-code and credentials as that would expose them to any user who has access to the page.

The most common architecture for doing this is to setup the following:

  1. A Lambda that will take your logging event and log it for you in Cloudwatch.
  2. An API-Gateway that your application can call that will trigger the Lambda.
  3. An Authorizer on the API-Gateway resource that will validate a JWT that is passed from the application.
  4. AWS Cognito that will supply your application with a JWT based on some login, either directly or via some integration with another service that is applicable for your case.
like image 94
jwh20 Avatar answered Oct 12 '22 16:10

jwh20