aserowy / docker2mqtt

Monitor your docker environment over mqtt the easy way.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker2mqtt

dependabot status release ci license pulls size

introduction

docker2mqtt enables monitoring of your docker containers via mqtt. In addition, docker2mqtt also supports Home Assistant discovery and creates a single device for each container, where different sensors can be used to monitor the current state of the container.

This implementation is implemented in Rust. This keeps the image size small and creates an environment for long runtimes. docker2mqtt relies on the docker.sock to read out current states.

configuration

docker2mqtt is configured using yaml. The confiugation is then provided to the container via volumes. In a docker-compose.yaml, the container can be initialized as follows:

version: "3.0"
services:
  docker2mqtt:
    image: serowy/docker2mqtt:latest
    container_name: docker2mqtt
    restart: always
    volumes:
      - ~/docker2mqtt/config:/docker2mqtt/config
      - ~/docker2mqtt/data:/docker2mqtt/data
      - ~/docker2mqtt/logs:/docker2mqtt/logs
      - /var/run/docker.sock:/var/run/docker.sock

In the directory ~/docker2mqtt/config the configuration of the service is then done by configuration.yaml. Commented values are optional and are filled by corresponding defaults:

# docker:
  # persist_state enables persistence of the current state to handle container changes while docker2mqtt
  #   is asleep. This ensures that e.g. home assistant sensors are up to date. [default: false]
  # persist_state: true

  # stream_logs enables streams for container logs with mqtt. [default: true]
  # stream_logs: false

  # stream_logs_container is a white list filter for container names. [default: empty]
  #
  # IMPORTANT: Do not enable logging for e.g. mosquitto or hassio because it can cause feedback loops!
  #   Because of this, docker2mqtt will get removed automatically!
  #
  # stream_logs_container:
  #   - watchtower
  #   - borg

  # stream_logs_filter is a regex powered white list filter for streamed logs. [default: empty]
  # stream_logs_filter:
  #   - error
  #   - test_word
  #   - .*

# hassio:
  # discovery enables (true) or disables (false) discovery messages for home assistant
  discovery: true

  # discovery_prefix should point to the configured prefix in home assistant [default: homeassistant]
  # discovery_prefix:

  # device_prefix is used to prefix all created devices (container) in home assistant [default: docker]
  # device_prefix:

# logging:
  # sets the logging level (TRACE, DEBUG, INFO, WARN, and ERROR) at start up [default: INFO]
  # level:

mqtt:
  # client_id is the id to uniquely identify the sender
  client_id:

  # host is the remote hostname of your mqtt broker e.g. mosquitto
  host:

  # port of your mqtt broker e.g. 1883 for mosquitto
  port:

  # password: # default: None
  # username: # default: None

  # connection_timeout: # default: 20
  # keep_alive: # default: 30
  # qos: # default: 0

About

Monitor your docker environment over mqtt the easy way.

License:MIT License


Languages

Language:Rust 95.4%Language:Dockerfile 3.7%Language:Nix 0.9%