Firebase Connector
Overview
Section titled “Overview”The Firebase connector enables writing data to Google Cloud Firestore, a flexible, scalable NoSQL cloud database for mobile, web, and server development.
Connector Types:
FirebaseWriter- Write documents to Firestore collections
Firebase Writer
Section titled “Firebase Writer”Write data to a Firestore collection:
{ "type": "FirebaseWriter", "config": { "credentialsFile": { "mode": "base64", "data": "<base64-encoded-service-account-json>" }, "projectId": "my-firebase-project", "collection": "sensor_readings" }}With Custom Database
Section titled “With Custom Database”Connect to a specific Firestore database (for multi-database projects):
{ "type": "FirebaseWriter", "config": { "credentialsFile": { "mode": "path", "data": "/path/to/service-account.json" }, "projectId": "my-firebase-project", "databaseName": "production-db", "collection": "iot_events" }}Configuration Parameters
Section titled “Configuration Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
credentialsFile | EncodedFile | ✅ | Service account credentials file |
projectId | string | ✅ | Firebase/GCP project ID |
collection | string | ✅ | Firestore collection name |
databaseName | string | ❌ | Firestore database name (for multi-database projects) |
Credentials File Format
Section titled “Credentials File Format”The credentialsFile parameter supports two modes:
Base64 Encoded
Section titled “Base64 Encoded”{ "credentialsFile": { "mode": "base64", "data": "eyJ0eXBlIjoic2VydmljZV9hY2NvdW50Ii..." }}File Path
Section titled “File Path”{ "credentialsFile": { "mode": "path", "data": "/etc/meddle/firebase-credentials.json" }}Service Account Setup
Section titled “Service Account Setup”- Go to Firebase Console
- Select your project → Project Settings → Service Accounts
- Click “Generate new private key”
- Download the JSON file
- Use the file path or base64-encode the contents
Data Format
Section titled “Data Format”Each data payload is added as a new document in the specified collection:
{ "temperature": 25.5, "pressure": 101.3, "humidity": 60, "timestamp": 1234567890}Firestore automatically generates a unique document ID for each entry.
Common Use Cases
Section titled “Common Use Cases”1. IoT Sensor Data
Section titled “1. IoT Sensor Data”Store sensor readings in Firestore:
{ "type": "FirebaseWriter", "config": { "credentialsFile": { "mode": "path", "data": "/config/firebase-sa.json" }, "projectId": "iot-monitoring", "collection": "sensor_data" }}2. Event Logging
Section titled “2. Event Logging”Log system events to Firestore:
{ "type": "FirebaseWriter", "config": { "credentialsFile": { "mode": "base64", "data": "<credentials>" }, "projectId": "event-tracker", "collection": "system_events" }}3. Multi-Database Architecture
Section titled “3. Multi-Database Architecture”Write to a specific database in a multi-database project:
{ "type": "FirebaseWriter", "config": { "credentialsFile": { "mode": "path", "data": "/config/firebase-sa.json" }, "projectId": "enterprise-app", "databaseName": "analytics-db", "collection": "metrics" }}Troubleshooting
Section titled “Troubleshooting”Initialization Failed
Section titled “Initialization Failed”Solutions:
- Verify credentials file is valid JSON
- Check project ID matches your Firebase project
- Ensure service account has Firestore permissions
- Verify base64 encoding if using base64 mode
Write Failed
Section titled “Write Failed”Solutions:
- Check collection name is valid
- Verify Firestore security rules allow writes
- Ensure service account has
datastore.userrole - Check Firestore quotas and limits
Client Connection Error
Section titled “Client Connection Error”Solutions:
- Verify network connectivity to Google Cloud
- Check firewall allows outbound HTTPS (port 443)
- Ensure credentials haven’t expired or been revoked
Best Practices
Section titled “Best Practices”- Use Service Accounts: Never use user credentials in production
- Limit Permissions: Grant only necessary Firestore permissions
- Organize Collections: Use meaningful collection names with clear hierarchy
- Monitor Usage: Track Firestore read/write operations for cost management
- Secure Credentials: Store credentials securely, never commit to version control