-
Notifications
You must be signed in to change notification settings - Fork 206
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
Add DynamoDB source plugin #3349
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
aefc57b
Add DynamoDB source plugin
daixba af033b5
Fix UT error
daixba 1e08325
Fix UT error
daixba c8cc23a
Remove the source test
daixba a3f5015
Fix UT error
daixba f02b5bd
Fix typo
daixba 7d513f8
Update stream config
daixba c12c051
Address PR comments
daixba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# DynamoDB Source | ||
|
||
This is a source plugin that supports retrieve data from DynamoDB tables. Basic use case of this source plugin is to | ||
sync the data from DynamoDB tables to OpenSearch indexes. With this CDC support, customer can run the end to end data | ||
sync pipeline and capture changed data in near real-time without writing any codes and without any downtime of business. | ||
Such pipeline can run on multiple nodes in parallel to support data capture of large scale tables. | ||
|
||
This plugin can support below three different modes: | ||
|
||
1. Full load only: One time full data export and load | ||
2. CDC Only: DynamoDB Stream | ||
3. Full load + CDC: One time full export and load + DynamoDB Stream. | ||
|
||
## Usages | ||
|
||
To get started with this DynamoDB source, create the following source configuration: | ||
|
||
```yaml | ||
source: | ||
dynamodb: | ||
tables: | ||
- table_arn: "arn:aws:dynamodb:us-west-2:123456789012:table/my-table" | ||
stream: | ||
start_position: | ||
export: | ||
s3_bucket: "my-bucket" | ||
s3_prefix: "export/" | ||
aws: | ||
region: "us-west-2" | ||
sts_role_arn: "arn:aws:iam::123456789012:role/DataPrepperRole" | ||
|
||
coordinator: | ||
dynamodb: | ||
table_name: "coordinator-demo" | ||
region: "us-west-2" | ||
|
||
|
||
``` | ||
|
||
## Configurations | ||
|
||
### Shared Configurations: | ||
|
||
* coordinator (Required): Coordination store setting. This design create a custom coordinator based on existing | ||
coordination store implementation. Only DynamoDB is tested so far. | ||
* aws (Required): High level AWS Auth. Note Data Prepper will use the same AWS auth to access all tables, check | ||
Security for more details. | ||
* region | ||
* sts_role_arn | ||
|
||
### Export Configurations: | ||
|
||
* s3_bucket (Required): The destination bucket to store the exported data files | ||
* s3_prefix (Optional): Custom prefix. | ||
|
||
### Stream Configurations | ||
|
||
* start_position (Optional): start position of the stream, can be either BEGINNING or LATEST. If export is required, | ||
this value will be ignored and set to LATEST by default. This is useful if customer don’t want to run initial export, | ||
so they can | ||
choose either from the beginning of the stream (up to 24 hours) or from latest (from the time point when pipeline is | ||
started) | ||
|
||
## Metrics | ||
|
||
### Counter | ||
|
||
- `exportJobsSuccess`: measures total number of export jobs run with status completed. | ||
- `exportJobsErrors`: measures total number of export jobs cannot be submitted or run with status failed. | ||
- `exportFilesTotal`: measures total number of export files generated. | ||
- `exportFilesSuccess`: measures total number of export files read (till the last line) successfully. | ||
- `exportRecordsTotal`: measures total number of export records generated | ||
- `exportRecordsSuccess`: measures total number of export records processed successfully . | ||
- `exportRecordsErrors`: measures total number of export records processed failed | ||
- `changeEventsSucceeded`: measures total number of changed events in total processed successfully | ||
- `changeEventsFailed`: measures total number of changed events in total processed failed | ||
Comment on lines
+68
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like these metrics mainly cover export. Are there any metrics that we should add for streams? Things like number of shards processed? |
||
|
||
## Developer Guide | ||
|
||
This plugin is compatible with Java 17. See | ||
|
||
- [CONTRIBUTING](https://github.com/opensearch-project/data-prepper/blob/main/CONTRIBUTING.md) | ||
- [monitoring](https://github.com/opensearch-project/data-prepper/blob/main/docs/monitoring.md) |
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,40 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation project(path: ':data-prepper-api') | ||
implementation project(path: ':data-prepper-core') | ||
implementation project(path: ':data-prepper-plugins:dynamodb-source-coordination-store') | ||
|
||
implementation libs.armeria.core | ||
implementation 'io.micrometer:micrometer-core' | ||
|
||
implementation 'software.amazon.awssdk:sts' | ||
implementation 'software.amazon.awssdk:arns' | ||
implementation 'software.amazon.awssdk:dynamodb' | ||
implementation 'software.amazon.awssdk:dynamodb-enhanced' | ||
implementation 'software.amazon.awssdk:s3' | ||
implementation 'software.amazon.awssdk:netty-nio-client' | ||
|
||
implementation 'com.fasterxml.jackson.core:jackson-core' | ||
implementation 'com.fasterxml.jackson.core:jackson-databind' | ||
// https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-ion | ||
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-ion' | ||
|
||
implementation project(path: ':data-prepper-plugins:aws-plugin-api') | ||
|
||
|
||
testImplementation platform('org.junit:junit-bom:5.9.1') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
50 changes: 50 additions & 0 deletions
50
...ource/src/main/java/org/opensearch/dataprepper/plugins/source/dynamodb/ClientFactory.java
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,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.source.dynamodb; | ||
|
||
import org.opensearch.dataprepper.aws.api.AwsCredentialsOptions; | ||
import org.opensearch.dataprepper.aws.api.AwsCredentialsSupplier; | ||
import org.opensearch.dataprepper.plugins.source.dynamodb.configuration.AwsAuthenticationConfig; | ||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; | ||
import software.amazon.awssdk.services.dynamodb.DynamoDbClient; | ||
import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
|
||
public class ClientFactory { | ||
|
||
private final AwsCredentialsProvider awsCredentialsProvider; | ||
|
||
public ClientFactory(AwsCredentialsSupplier awsCredentialsSupplier, AwsAuthenticationConfig awsAuthenticationConfig) { | ||
awsCredentialsProvider = awsCredentialsSupplier.getProvider(AwsCredentialsOptions.builder() | ||
.withRegion(awsAuthenticationConfig.getAwsRegion()) | ||
.withStsRoleArn(awsAuthenticationConfig.getAwsStsRoleArn()) | ||
.withStsExternalId(awsAuthenticationConfig.getAwsStsExternalId()) | ||
.withStsHeaderOverrides(awsAuthenticationConfig.getAwsStsHeaderOverrides()) | ||
.build()); | ||
} | ||
|
||
|
||
public DynamoDbStreamsClient buildDynamoDbStreamClient() { | ||
return DynamoDbStreamsClient.builder() | ||
.credentialsProvider(awsCredentialsProvider) | ||
.build(); | ||
} | ||
|
||
|
||
public DynamoDbClient buildDynamoDBClient() { | ||
return DynamoDbClient.builder() | ||
.credentialsProvider(awsCredentialsProvider) | ||
.build(); | ||
} | ||
|
||
|
||
public S3Client buildS3Client() { | ||
return S3Client.builder() | ||
.credentialsProvider(awsCredentialsProvider) | ||
.build(); | ||
} | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make an issue to get the configuration for this coordinator moved to the
data-prepper-config.yaml
to be completed in a future PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Will do once this code is merged. I will create one to refer to this.
It looks like we can either expose a getCoordinationStore from current LeaseBasedCoordinator or by default only create coordinationStore from the data-prepper-config.yaml only instead of the coordinator. Not sure what is the best way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will want to use the data-prepper-config only. We can use the same flow that we currently use to provide plugins with a source coordinaor