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

Format for multiple tags for a static monitor? #51

Closed zodac closed 5 months ago

zodac commented 5 months ago

I am trying to add a static monitor and specify multiple tags. I can get it working fine with a single tag:

name = "Site"
url = "my.url"
type = "http"
tags = '[{"tag_id": 1 }]'

However, when I try and use 2 tags, I get the following error:

name = "Site"
url = "my.url"
type = "http"
tags = [{"tag_id" = 1},{"tag_id" = 2}]

WARN [autokuma::sync] Encountered error during sync: Error while trying to parse labels: expected : at line 1 column 27

I tried with JSON too, and got a different bad syntax error:

{
  "name": "Site",
  "type": "http",
  "url": "my.url",
  "tags": [
    {
      "tag_id": 1
    },
    {
      "tag_id": 2
    }
  ]
}

This gave the error:

WARN [autokuma::sync] Encountered error during sync: Error while trying to parse labels: TOML parse error at line 8, column 18 | 8 | tags = [{"tag_id":1},{"tag_id":2}] | ^ expected ., =

Apologies if I missed an example, I wasn't able to find one in the docs or previous issues.

BigBoot commented 5 months ago

Hi, due to autokuma normally getting it's values from docker labels nested arrays need to be passed as a string and formatted as json. So this should work:

Toml:

name = "Site"
url = "my.url"
type = "http"
tags = '[{"tag_id": 1},{"tag_id": 2}]'

Json:

{
  "name": "Site",
  "type": "http",
  "url": "my.url",
  "tags":  "[{\"tag_id\": 1},{\"tag_id\": 2}]"
}
zodac commented 5 months ago

Thanks, that did the job! :)