Inserting and deleting events


Lenses gives you the ability to produce (insert) messages in different ways. You can use this to debug your flows, automate scenarios or fix errors.

You can insert new messages in the topic via the UI:

  1. Make sure the Key, Value types are correct ( and not BYTES )
  2. Click on the Actions menu of your topic
  3. Select Insert Messages
Topic Action Menu

The input expects an array of messages in a JSON format. You can therefore insert one or multiple messages at the same time. Lenses will follow the known schema to be able to insert the message. In the case of AVRO, the schema is known via the connected Schema Registry. Make sure you have set the Key and Value types to the relevant serialization format (ie. AVRO, JSON, String, etc ).

In certain cases you can auto generate the message with random values. Lenses will use the known schema of the key and the value, and synthetically generate a message.

Insert auto generate

Insert message with headers

You can also produce message with headers by including it to the JSON representation:

[
  {
    "headers": {
       "h1": "...",
       "h2": "..."
    },
    "key" : "...",
    "value": "..."
  }
]

See here

Insert using SQL

If you want to automate or make repeatable the insertion of new messages in Kafka topics, use the INSERT INTO SQL statement. Example:

INSERT INTO customer (_key, id, address.line, address.city, address.postcode, email)
VALUES ('david.green', 'david.green', '4309 S Morgan St', 'Chicago', 60609, 'david.green@lenses.io');

Delete data

Deleting data from topics is supported by removing all messages from a partition up to a specific offset. The deletion of messages on compacted topics is also supported.

From the Actions menu of your topic, select Delete Messages

Delete messages

Delete using SQL

DELETE FROM customer WHERE _meta.offset <=10