BigBoot / AutoKuma

AutoKuma is a utility that automates the creation of Uptime Kuma monitors based on Docker container labels. With AutoKuma, you can eliminate the need for manual monitor creation in the Uptime Kuma UI.
MIT License
312 stars 15 forks source link

{{container_name}} not working #14

Closed jordanlambrecht closed 8 months ago

jordanlambrecht commented 8 months ago

I'm having some issues getting the dynamic variables to work.

I keep getting this error: WARN autokuma::sync > Encountered error during sync: Encountered errors trying to validate '{{container_name}}': ["Missing property 'name'"]

Here's my compose file:

x-common-service-config: &common-service-config
  environment:
    TZ: ${TZ}
    PUID: ${PUID}
    PGID: ${PGID}
    UMASK: ${UMASK}
  networks:
    - <redacted>
  restart: always

services:
  uptime-kuma:
    <<: *common-service-config
    image: louislam/uptime-kuma:1
    container_name: uptime-kuma
    volumes:
      - ./uptime-kuma:/app/data
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      WEBSOCKET: "true"
    networks:
      <redacted>:
        aliases:
          - kuma
    ports:
      - ${UPTIME_KUMA_PORT}:${UPTIME_KUMA_PORT}
    labels:
      kuma.controltower.group.name: "Control Tower"
      kuma.{{container_name}}.http.name: "Uptime Kuma"
      kuma.{{container_name}}.http.url: "http://kuma:3001"
      kuma.{{container_name}}.http.parent_name: "control-tower"
      kuma.{{container_name}}.docker.parent_name: "control-tower"
      kuma.{{container_name}}.docker.name: "uptime-kuma"
      kuma.{{container_name}}.docker.docker_container: "uptime-kuma"

  autokuma:
    <<: *common-service-config
    image: ghcr.io/bigboot/autokuma:latest
    container_name: autokuma
    restart: unless-stopped
    hostname: autokuma
    environment:
      AUTOKUMA__KUMA__URL: http://kuma:3001
      AUTOKUMA__KUMA__USERNAME: "${ADMIN_USERNAME}"
      AUTOKUMA__KUMA__PASSWORD: "${ADMIN_PASSWORD}"
      AUTOKUMA__URL: http://kuma:3001
      AUTOKUMA__USERNAME: "${ADMIN_USERNAME}"
      AUTOKUMA__PASSWORD: "${ADMIN_PASSWORD}"
      AUTOKUMA__TAG_NAME: AutoKuma
      AUTOKUMA__TAG_COLOR: "#42C0FB"
      AUTOKUMA__DEFAULT_SETTINGS: |-
        docker.docker_container: {{container_name}}
        http.max_redirects: 10
        http.max_retries: 2
      AUTOKUMA__DOCKER__SOCKET: /var/run/docker.sock
      AUTOKUMA__DOCKER__LABEL_PREFIX: kuma
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - uptime-kuma

overseerr:
    <<: *common-service-config
    image: sctx/overseerr:develop
    container_name: overseerr
    hostname: overseerr
    ports:
      - 5055:5055
    volumes:
      - ./overseerr/:/app/config
    labels:
      kuma.mediamanager.group.name: "Media Manager"
      kuma.{{container_name}}.http.name: "Overseerr"
      kuma.{{container_name}}.http.url: "http://overseerr:5055"
      kuma.{{container_name}}.http.parent_name: "media-manager"
      kuma.{{container_name}}.docker.parent_name: "media-manager"
      kuma.{{container_name}}.docker.name: "Overseerr"
      kuma.{{container_name}}.docker.docker_container: "overseerr"

It's probably me doing something stupid, but the documentation could really benefit from some more granular instructions and a detailed example docker-compose file. Also there's some conflicting information between the documentation and the release notes for 0.3.0, hence the doubling-up on the variables- any advice there would be greatly appreciated.

Love this project!

BigBoot commented 8 months ago

Hi, there are actually a few problems with this config:

  1. Templates are currently not supported in the label names, only values -> This has been added in master
  2. Container names start with a "/" because of some legacy stuff in docker, this would be invalid in docker label names -> {{container_name}} will now strip the leading "/" in master
  3. Your group id is controltower/mediamanager but you try to assign the children to control-tower/media-manager -> Make sure your id's are in sync
  4. The http/docker monitors share the same id {{container_name}}, this is not supported -> Use separate ids for all monitors, e.g. kuma.{{container_name}}-http.http./kuma.{{container_name}}-docker.http.