-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability for Logger
to ship logs to CloudWatch Logs
#3524
Comments
We would find this very useful as well. |
I asked an AWS trainer about this, and he said it would probably be more flexible to ship logs to S3 so they can be more easily loaded into various other services (Athena, Redshift, EMR). That being said, I am +1 for shipping application logs to one service or the other as an option for the Logger class. FWIW I tried prototyping it myself just by extending Logger (don't own the code so I can't currently share it), and the |
The route I'm taking on this is to add a lambda function that the logger can send content to do that will perform the CloudWatch logging for me.
And then I'm looking at https://www.npmjs.com/package/lambda-log to handle log shipping for me. I'll report back when I have it working. Obviously, it would be great if the built-in Logger could have an option for a mirroring destination. I'm patching that into the Amplify-JS library I'm running in my app. If that turns well, I'll see if I can get it in as a PR. |
Sounds good! @dbhagen , a couple of comments though: Be aware of the Lambda concurrency limits; Log shipping may be an operation that happens fairly frequently and depending how many clients (frontend apps) you have, you may be hitting your lambda function a lot: https://docs.aws.amazon.com/lambda/latest/dg/limits.html . I also believe that the biggest challenge in doing Log shipping is not so much on the backend, but in the client library to do error handling, buffering to send logs in batches, local cache to deal with lost of connectivity, retry backoffs, etc. In your approach, you still need to handle all of that in the client. |
it boggles my mind there isn't some sort of built in support to access generated application logs in the amplify console. it's like they didn't expect users would want to look at the logs if their deployment failed. |
Any update on this? My current workaround is to create an error model on my schema and create records whenever I hit a catch block. For instance, I added
Then when I hit a catch block, I hit up my appsync api:
But it's hacky and error prone. |
@karrettgelley We are doing something very similar. It seems like a step backwards compared to other logging frameworks. |
do we have any update this feature ? |
+1 This is a must have |
We were also wanting to use Logger as a way to report on crash metrics in our React app. Right now we have implemented a class resembling winston-cloudwatch that uses AWS.CloudWatchLogs.PutLogEvents with some custom code to manage batching messages and sequence tokens. I'd love to see our analytics and logging come from Amplify so that everything is in one place. |
Hi, |
i followed the Logger guide and am developing an application locally. i don't know where/if my logs are written to. the guide does not indicate where these logs get written to, nor how to configure output location. for reference, i am only importing the |
@hp4k1h5 the logs are just console.log visible in Chrome inspector for example. |
@xavierraffin thanks for this information, but i don't see any logs in the dev console at all. im not getting any errors either. so i believe i have instantiated the Logger correctly. all of my im also wondering what the point of having a wrapper around |
The libraries |
You shouldn't need to use a 3rd party library, the AWS CloudWatchLogs SDK has all the methods you need to add logging.
|
Circling back to this issue - I've begun investigating this and want to clarify and narrow down the use cases here. Are you looking to primarily send up logs to CloudWatch from the "user" level, or are you also wanting to send the background Amplify logging that is happening? |
@eddiekeller ; i've moved on at least temporarlily from this issue. at the time, i was using amplify as an import to a Vue application, and wanted a default way to write error level log information (re login/account issues) to cloudwatch. i never figured out if i was not integrated enough or not finding the right api's. our use case seemed clear but for whichever combo of reasons, i and others are left feeling like we have wasted investment in potentially useful development. i.e. >> i have a vue login portal and the Logger function integrates with the same aws token to deliver login success/failure metrics. |
@eddiekeller |
Thanks for the responses. Small follow up to help me clarify this a bit more. It totally makes sense that you want to be able to send up errors (and possibly other logs) from the client side and from your API responses. My next thought is - what about the error logging that we have in Amplify itself? For instance, this |
If there are automatic includes like the error mentioned I feel like that would be a win and our teams would gladly accept those "background" Amplify logs as well. |
Ok, got it. So it sounds like the background ones would be useful but, in the immediate sense, are more like a "nice to have" and the core ask right now is in your own usage of the logger. Does that sound correct? For the initial implementation at least, I'm thinking it might be best to restrict it to that since having it be automatic for the background Amplify logging will require a lot more work to run through everything...plus it would require some extra thought regarding cloudwatch pricing and log storage. Like I said, I'm investigating this now and having some discussions with the team on this issue. Don't hesitate to comment with additional info. |
That sounds spot on! We found immediate benefit in simple one off logging, but I could see value in automatic background logs. We just don't have that implemented so I don't have stats to back that up. |
I have out a PR for it now that I believe should address the asks here. #8309 |
PR has been merged in. New ticket tracking future improvements has been made here #8354 |
@eddiekeller as the PR has been reverted, should this issue be re-opened? |
Not sure if anyone here can help, but this functionality was merged back in and I am attempting to use it. It seems to fail on the initial log post though details here - #8309 (comment) |
@eddiekeller Seems like some of our customers are still having an issue, can you please take a look? |
@alexanderMontague Thanks for bringing that issue to my attention. It looks like another commenter found a temporary way around the bug. Did you try that? In the meantime, I'll work on throwing together a fix. Should be relatively simple based on what the other commenter found. |
Hey all - I have this up and working in us-east-1 and it works fine. Now trying to implement in ap-southeast-2 with a very similar configuration I'm getting a "AWSCloudWatch - error getting log group - Error: Region is missing" error. I've tried everything I can think of but nothing seems to work. Anyone have any hypotheses I might explore? Thanks! |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Is your feature request related to a problem? Please describe.
As a developer, I would like for Amplify to support log shipping to CloudWatch logs via the use of Logger. So I can send certain logs (like errors or stack traces) to my AWS account for future analysis.
Describe the solution you'd like
This feature would leverage the Cognito integration such that log shipping is done in a secure fashion with temporary credentials. I would like for the
Logger
to take care of sending logs in batches in the background and support a local cache for lost connectivity.Describe alternatives you've considered
I have considered using existing npm packages like https://www.npmjs.com/package/winston-cloudwatch.
The text was updated successfully, but these errors were encountered: