- 18 Mar 2025
- 1 Minute to read
- Print
- PDF
MongoDB Time-Series
- Updated on 18 Mar 2025
- 1 Minute to read
- Print
- PDF
Overview
The MongoDB connector inserts all the Sparkplug metrics into a MongoDB Time-Series collection including the context and metadata provided by the Sparkplug protocol.
Each event stored in the database contains the following:
The event timestamp, name, data type and value.
The Sparkplug metadata in the meta object.
The Sparkplug properties (if any) in the properties object.
Configuration
The default configuration for the MongoDB connector:
...
# Connectors configuration
[connectors]
name = "mongo"
# MongoDB
[connectors.mongo]
# Connection URI
# Example:
# - mongodb+srv://<username>:<password>@cluster.8wkd5pc.mongodb.net/?retryWrites=true&w=majority
uri = ""
# SSL/TLS configuration
tls_enabled = true
tls_client_certificate = ""
tls_client_certificate_key = ""
tls_certificate_authority = ""
tls_insecure_skip_verify = false
# Name of the database
database = "enterprise"
# Name of the time-series collection
collection = "uns-data"
Atlas Cluster
Example configuration to securely connect with a MongoDB Atlas cluster using SCRAM-SHA-256 authentication (username/password) and TLS encryption:
...
# Connectors configuration
[connectors]
name = "mongo"
# MongoDB
[connectors.mongo]
# Connection URI
uri = "mongodb+srv://<username>:<password>@cluster.8qjd4ff.mongodb.net/?retryWrites=true&w=majority"
# SSL/TLS configuration
tls_enabled = true
tls_client_certificate = ""
tls_client_certificate_key = ""
tls_certificate_authority = ""
tls_insecure_skip_verify = false
# Name of the database
database = "enterprise"
# Name of the time-series collection
collection = "uns-data"
Atlas Cluster with mTLS
Example configuration to securely connect to a MongoDB Atlas cluster using mutual TLS authentication with x.509 certificates:
...
# Connectors configuration
[connectors]
name = "mongo"
# MongoDB
[connectors.mongo]
# Connection URI
uri = "mongodb+srv://cluster.8qjd4ff.mongodb.net/?retryWrites=true&w=majority"
# SSL/TLS configuration
tls_enabled = true
tls_client_certificate = "/etc/sparkpipe/certs/client.crt"
tls_client_certificate_key = "/etc/sparkpipe/certs/client.key"
tls_certificate_authority = "/etc/sparkpipe/certs/ca.crt"
tls_insecure_skip_verify = false
# Name of the database
database = "enterprise"
# Name of the time-series collection
collection = "uns-data"
Self-Managed Database
Example configuration to connect with a self-managed MongoDB database in the same VPC.
...
# Connectors configuration
[connectors]
name = "mongo"
# MongoDB
[connectors.mongo]
# Connection URI
uri = "mongodb://ip-192-168-1-10.us-west-2.compute.internal:27017/?retryWrites=true&tls=false"
# SSL/TLS configuration
tls_enabled = false
tls_client_certificate = ""
tls_client_certificate_key = ""
tls_certificate_authority = ""
tls_insecure_skip_verify = false
# Name of the database
database = "enterprise"
# Name of the time-series collection
collection = "uns-data"