Introducing the new MongoDB target

Jeff Neff

Jeff Neff

Mar 6, 2023
Introducing the new MongoDB target
Introducing the new MongoDB target

In TriggerMesh v1.24 we introduced a new MongoDB target. In this post I want to show you how to set it up. This is particularly useful if you want to store messages persistently or hydrate a data lake based on Mongo.

With the TriggerMesh CLI tmctl, you can create a MongoDB target by using the connection string that you will have previously downloaded (containing the username, password and hostname), the database name and the collection name.

Here's what it looks like with a database called tmctl and a collection called demo:

tmctl create target mongodb --connectionString $(cat connection.string) \
                            --database tmctl \
                            --collection demo

All the parameters that can be used to configure this target can be obtained via tab completion:

tmctl create target mongodb \
        --adapterOverrides  ((object) Kubernetes object parameters to apply on top of default adapter values.)\
        --collection        ((*required,string) Define the default (over-writeable at runtime) collection to write new events to.)\
        --connectionString  ((*required,string/secret) The connection string containing the endpoint for the MongoDB Server and the…)\
        --database          ((*required,string) Define the default (over-writeable at runtime) database to write new events to.)\
        --eventTypes        (Event types filter.)\
        --help              (help for target)\
        --name              (Optional component name.)\
        --source            (Event source name.)\
        --version           (TriggerMesh components version.)

If you want to see all the steps interactively, check out this very short screencast which demonstrates how to build the highly popular integration between a Kafka topic (via a Kafka cluster running in Confluent cloud) and a MongoDB database running on Digital Ocean.

Once you are happy with your local flow you can decide to deploy it on a Kubernetes cluster running TriggerMesh. The MongoDB target API manifest will look like this:

kind: MongoDBTarget
  labels: mongo  
  name: mongo-mongodbtarget
  collection: demo  
      key: connectionString      
      name: mongo-mongodbtarget-secret 
  database: tmctl

Join us on Slack to learn more and put this new target through its paces.

Create your first event flow in under 5 minutes