generated from Ed-Fi-Exchange-OSS/Template-for-GitHub
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RND-247] Kafka to OpenSearch - MongoDB (#273)
* Initial version of kafka to opensearch connector * Creating meadowlark-net on docker file to handle communication * Adding permissions to allow extract and delete executable * Adding documentation * Moving image to docker folder * Updating debezium kafka images * Fixing debezium package version to avoid using alpha versions * Moving kafka to backend folder and follow same structure * Add opensearch to same network * Fix typo * Adding json converter to example * Checking for file integrity before downloading from github * Changing value in example * Fix path * Simplifying opensearch sing config example * Updating sink json example (writes data without information) * Updating debezium mongodb configuration to insert json into kafka * Updating opensearch sink example to write to OpenSearch * Updating opensearch example * Add initial kafka connect transform * Rename project * Add gradle build to dockerfile * Removing duplicated license file * Fix issue with escaped strings * Adding console consumer documentation * Fix typo * Adding connect-meadowlark image * Fixing order of transforms * Adding documentation information
- Loading branch information
Showing
27 changed files
with
1,515 additions
and
117 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
debezium-mongodb.json | ||
opensearch_sink.json |
20 changes: 12 additions & 8 deletions
20
...kend/docker/debezium-mongodb.json.example → ...ream/docker/debezium-mongodb.json.example
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
70 changes: 70 additions & 0 deletions
70
Meadowlark-js/backends/meadowlark-kafka-stream/docker/docker-compose.yml
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,70 @@ | ||
version: '3' | ||
services: | ||
|
||
# Zookeeper image from Debezium | ||
zookeeper: | ||
hostname: zookeeper1 | ||
container_name: zookeeper1 | ||
image: debezium/zookeeper:2.3@sha256:42b73151458b12c9dc1473807ee8369a917724278d6ec08d82702da8c46a9639 | ||
networks: | ||
- meadowlark-net | ||
ports: | ||
- 2181:2181 | ||
- 2888:2888 | ||
- 3888:3888 | ||
volumes: | ||
- zookeeper-logs:/var/lib/zookeeper/log | ||
- zookeeper-data:/var/lib/zookeeper/data | ||
|
||
# Kafka image from Debezium | ||
kafka: | ||
hostname: kafka1 | ||
container_name: kafka1 | ||
image: debezium/kafka:2.3@sha256:ffe34d457bff18de31c5ed695f22291680608d9758f041ae55310439224781cf | ||
networks: | ||
- meadowlark-net | ||
ports: | ||
- 9092:9092 | ||
links: | ||
- zookeeper | ||
environment: | ||
- ZOOKEEPER_CONNECT=zookeeper:2181 | ||
|
||
connect: | ||
hostname: kafka-connect | ||
container_name: kafka-connect | ||
image: edfialliance/connect-meadowlark:2.3-1@sha256:6605d2f0ad1797ccf7e3f7a4dbe690bb0c9e198dd6a0d5720a7b170d0bc4ca95 | ||
ports: | ||
- 8083:8083 | ||
networks: | ||
- meadowlark-net | ||
links: | ||
- kafka | ||
environment: | ||
- BOOTSTRAP_SERVERS=kafka:9092 | ||
- GROUP_ID=1 | ||
- CONFIG_STORAGE_TOPIC=debezium_config | ||
- OFFSET_STORAGE_TOPIC=debezium_offset | ||
- STATUS_STORAGE_TOPIC=debezium_status | ||
|
||
# Kafka Web UI - https://github.com/obsidiandynamics/kafdrop | ||
kafdrop: | ||
hostname: kafdrop | ||
container_name: kafdrop | ||
image: obsidiandynamics/kafdrop:3.31.0@sha256:f89f34f56e72188aa61b557866dbece57238a74c599e88105b200c2532bb804b | ||
ports: | ||
- 9000:9000 | ||
networks: | ||
- meadowlark-net | ||
environment: | ||
KAFKA_BROKERCONNECT: kafka1:9092 | ||
JVM_OPTS: "-Xms32M -Xmx64M" | ||
SERVER_SERVLET_CONTEXTPATH: "/" | ||
|
||
volumes: | ||
zookeeper-logs: | ||
zookeeper-data: | ||
|
||
networks: | ||
meadowlark-net: | ||
external: true |
32 changes: 32 additions & 0 deletions
32
Meadowlark-js/backends/meadowlark-kafka-stream/docker/opensearch_sink.json.example
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,32 @@ | ||
{ | ||
"name":"kafka_opensearch", | ||
"config": { | ||
"connector.class": "io.aiven.kafka.connect.opensearch.OpensearchSinkConnector", | ||
"topics": "edfi.meadowlark.documents", | ||
"type_name": "_doc", | ||
|
||
"connection.url": "<your-opensearch-url>", | ||
"connection.username": "<your-opensearch-username-goes-here>", | ||
"connection.password": "<your-opensearch-password-goes-here>", | ||
|
||
"tasks.max":"1", | ||
|
||
"key.converter": "org.apache.kafka.connect.json.JsonConverter", | ||
"key.converter.schemas.enable": "false", | ||
"value.converter": "org.apache.kafka.connect.json.JsonConverter", | ||
"value.converter.schemas.enable": "false", | ||
|
||
"schema.ignore": "true", | ||
|
||
"compact.map.entries": "true", | ||
|
||
"transforms": "removeId, generateIndexFromResource", | ||
"transforms.removeId.type": "org.apache.kafka.connect.transforms.ReplaceField$Value", | ||
"transforms.removeId.exclude": "_id", | ||
"transforms.generateIndexFromResource.type":"com.github.edfiexchangeoss.meadowlark.kafka.connect.transforms.GenerateIndexFromResource", | ||
"transforms.generateIndexFromResource.field.name":"projectName, resourceVersion, resourceName", | ||
|
||
"behavior.on.version.conflict": "ignore" | ||
|
||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
Meadowlark-js/backends/meadowlark-kafka-stream/docker/readme.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,71 @@ | ||
# Using Kafka for Event processing | ||
|
||
To setup with Debezium and connect to MongoDB and OpenSearch, run the `docker compose up -d`. Then execute the following | ||
steps: | ||
|
||
## Configure Debezium | ||
|
||
The Debezium Kafka Connector must be configured with the MongoDB admin username and password to listen to MongoDB change | ||
stream. To do this, copy the `debezium-mongodb.json.example` file to `debezium-mongodb.json`. Edit the json file and insert | ||
the MongoDB admin username and password. Then send the configuration to the Debezium Kafka Connector: | ||
|
||
Linux: | ||
|
||
```bash | ||
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" \ | ||
http://localhost:8083/connectors/ -d @debezium-mongodb.json | ||
``` | ||
|
||
Windows: | ||
|
||
```pwsh | ||
Invoke-RestMethod -Method Post -InFile .\debezium-mongodb.json ` | ||
-uri http://localhost:8083/connectors/ -ContentType "application/json" | ||
``` | ||
|
||
## Send Kafka Events to OpenSearch | ||
|
||
The Debezium Kafka Connector must be configured with the OpenSearch admin username and password to send the data streams to opensearch. To do this, copy the `opensearch_sink.json.example` file to `opensearch_sink.json`. Edit the json file and insert | ||
the connection username and password. Then send the configuration to the Debezium Kafka Connector: | ||
|
||
Linux: | ||
|
||
```bash | ||
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" \ | ||
http://localhost:8083/connectors/ -d @opensearch_sink.json | ||
``` | ||
|
||
Windows: | ||
|
||
```pwsh | ||
Invoke-RestMethod -Method Post -InFile .\opensearch_sink.json ` | ||
-uri http://localhost:8083/connectors/ -ContentType "application/json" | ||
``` | ||
|
||
### Verify configuration | ||
|
||
To check that connectors are running, execute: | ||
|
||
```bash | ||
curl http://localhost:8083/connector-plugins | jq . | ||
``` | ||
|
||
```pwsh | ||
Invoke-RestMethod http://localhost:8083/connector-plugins | ConvertTo-Json | ConvertFrom-Json | ||
``` | ||
|
||
This returns the debezium connectors and the OpenSearch connector information. | ||
|
||
### Browsing Kafka Topics and Messages | ||
|
||
[Kafdrop](https://github.com/obsidiandynamics/kafdrop), a free Kafka Web UI, is | ||
bundled with this deployment. Browse the Kafka instance with Kafdrop at | ||
`http://localhost:9000/`. | ||
|
||
### View Logs | ||
|
||
To view logs and additional information, use the `kafka-console-consumer.sh` script inside kafka-connect: | ||
|
||
```bash | ||
docker exec -it kafka1 ./bin/kafka-console-consumer.sh --bootstrap-server 172.18.0.9:9092 --topic edfi.meadowlark.documents --from-beginning --max-messages 1 | jq . | ||
``` |
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
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
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
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
Oops, something went wrong.