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
153 stars 11 forks source link

struggling w/ snippets #39

Closed johntdyer closed 2 months ago

johntdyer commented 2 months ago

I have tried the suggestions in #26 but I still seem to be having issues...

Kuma config

      AUTOKUMA__SNIPPETS__WEB: |-
        {{container_name}}_http.http.name: {{container_name}} HTTP
        {{container_name}}_http.http.url: https://{{@0}}:{{@1}}
        {{container_name}}_docker.docker.name: [http] - {{container_name}} Docker
        {{container_name}}_docker.docker.docker_container: {{container_name}}

Compose

influxdb:
    image: influxdb:latest
    container_name: "influxdb"
    networks:
      - proxy
    restart: unless-stopped
    volumes:
      # Mount for influxdb data directory and configuration
      - /nvme0n1/influxdb:/var/lib/influxdb2
    # ports:
    #   - "8086:8086"
    expose:
      - 8086
    labels:
      - traefik.enable="true"
      - traefik.http.routers.influxdb.rule="Host(`influx.dyer.house`) || Host(`influxdb.dyer.house`)"
      - com.centurylinklabs.watchtower.enable=true
      - kuma.__web="influx.dyer.house",443
    healthcheck:
      interval: 60s
      test: /usr/bin/curl --silent --fail -k http://127.0.0.1:8086 || exit 1
      timeout: 30s
      retries: 2
      start_period: 15s

Error


WARN [kuma_client::util] Error while parsing snippet: Error while trying to parse labels:  --> 2:45
  |
2 | {{container_name}}_http.http.url: https://{{@0}}:{{@1}}
  |                                             ^---
  |
  = expected a value that can be negated or an array of values
Context: Some(Object {"Command": String("/entrypoint.sh influxd"), "Created": Number(1714941224), "HostConfig": Object {"NetworkMode": String("00f90ecbc2420da6a3fc6c5b1ef5d76eddddef8799f189a9bafd7b3f4b68e734")}, "Id": String("c0c2622b1dd6e48605955194b22e04974a4943a181fbdee635d47336b1749db0"), "Image": String("influxdb:latest"), "ImageID": String("sha256:2347a667f34c96dd2bb711053800ded152012feae7a05a6fc33bad80aa435f21"), "Labels": Object {"com.centurylinklabs.watchtower.enable": String("true"), "com.docker.compose.config-hash": String("a0372dc9fb4c452e2e3c68d9a15bce8970e19b6bcfe976d67950aa756473851f"), "com.docker.compose.container-number": String("1"), "com.docker.compose.depends_on": String(""), "com.docker.compose.image": String("sha256:2347a667f34c96dd2bb711053800ded152012feae7a05a6fc33bad80aa435f21"), "com.docker.compose.oneoff": String("False"), "com.docker.compose.project": String("shared-config"), "com.docker.compose.project.config_files": String("/common/shared-config/docker-compose.yaml"), "com.docker.compose.project.working_dir": String("/common/shared-config"), "com.docker.compose.replace": String("dc0f5b99ca92f9f46f52d8300618a78d87c1f44e29c08410725dacabcb78c672"), "com.docker.compose.service": String("influxdb"), "com.docker.compose.version": String("2.26.1"), "kuma.__web": String("\"influx.dyer.house\",443"), "traefik.enable": String("\"true\""), "traefik.http.routers.influxdb.rule": String("\"Host(`influx.dyer.house`) || Host(`influxdb.dyer.house`)\"")}, "Mounts": Array [Object {"Destination": String("/etc/influxdb2"), "Driver": String("local"), "Mode": String("z"), "Name": String("c0a79dc6318b804bc5696ae7f6720e26639d74d6a00b82b9f5e833fbcea67557"), "Propagation": String(""), "RW": Bool(true), "Source": String("/var/lib/docker/volumes/c0a79dc6318b804bc5696ae7f6720e26639d74d6a00b82b9f5e833fbcea67557/_data"), "Type": String("volume")}, Object {"Destination": String("/var/lib/influxdb2"), "Mode": String("rw"), "Propagation": String("rprivate"), "RW": Bool(true), "Source": String("/nvme0n1/influxdb"), "Type": String("bind")}], "Names": Array [String("/influxdb")], "NetworkSettings": Object {"Networks": Object {"proxy": Object {"EndpointID": String("bc1a7bb95863b6fbe4ead07d99530d661b7bc5d59d547d303020d3600d380eba"), "Gateway": String("172.27.0.1"), "GlobalIPv6Address": String(""), "GlobalIPv6PrefixLen": Number(0), "IPAddress": String("172.27.0.46"), "IPPrefixLen": Number(16), "IPv6Gateway": String(""), "MacAddress": String("02:42:ac:1b:00:2e"), "NetworkID": String("00f90ecbc2420da6a3fc6c5b1ef5d76eddddef8799f189a9bafd7b3f4b68e734")}}}, "Ports": Array [Object {"PrivatePort": Number(8086), "Type": String("tcp")}], "State": String("running"), "Status": String("Up 12 seconds (health: starting)")})

this is v0.6.0.

Thanks for any help you can provide and for making such an awesome tool !

BigBoot commented 2 months ago

The syntax for arguments in snippets changed in 0.6.0 due to the switch to Tera, please take a look at the changelog for more details:

      AUTOKUMA__SNIPPETS__WEB: |-
        {{container_name}}_http.http.name: {{container_name}} HTTP
        {{container_name}}_http.http.url: https://{{args[0]}}:{{args[1]}}
        {{container_name}}_docker.docker.name: [http] - {{container_name}} Docker
        {{container_name}}_docker.docker.docker_container: {{container_name}}
johntdyer commented 2 months ago

Thank you , this makes sense now... I was referencing an issue that had the older syntax :)