-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new doc page for enable logging for
defineData
(#8199)
* added enable logging page * update link
- Loading branch information
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,6 +494,7 @@ | |
"dataaccess", | ||
"dataacess", | ||
"databinding", | ||
"datalogconfig", | ||
"dataset", | ||
"datasource", | ||
"DataSource", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/pages/[platform]/build-a-backend/data/enable-logging/index.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { getCustomStaticPath } from '@/utils/getCustomStaticPath'; | ||
|
||
export const meta = { | ||
title: 'Enable logging', | ||
description: 'Learn how to enable logging for your Amplify data resource', | ||
platforms: [ | ||
'android', | ||
'angular', | ||
'flutter', | ||
'javascript', | ||
'nextjs', | ||
'react', | ||
'react-native', | ||
'swift', | ||
'vue' | ||
] | ||
}; | ||
|
||
export function getStaticPaths() { | ||
return getCustomStaticPath(meta.platforms); | ||
} | ||
|
||
export function getStaticProps(context) { | ||
return { | ||
props: { | ||
platform: context.params.platform, | ||
meta | ||
} | ||
}; | ||
} | ||
|
||
You can enable logging to debug your GraphQL API using Amazon CloudWatch logs. To learn more about logging and monitoring capabilities for your GraphQL API, visit the [AWS AppSync documentation for logging and monitoring](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html). | ||
|
||
## Enable default logging configuration | ||
|
||
Default logging can be enabled by setting the `logging` property to `true` in the call to `defineData`. For example: | ||
|
||
```ts title="amplify/data/resource.ts" | ||
export const data = defineData({ | ||
// ... | ||
logging: true | ||
}); | ||
``` | ||
|
||
Using `logging: true` applies the default configuration: | ||
- `excludeVerboseContent: true` (see [AppSync's Request-level logs](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html#cwl)) | ||
- `fieldLogLevel: 'none'` (see [AppSync's Field-level logs](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html#cwl)) | ||
- `retention: '1 week'` (see [Enum RetentionDays](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.RetentionDays.html)) | ||
|
||
## Customize logging configuration | ||
|
||
You can customize individual configuration values by providing a [`DataLogConfig`](#datalogconfig-fields) object. For example: | ||
|
||
```ts title="amplify/data/resource.ts" | ||
export const data = defineData({ | ||
// ... | ||
logging: { | ||
excludeVerboseContent: false, | ||
fieldLogLevel: 'all', | ||
retention: '1 month' | ||
} | ||
}); | ||
``` | ||
|
||
<Callout warning> | ||
**WARNING**: Setting `excludeVerboseContent` to `false` logs full queries and user parameters, which can contain sensitive data. We recommend limiting CloudWatch log access to only those roles or users (e.g., DevOps or developers) who genuinely require it, by carefully scoping your IAM policies. | ||
</Callout> | ||
|
||
## Configuration Properties | ||
|
||
### `logging` | ||
- `true`: Enables default logging. | ||
- `DataLogConfig` object: Overrides one or more default fields. | ||
|
||
### `DataLogConfig` Fields | ||
|
||
- **`excludeVerboseContent?: boolean`** | ||
- Defaults to `true` | ||
- When `false`, logs can contain request-level logs. See [AppSync's Request-Level Logs](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html#cwl). | ||
|
||
- **`fieldLogLevel?: DataLogLevel`** | ||
- Defaults to `'none'` | ||
- Supported values of [AppSync's Field Log Levels](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html#cwl): | ||
- `'none'` | ||
- `'error'` | ||
- `'info'` | ||
- `'debug'` | ||
- `'all'` | ||
|
||
- **`retention?: LogRetention`** | ||
- Number of days to keep the logs | ||
- Defaults to `'1 week'` | ||
- Supported values of [Enum RetentionDays](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.RetentionDays.html): | ||
- `'1 day'` | ||
- `'3 days'` | ||
- `'5 days'` | ||
- `'1 week'` | ||
- `'2 weeks'` | ||
- `'1 month'` | ||
- `'2 months'` | ||
- `'3 months'` | ||
- `'4 months'` | ||
- `'5 months'` | ||
- `'6 months'` | ||
- `'1 year'` | ||
- `'13 months'` | ||
- `'18 months'` | ||
- `'2 years'` | ||
- `'5 years'` | ||
- `'10 years'` | ||
- `'infinite'` |