Sign inSign up

novinem/uptimebot

By novinem

Updated 11 months ago

The UptimeBot is responsible for automatically managing our Uptime-Kuma installation.

Image
Monitoring & observability
0

787

novinem/uptimebot repository overview

About this image

This repository contains the dockerfile (and PHP source code) for building our 'UptimeBot'. The UptimeBot is responsible for automatically managing our Uptime-Kuma installation when changes occur in one of the backends.

The tasks that the UptimeBot automates are:

  • Deploying a new 'Monitor' (for one or more domains) when we deploy a new website on a backend server.
  • Deleting an old 'Monitor' (for one or more domains) when we delete a website from a backend server.

About: Known Limitations

Tags: While Uptime-Kuma supports tags, the Web-API that we use doesn't. The code is ready for use with tags, but until the API supports it we can't do shit about it.

Manual changes: The UptimeBot will remove all the hosts that you manually add unless they start with a dot (.). We would love to work with Tags so that the UptimeBot can 'remember' what hosts are managed by the UptimeBot. However, as you can read above, tags are not yet supported by the API.

About: Implementations

While the UptimeBot is capable of plug'n'play different types of backends and logging services(by extending the abstract classes and re-building the image), this current version only implements the following services:

  • Backend:
    • Traefik (via the JSON API)
    • Virtualmin (via the WEB API)
  • Logging: Slack

Installation: Requirements

This image is only an implementation of the UptimeBot itself. This means that the actual Uptime Kuma instance and the Web-API need to be run as a standalone Docker image (or on the host directly). Also, we ofcourse assume that you already have a working implementation of (at least) one backend server (Traefik or Virtualmin) and that this server is reachable by the (future) UptimeBot server.

Installation: With Plain Docker

  1. Download the UptimeBot image from the Docker Hub with the ID: novinem/uptimebot.
  2. Make sure the required files/folders are mounted in the container. Based on the default config.yml settings these are:
    1. /usr/src/dynamic_config/config.yml - The config for the UptimeBot (see the config.yml.example)
  3. Start the container with: docker run --rm novinem/uptimebot -v ...
    • Like you see, this image doesn't expose any ports.

Installation: With Docker-compose

  1. Copy the docker-compose.yml file to your directory.
  2. Make sure the required files/folders exist in your working directory. See the chapter above for details about the required files and folders.
  3. Run the UptimeBot with: docker compose up

Example: docker-compose.yml

---
version: '3'
    
services:
    
  uptimebot_kuma:
    container_name: uptime-kuma
    image: louislam/uptime-kuma:latest
    ports:
      - "3001:3001"
    restart: always
    volumes:
      - uptime-kuma:/app/data

  uptimebot_api:
    container_name: uptimebot_api
    image: novinem/uptime-kuma-web-api:latest
    volumes:
      - api-db:/db
    restart: always
    environment:
      - KUMA_SERVER=http://uptimebot_kuma:3001
      - KUMA_USERNAME=<username>
      - KUMA_PASSWORD=<username>
      - ADMIN_PASSWORD=<choose_api_admin_pass>
      - ACCESS_TOKEN_EXPIRATION=1440
    depends_on:
      - uptimebot_kuma
      
  uptimebot_autoconfig:
    image: novinem/uptimebot:latest
    container_name: uptimebot_autoconfig
    volumes:
      # Bind mounts (dynamic config)
      - ./mounts/dynamic-config:/usr/src/dynamic_config
    depends_on:
      - uptimebot_api
    restart: unless-stopped

volumes:
  uptime-kuma:
    name: uptime-kuma
  
  api-db:
    name: api-db

Example: config.yml


# |||||||||||||||||||||||||||||||||||||
# |
# | Dynamic configuration
# |
# |||||||||||||||||||||||||||||||||||||

monitor_only_main_domain: true
monitor_clean_on_startup: true

# These settings have to match the docker compose
api_url: http://uptimebot_api:8000/ 
api_admin_password: admin

continuous: false
continuous_delay_ms: 30000

# You can use multiple loggers at once.
# The different values for 'log_level' are: debug, info, warning, error, fatal
# The 'backends' parameter accepts an array of names for backends (name) to which this logger applies. If this array is empty, then this logger will only log non-backend specific errors.
loggers:
  - type: slack
    backends: []
    log_level: debug
    type_meta:
      slack_webhook_url: https://hooks.slack.com/...
  - type: slack
    backends: [backend_name]
    log_level: debug
    type_meta:
      slack_webhook_url: https://hooks.slack.com/...


# 'name' is the name of the backend you want to give it for reference.
# 'traefik_router_exclusions' needs to be an array with the names of the routers that need to be excluded.
backends:
  - name: test_vmin
    type: virtualmin
    type_meta:
      virtualmin_api_url: https://<backend_ip>:10000
      virtualmin_root_password: ROOT_PASSWORD
  - name: backend_name
    type: traefik
    type_meta:
      traefik_api_url: http://<backend_ip>:8080
      traefik_router_exclusions:
        - dashboard@internal
        - api@internal



# |||||||||||||||||||||||||||||||||||||
# |
# | Static configuration 
# | 
# | !! (IMPORTANT) These files and paths are hardcoded in the image and exist only in this config for future reference.
# | So, only change this if you know what you are doing.
# |
# |||||||||||||||||||||||||||||||||||||

dynamic_config_dir: /usr/src/dynamic_config

Tag summary

Content type

Image

Digest

sha256:8911f950c

Size

125.6 MB

Last updated

11 months ago

docker pull novinem/uptimebot