Skip to main content

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​

Set up the fake data producer​

Use the Dockerized fake data producer for Aiven for Apache Kafka® to stream sample messages into a topic.

  1. Clone the repository:

    git clone https://github.com/aiven/fake-data-producer-for-apache-kafka-docker
  2. Copy the sample config file to create your own version:

    cp conf/env.conf.sample conf/env.conf
  3. Open the conf/env.conf file and update the following values:

    • my_project_name: Aiven project name
    • my_kafka_service_name: Apache Kafka service name
    • my_topic_name: Topic name to receive messages
    • my_aiven_email: Aiven login email
    • my_aiven_token: Personal access token
  4. 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'
    tip

    The command uses jq to extract the token from the Aiven CLI output. If jq is not installed, remove the | jq -r '.[].full_token' part and copy the token manually from the JSON output.

  5. Build the Docker image:

    docker build -t fake-data-producer-for-apache-kafka-docker .
    tip

    Rebuild the Docker image after editing the conf/env.conf file.

  6. Start the producer:

    docker run fake-data-producer-for-apache-kafka-docker
  7. 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

Stream sample data from the Aiven Console