Generate icon
JsonObjectGenerator icon
Load icon

Generate mock JSON data and send the file to MongoDB

Seed a MongoDB collection with realistic fake data. Kestra generates 100 mock JSON people records with DataGen and bulk-loads them in one declarative flow.

Categories
Data

Need a MongoDB collection full of realistic test data without writing a seeding script? This blueprint generates 100 mock people records (names, emails, addresses, skills, timestamps) as a JSON file with the Kestra DataGen plugin, then bulk-loads that file into a MongoDB collection. It solves the recurring problem of populating dev, staging, or demo databases with believable documents so you can test queries, indexes, dashboards, and downstream pipelines against data that looks real, all from declarative YAML with no throwaway scripts to maintain.

How it works

  1. The datagen task (io.kestra.plugin.datagen.core.Generate) produces fake records using a JsonObjectGenerator. It builds each document from Faker expressions like #{name.fullName}, #{internet.emailAddress}, and #{address.city}, mixes in a static age, a skills array, and a ts field set with {{ now() }}. With batchSize: 100 and store: true, the output is written to Kestra internal storage as a JSON file.
  2. The send_to_mongodb task (io.kestra.plugin.mongodb.Load) reads that file from {{ outputs.datagen.uri }} and bulk-inserts every record into the target collection. The connection uri, database, and collection all come from secrets, so no credentials live in the flow.

What you get

  • A MongoDB collection seeded with 100 realistic, structured JSON documents.
  • Nested fields (address.city, address.zip) and array fields (skills) to exercise real document shapes.
  • A repeatable, parameterized seeding routine instead of ad hoc scripts.
  • Secret-based connection handling, so the same flow runs safely across environments.

Who it's for

  • Backend and full-stack developers who need believable data in a local or shared MongoDB.
  • QA and test engineers validating queries, indexes, and aggregation pipelines.
  • Data and platform engineers building demo or staging environments.
  • Solutions and sales engineers preparing realistic product demos.

Why orchestrate this with Kestra

DataGen and MongoDB have no shared scheduler to tie generation and loading together. Kestra orchestrates both as one declarative flow: it passes the generated file between tasks via {{ outputs.datagen.uri }}, adds retries and alerting on failure, tracks execution lineage and logs, and lets you trigger seeding on a schedule, from an API call, or on demand. You get reproducible, observable data seeding that a standalone generator or a raw mongoimport command cannot coordinate on its own.

Prerequisites

  • A reachable MongoDB instance and a database where the collection can be created.
  • The Kestra DataGen and MongoDB plugins available in your instance.

Secrets

  • MONGO_URI: the MongoDB connection string used by connection.uri.
  • DATABASE_NAME: the target database name.
  • COLLECTION_NAME: the target collection name.

Quick start

  1. Add the secrets MONGO_URI, DATABASE_NAME, and COLLECTION_NAME to your Kestra instance.
  2. Create the flow from this blueprint.
  3. Run it. The datagen task writes a JSON file and send_to_mongodb loads every record.
  4. Query the collection in MongoDB to verify the inserted documents.

How to extend

  • Edit the JsonObjectGenerator value map to match your own schema, adding or removing fields and Faker expressions.
  • Increase batchSize to seed more records per run.
  • Change locale to generate region-specific names and addresses.
  • Add a schedule or webhook trigger to refresh the collection automatically.
  • Chain a downstream task to index the collection or kick off a test suite once loading completes.

Links

Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.