Generate sample data with Docker
Use a Docker-based producer to generate sample data in Aiven for Apache Kafka®. It creates a customizable stream of messages for testing and development.
This example uses Docker images.
Prerequisites
- Docker or Podman installed
- Active Aiven for Apache Kafka® service
- Access to the Aiven Console
- Kafka REST API enabled
- Personal access token
Set up the fake data producer
Use the Dockerized fake data producer for Aiven for Apache Kafka® to stream sample messages into a topic.
-
Clone the repository:
git clone https://github.com/aiven/fake-data-producer-for-apache-kafka-docker
-
Copy the sample config file to create your own version:
cp conf/env.conf.sample conf/env.conf
-
Open the
conf/env.conf
file and update the following values:my_project_name
: Aiven project namemy_kafka_service_name
: Apache Kafka service namemy_topic_name
: Topic name to receive messagesmy_aiven_email
: Aiven login emailmy_aiven_token
: Personal access token
-
Generate a personal access token in the Aiven Console or use the Aiven CLI:
avn user access-token create \
--description "Token used by fake data generator" \
--max-age-seconds 3600 \
--json | jq -r '.[].full_token'tipThe command uses
jq
to extract the token from the Aiven CLI output. Ifjq
is not installed, remove the| jq -r '.[].full_token'
part and copy the token manually from the JSON output. -
Build the Docker image:
docker build -t fake-data-producer-for-apache-kafka-docker .
tipRebuild the Docker image after editing the
conf/env.conf
file. -
Start the producer:
docker run fake-data-producer-for-apache-kafka-docker
-
Once the Docker image is running, verify that the topic is receiving messages:
- In the Aiven Console, go to your Apache Kafka service and click Topics.
- Or use a command-line tool such as kcat to consume messages from the topic.
Related pages