Skip to content
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

Not able to push my React Native app logs to CloudWatch #12899

Closed
3 tasks done
cristobalbl86 opened this issue Jan 25, 2024 · 5 comments
Closed
3 tasks done

Not able to push my React Native app logs to CloudWatch #12899

cristobalbl86 opened this issue Jan 25, 2024 · 5 comments
Labels
duplicate If marked with duplicate, issue will be closed & original will be added for traceability feature-request Request a new feature Logger Related to Logger category React Native React Native related issue

Comments

@cristobalbl86
Copy link

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Analytics

Amplify Version

v6

Amplify Categories

analytics

Backend

Amplify CLI

Environment information

# Put output below this line
  System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 2.48 GB / 15.82 GB
  Binaries:
    Node: 16.20.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (120.0.2210.133)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @aws-amplify/react-native: ^1.0.13 => 1.0.13 
    @babel/core: ^7.20.0 => 7.23.7 
    @react-native-async-storage/async-storage: ^1.21.0 => 1.21.0 
    @react-native-community/netinfo: ^11.2.1 => 11.2.1 
    @types/react: ~18.2.45 => 18.2.48
    @types/react-native: ^0.73.0 => 0.73.0
    HelloWorld:  0.0.1
    aws-amplify: ^6.0.13 => 6.0.13
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    expo: ~50.0.3 => 50.0.3
    expo-status-bar: ~1.11.1 => 1.11.1
    react: 18.2.0 => 18.2.0
    react-native: 0.73.2 => 0.73.2
    typescript: ^5.1.3 => 5.3.3
  npmGlobalPackages:
    @aws-amplify/cli: 12.10.1
    expo-cli: 6.3.10
    newman: 5.3.2
    vsts-npm-auth: 0.42.1
    yarn: 1.22.19

Describe the bug

I'm trying to push Amplify Logger logs to AWS CloudWatch

All configs are done in the AWS account, the logGroup and logsStream.
My problem is in the react native app, I found this way but the AWSCloudWatchProvider doen't seem to work.
Module '"aws-amplify"' has no exported member 'AWSCloudWatchProvider'.ts(2305)

`import { Amplify, AWSCloudWatchProvider } from "aws-amplify";
import { ConsoleLogger as Logger } from "@aws-amplify/core";

import awsmobile from "./src/aws-exports";

Amplify.configure(awsmobile);

const cwLogger = new Logger("cloudwatch", "DEBUG");

cwLogger.addPluggable(
new AWSCloudWatchProvider({
logGroupName: "cloudwatchlogs",
logStreamName: "cloudwatchstream",
region: awsmobile.aws_project_region,
})
);

export { cwLogger };
`

And I noticed that you deprecated that provider in this PR:
#11830

What is the right way to push the Logger logs to CloudWatch?

Expected behavior

I expect the logger be able to push logs to AWS CloudWatch

Reproduction steps

my app is not able to run, the error comes in the imports section
image

Code Snippet

// Put your code below this line.
`import { Amplify, AWSCloudWatchProvider } from "aws-amplify";
import { ConsoleLogger as Logger } from "@aws-amplify/core";

import awsmobile from "./src/aws-exports";

Amplify.configure(awsmobile);

const cwLogger = new Logger("cloudwatch", "DEBUG");

cwLogger.addPluggable(
  new AWSCloudWatchProvider({
    logGroupName: "cloudwatchlogs",
    logStreamName: "cloudwatchstream",
    region: awsmobile.aws_project_region,
  })
);

export { cwLogger };
`

Log output

// Put your logs below this line


aws-exports.js

/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "us-west-2",
    "aws_cognito_identity_pool_id": "us-west-2:b6f1ddce-042b-4d30-86dc-ed7dbd51545d",
    "aws_cognito_region": "us-west-2",
    "aws_user_pools_id": "us-west-2_bLrr9q6i2",
    "aws_user_pools_web_client_id": "1pp5610u6dthptv187c2s7so8v",
    "oauth": {},
    "aws_cognito_username_attributes": [
        "EMAIL"
    ],
    "aws_cognito_social_providers": [],
    "aws_cognito_signup_attributes": [
        "EMAIL"
    ],
    "aws_cognito_mfa_configuration": "OFF",
    "aws_cognito_mfa_types": [
        "SMS"
    ],
    "aws_cognito_password_protection_settings": {
        "passwordPolicyMinLength": 8,
        "passwordPolicyCharacters": []
    },
    "aws_cognito_verification_mechanisms": [
        "EMAIL"
    ]
};


export default awsmobile;

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@cristobalbl86 cristobalbl86 added the pending-triage Issue is pending triage label Jan 25, 2024
@nadetastic nadetastic added React Native React Native related issue Logger Related to Logger category labels Jan 25, 2024
@nadetastic nadetastic self-assigned this Jan 25, 2024
@nadetastic
Copy link
Member

Hi @cristobalbl86 thank you for opening this issue. After taking a look at it, it seems that you are using v5 specific imports with v6 of aws-amplify. For example, AWSCloudWatchProvider was previously available in v5 but is not available in v6.

I'd recommend taking a a look at the migration guide here.

Additionally, also note that the ConsoleLogger is now imported from aws-amplify/utilites and not @aws-amplify/core - documentation.

import { ConsoleLogger } from 'aws-amplify/utils';

Let me know if you have any questions.

@nadetastic nadetastic added pending-response and removed pending-triage Issue is pending triage labels Jan 27, 2024
@cristobalbl86
Copy link
Author

Hi @cristobalbl86 thank you for opening this issue. After taking a look at it, it seems that you are using v5 specific imports with v6 of aws-amplify. For example, AWSCloudWatchProvider was previously available in v5 but is not available in v6.

I'd recommend taking a a look at the migration guide here.

Additionally, also note that the ConsoleLogger is now imported from aws-amplify/utilites and not @aws-amplify/core - documentation.

import { ConsoleLogger } from 'aws-amplify/utils';

Let me know if you have any questions.

Thank you @nadetastic for the feedback, I already updated my imports.
But I still see that the ConsoleLogger in v6 supports the addPluggable method which receives a LoggingProvider parameter.
What should I pass there if AWSCloudWatchProvider is not supported?, my goal is to push the logger logs to CloudWatch.
Can you point me to any sample in v6? I was checking your docs but still don't find anything that can unblock me.

@cristobalbl86
Copy link
Author

I will appreciate any additional feedback.

@nadetastic
Copy link
Member

Hi @cristobalbl86, following up here, thank you for your patience.

V6 doesn’t currently support CloudWatch, and we are working to get this addressed - however I am unable to provide an ETA at this time. In the meantime, a workaround could be to use the AWS SDK (as seen here) to emit the logs yourself.

I’ve marked this as a feature request and will provide any future updates here, but let me know if you have any additional questions.

@nadetastic nadetastic added the feature-request Request a new feature label Feb 12, 2024
@cwomack cwomack added the duplicate If marked with duplicate, issue will be closed & original will be added for traceability label May 24, 2024
@cwomack
Copy link
Member

cwomack commented May 24, 2024

For anyone that is following this issue, we will be consolidating the context and feedback detailed here into issue #13336 to better focus our efforts on an implementation strategy for improving CloudWatch support in v6. Please leave any additional context or feedback on that issue, and follow it for further updates on progress as we make it!

@cwomack cwomack closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate If marked with duplicate, issue will be closed & original will be added for traceability feature-request Request a new feature Logger Related to Logger category React Native React Native related issue
Projects
None yet
Development

No branches or pull requests

3 participants