MongoDB
Datafly Signal delivers events to MongoDB for flexible, document-oriented NoSQL storage with rich querying, aggregation, and indexing capabilities.
Prerequisites
Before configuring MongoDB in Signal, you need a MongoDB instance (self-hosted or Atlas), a database and collection, and a connection URI.
Set Up a MongoDB Instance
You have two options:
Option A: MongoDB Atlas (Managed)
- Sign up at mongodb.com/cloud/atlas.
- Create a new project and click Build a Cluster.
- Choose a tier:
- M0 (Free) — suitable for development and testing.
- M10+ — production-ready with dedicated resources.
- Select a cloud provider and region.
- Click Create Cluster.
Option B: Self-Hosted MongoDB
- Install MongoDB using the official guide.
- Start the
mongodprocess. - Ensure the server is accessible from your Signal infrastructure.
Configure Network Access (Atlas)
- In Atlas, go to Network Access > Add IP Address.
- Add the IP addresses of your Signal deployment.
- Click Confirm.
Never whitelist 0.0.0.0/0 (allow from anywhere) in production. Restrict access to only your Signal infrastructure IP addresses.
Create a Database User
For Atlas:
- Go to Database Access > Add New Database User.
- Choose Password authentication.
- Enter a Username (e.g.
datafly_signal) and Password. - Under Database User Privileges, select Read and write to any database or restrict to a specific database with
readWriterole. - Click Add User.
For Self-Hosted:
use admin
db.createUser({
user: "datafly_signal",
pwd: "your_secure_password",
roles: [
{ role: "readWrite", db: "datafly_events" }
]
})Get the Connection URI
For Atlas:
- In your cluster, click Connect > Connect your application.
- Select Driver: Node.js (or any driver — the URI format is the same).
- Copy the Connection string (e.g.
mongodb+srv://datafly_signal:[email protected]/datafly_events). - Replace
<password>with the actual password.
For Self-Hosted:
The URI format is: mongodb://datafly_signal:password@hostname:27017/datafly_events
Create a Database and Collection
MongoDB creates databases and collections automatically on first write. However, you can create them explicitly:
use datafly_events
db.createCollection("events")
db.events.createIndex({ "timestamp": -1 })
db.events.createIndex({ "type": 1, "event": 1 })Creating indexes in advance improves query performance. The timestamp descending index is useful for retrieving recent events, and the compound index on type and event optimises filtered queries.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
connection_uri | secret | Yes | The MongoDB connection string (e.g. mongodb+srv://user:[email protected]/dbname). |
database | string | Yes | The target database name. |
collection | string | Yes | The target collection name to insert documents into. |
Signal Setup
Quick Setup
- Navigate to Integrations in the sidebar.
- Open the Integration Library tab.
- Find MongoDB or filter by Cloud Storage.
- Click Install, select a variant if available, and fill in the required fields.
- Click Install Integration to create the integration with a ready-to-use default blueprint.
API Setup
curl -X POST http://localhost:8084/v1/admin/integration-catalog/mongodb/install \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "MongoDB",
"variant": "default",
"config": {
"connection_uri": "mongodb+srv://datafly_signal:[email protected]/datafly_events",
"database": "datafly_events",
"collection": "events"
},
"delivery_mode": "server_side"
}'Testing
- Enable the integration in Signal and trigger a test event on your website.
- Connect to your MongoDB instance and query the collection:
use datafly_events
db.events.find().sort({ timestamp: -1 }).limit(10)- Or in Atlas, use the Browse Collections interface to view documents.
- In Signal, check the Live Events view to confirm delivery status shows as successful.
Troubleshooting
| Problem | Solution |
|---|---|
| Events not appearing in the collection | Verify the connection URI, database, and collection name are correct. |
Authentication failed | The username or password in the connection URI is incorrect. Verify the database user credentials. |
| Connection timeout | Check that Signal’s IP addresses are whitelisted in Atlas Network Access (or firewall rules for self-hosted). Verify DNS resolution. |
not authorized on database | The database user lacks readWrite permission on the database. Update the user’s roles in Database Access. |
MongoServerSelectionError | The connection string may be incorrect or the cluster is unreachable. Check the URI format and network connectivity. |
| Document too large | MongoDB documents cannot exceed 16 MB. Check the event payload size. |
| Write concern errors | If using replica sets, verify the write concern configuration. Default write concern (w:1) is sufficient for most use cases. |
Visit MongoDB documentation for full query reference, aggregation pipeline guides, and Atlas management.