Linking MongoDB as a source
The MongoDB connector can link your MongoDB collections to PostHog.
To link MongoDB:
- Go to the Data pipeline page and the sources tab in PostHog
- Click New source and select MongoDB
- Enter your MongoDB connection string. If your connection string doesn't include a database name, enter it in the optional Database name field.
- Click Next, select the collections you want to sync, as well as the sync method, and then press Import
Tip: MongoDB Atlas SRV connection strings usually omit the database name (e.g.,
mongodb+srv://user:pass@cluster.mongodb.net/). If yours doesn't include one, fill in the Database name field. A database specified in the connection string (e.g.,mongodb+srv://user:pass@cluster.mongodb.net/my_database) takes precedence over this field.
Once the syncs are complete, you can start using MongoDB data in PostHog.
Note: MongoDB data is unstructured so the returned columns are an
_idfield and adatacolumn that contain the entire document contents. Data fields can be selected with dot notation (e.g.data.field1)
Configuration
| Option | Description |
|---|---|
Connection StringType: text Required: True | |
Database nameType: text Required: False | Only needed if your connection string doesn't already include the database (Atlas |
Incremental and append-only syncing
MongoDB supports incremental and append-only sync methods. For a field to be available for these sync methods, it must:
- Have an index — only indexed fields are eligible.
- Be a supported type — the following BSON types work:
dateortimestampintorlongdoubleordecimalobjectId(only for the_idfield)
PostHog infers field types from the first 10,000 documents in the collection, so fields with mixed types may resolve to an unsupported type.
Inbound IP addresses
We use a set of IP addresses to access your instance. To ensure this connector works, add these IPs to your inbound security rules:
| US | EU |
|---|---|
| 44.205.89.55 | 3.75.65.221 |
| 44.208.188.173 | 18.197.246.42 |
| 52.4.194.122 | 3.120.223.253 |