Skip to content

Deployment

Dave Schmid edited this page Nov 22, 2024 · 4 revisions

Deployment with Docker Compose

The Qingping Air Monitor Lite MQTT to InfluxDB Collector is designed to run within a Docker container, ensuring consistency, portability, and simplified deployment. Below are the steps to deploy the collector using Docker Compose.


Prerequisites

  1. Docker and Docker Compose Installed
    Ensure Docker and Docker Compose are installed on the host system.

  2. InfluxDB Setup
    Confirm that an InfluxDB instance is running and accessible.

  3. MQTT Broker Configuration
    Set up a compatible MQTT broker (e.g., Mosquitto, EMQX) and configure your Qingping devices to publish to this broker.


Deployment Steps

1. Create a compose.yaml File

name: qingping-collector
services:
  qingping-collector:
    command:
      - python
      - main.py
    container_name: qingping-collector
    environment:
      # InfluxDB Configuration
      INFLUXDB_BUCKET: qingping
      INFLUXDB_ORG: YourOrg
      INFLUXDB_TOKEN: your-influxdb-token
      INFLUXDB_URL: http://your-influxdb-server:8086/
      INFLUXDB_BATCH_SIZE: "100"
      INFLUXDB_FLUSH_INTERVAL: "5000"
      INFLUXDB_ENABLE_GZIP: "true"

      # MQTT Broker Configuration
      MQTT_BROKER_ADDRESS: your-mqtt-broker
      MQTT_BROKER_PORT: "1883"
      MQTT_KEEPALIVE: "60"
      MQTT_USERNAME: your-mqtt-username
      MQTT_PASSWORD: your-mqtt-password
      MQTT_TOPIC: qingping/#

      # Logging Configuration
      LOG_LEVEL: INFO

      # Reconnection Strategy
      MAX_RECONNECT_DELAY: "60"
      MAX_RECONNECT_ATTEMPTS: "5"

      # Other Configurations
      TZ: America/Chicago
      USE_CURRENT_TIME: "1"
      SET_DEVICE_INTERVALS: "0"
      DEFAULT_REPORT_INTERVAL: "10"
      DEFAULT_COLLECT_INTERVAL: "10"

    image: lux4rd0/qingping-collector:latest
    restart: always
    networks:
      default: null
networks:
  default:
    name: qingping-collector_default

2. Run the Collector

docker-compose up -d

This will start the collector in detached mode. Logs can be monitored using docker logs:

docker logs -f qingping-collector

Notes on Deployment

  1. Docker Requirement
    This collector is designed to run exclusively in Docker. Deploying it directly on a host system is not supported.

  2. Environment Variables
    Customize the environment variables in the compose.yaml file to fit your specific MQTT broker and InfluxDB setup.

  3. Restart Policy
    The restart: always policy ensures the service automatically restarts in case of a crash or system reboot.

  4. Network Configuration
    By default, the collector operates on an isolated Docker network. Ensure that your MQTT broker and InfluxDB are accessible from this network.

  5. Time Zones
    The TZ environment variable ensures the container operates in the desired time zone.


Verifying Deployment

  1. Check Container Status

    docker ps

    Confirm that the qingping-collector container is running.

  2. Monitor Logs

    docker logs -f qingping-collector
  3. Verify Data in InfluxDB
    Use the InfluxDB UI or API to confirm data is being written to the configured bucket.


Troubleshooting

  • Connectivity Issues
    Ensure the MQTT broker and InfluxDB URLs are correct and accessible from within the container.

  • Data Not Flowing
    Check MQTT logs to confirm devices are publishing data to the broker.

  • Timestamps Off
    Set the USE_CURRENT_TIME flag to 1 to use the collector's local time instead of payload timestamps.


Clone this wiki locally