Database connectivity
The application uses SQLAlchemy withpool_pre_ping=True to maintain database connections (src/db.py:9):
Connection string format
The database connection is built from environment variables (src/config.py:22-26):MQTT connection health
Connection configuration
The MQTT client connects using settings from the database and environment variables (src/mqtt_client.py:112):- Host and Port: Retrieved from the
mqtt_serverstable (first enabled server) - Client ID:
MQTT_CLIENT_IDenvironment variable (default:mqtt-gateway) - Keepalive:
MQTT_KEEPALIVEenvironment variable (default:60seconds)
Connection monitoring
Check for connection errors in the log files. Failed connections are logged with the reason code (src/mqtt_client.py:67):0: Connection successful1: Incorrect protocol version2: Invalid client identifier3: Server unavailable4: Bad username or password5: Not authorized
Flow reload interval
The service automatically reloads flows from the database at regular intervals (src/mqtt_client.py:115-122):Changes to flows in the database are picked up automatically without restarting the service. The minimum reload interval is 1 second.
Message processing metrics
Message counter
Each flow maintains alast_msg_id counter that increments with every processed message (src/processor.py:94):
flows table to verify messages are being processed.
Database records
ForSTORE_DB flows, check the data table for recent records:
HTTP endpoint monitoring
Timeout configuration
HTTP POST requests to endpoints have a configurable timeout (src/processor.py:120):Endpoint failures
Failed HTTP requests are logged but don’t stop message processing (src/processor.py:124-129). Monitor logs for:Checking service status
Startup sequence
On startup, the service performs these initialization steps (src/main.py:14-25):- Load configuration from environment variables
- Connect to MariaDB database
- Create tables if they don’t exist
- Seed default MQTT server if none exists
- Load enabled flows from database
- Connect to MQTT broker
- Subscribe to flow topics
Runtime health indicators
- Log files: Check for recent ERROR entries
- Database connectivity: Query the
flowstable - MQTT subscriptions: Verify messages are incrementing
last_msg_id - Process running: Check if the Python process is active