MongoDB Connector
Overview
Section titled “Overview”The MongoDB connector writes JSON documents to MongoDB collections.
Connector Type: MongoWriter
Configuration
Section titled “Configuration”{ "type": "MongoWriter", "config": { "endpoint": "mongodb://root:password@localhost:27017/", "database": "sensor_db", "collection": "measurements" }}Configuration Parameters
Section titled “Configuration Parameters”- endpoint: MongoDB connection string
- database: Database name
- collection: Collection name
Connection String Formats
Section titled “Connection String Formats”Local MongoDB
Section titled “Local MongoDB”mongodb://localhost:27017/With Authentication
Section titled “With Authentication”mongodb://username:password@localhost:27017/MongoDB Atlas
Section titled “MongoDB Atlas”mongodb+srv://username:password@cluster.mongodb.net/With Options
Section titled “With Options”mongodb://localhost:27017/?authSource=admin&retryWrites=trueData Storage
Section titled “Data Storage”Input payload:
{ "temperature": 25.5, "humidity": 60, "timestamp": 1234567890}Stored as MongoDB document:
{ "_id": ObjectId("..."), "temperature": 25.5, "humidity": 60, "timestamp": 1234567890}Use Case: IoT Data Storage
Section titled “Use Case: IoT Data Storage”{ "type": "MongoWriter", "config": { "endpoint": "mongodb://mongo.local:27017/", "database": "iot_platform", "collection": "sensor_readings" }}Best Practices
Section titled “Best Practices”- Use meaningful database and collection names
- Consider adding timestamps to documents
- Use indexes for frequently queried fields
- Monitor collection size and implement archiving