Skip to main content

learn

Quickstart

Here's a minimal example that generates data to Kafka to get you up and running.

Up and running​

Create a license file​

Create a license.env file with your license variables. If you don't have one yet, you can get one here for free.

LICENSE_ID=xxx
LICENSE_EMAIL=xxx
LICENSE_ORGANIZATION=xxx
LICENSE_EDITION=xxx
LICENSE_EXPIRATION=xxx
LICENSE_SIGNATURE=xx

Set the configuration​

Create a hello-world.json file with this configuration. Don’t worry about the connection details, as you'll see in a minute.

{
"generators": [
{
"topic": "testTopic",
"value": {
"emoji": {
"_gen": "oneOf",
"choices": [
"πŸ‘", "πŸ”₯", "❀️"
]
}
}
}
],
"connections": {
"localKafka": {
"kind": "kafka",
"producerConfigs": {
"bootstrap.servers": "localhost:9092",
"key.serializer" : "io.shadowtraffic.kafka.serdes.JsonSerializer",
"value.serializer" : "io.shadowtraffic.kafka.serdes.JsonSerializer"
}
}
}
}

Launch ShadowTraffic​

Launch ShadowTraffic in watch mode (--watch).

This command will print out 10 example events and then stop. Every time you change your config file, it'll rerun.

The --stdout flag sends all generated data to your terminal, so it doesn't write to Kafka, giving you an interactive development flow. Note that --stdout, --watch, and --sample are all non-mandatory flags.

docker run --env-file license.env -v $(pwd)/hello-world.json:/home/config.json shadowtraffic/shadowtraffic:latest --config /home/config.json --watch --sample 10 --stdout

Connect to Kafka​

Update your configuration file to connect to a live Kafka instance, then rerun the Docker command without --stdout, --sample, and --watch. Data should flow into your topic.

If your Kafka broker is running on localhost, you may need to turn off Docker networking with --net=host so the broker endpoint is resolvable.


Want to learn more? Try the video guides or the cheat sheet.