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
307 stars 15 forks source link

Feature Request: improve error messages when parsing snippets #55

Open lgo opened 4 months ago

lgo commented 4 months ago

I've sort of hit two problems.

  1. I was getting an error which doesn't have any logs for the snippet or context making it hard to pin down.

    WARN [kuma_client::util] Error while parsing snippet arguments: expected value at line 1 column 27
  2. I had a snippet argument that wasn't valid JSON but was expected to be correct.

    - 'kuma.__internal_web_app={ "port": 32400, "path": /web }'

    Which had a mistake with /web not wrapped in quotes, so it's not valid JSON.

For posterity, this was my snippet

      AUTOKUMA__SNIPPETS__INTERNAL_WEB_APP: |-
        {% set args = args[0] %}
        {% if args.path %}
          {% set path = args.path %}
        {% else %}
          {% set path = '/' %}
        {% endif %}
        {{ container_name }}.group.name: {{ container_name }} App
        {{ container_name }}-http.http.name: {{ container_name }} Internal
        {{ container_name }}-http.http.parent_name: {{ container_name }}
        {{ container_name }}-http.http.url: http://{{ container_name }}:{{ args.port }}{{ path }}
        {% if args.status_code %}
          {{ container_name }}-http.http.status_code: {{ args.status_code }}
        {% endif %}
        {{ container_name }}-docker.docker.name: {{ container_name }} Docker
        {{ container_name }}-docker.docker.parent_name: {{ container_name }}
        {{ container_name }}-docker.docker.docker_container: {{ container_name }}
        {{ container_name }}-docker.docker.docker_host: 1
        {{ container_name }}-https.http.name: {{ container_name }} Web
        {{ container_name }}-https.http.parent_name: {{ container_name }}
        {{ container_name }}-https.http.url: https://{{ container_name }}.<x>.<y>{{ path }}
        {% if args.status_code %}
          {{ container_name }}-https.http.status_code: {{ args.status_code }}
        {% endif %}

btw, I absolutely love autokuma! It's helped me really shore up 50+ homelab containers while I migrated everything to a template with container-oriented definitions.