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

Static Configuration using groups, tags, and monitors in different files does not create monitors #94

Closed instantdreams closed 2 weeks ago

instantdreams commented 2 weeks ago

Issue: Unable to create monitors

Starting with a fresh installation of uptime-kuma using a username and password, I am attempting to create an AutoKuma configuration using static configuration files only. I have split my static configuration into separate files, which I don't think is causing the issue.

Uptime Kuma version: louislam/uptime-kuma:latest v1.23.15 AutoKuma version: ghcr.io/bigboot/autokuma:master v0.8.0-132419e5

AutoKuma docker compose log

``` autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/09-edge2.json] No monitor named edge2 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/09-edge2.json] No monitor named edge2 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/09-edge2.json] No monitor named edge2 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/09-edge2.json] No monitor named edge2 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/09-edge2.json] No monitor named edge2 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/09-edge2.json] No monitor named edge2 could be found autokuma | INFO [autokuma::sync] Creating new Monitor: static-monitors/01-groups[2] autokuma | INFO [autokuma::sync] Creating new Monitor: static-monitors/01-groups[0] autokuma | INFO [autokuma::sync] Creating new Monitor: static-monitors/01-groups[4] autokuma | INFO [autokuma::sync] Creating new Tag: static-monitors/03-tags[1] autokuma | INFO [autokuma::sync] Creating new Tag: static-monitors/03-tags[0] autokuma | INFO [autokuma::sync] Creating new Tag: static-monitors/03-tags[2] autokuma | INFO [autokuma::sync] Creating new Tag: static-monitors/03-tags[7] autokuma | INFO [autokuma::sync] Creating new Tag: static-monitors/03-tags[4] autokuma | INFO [autokuma::sync] Creating new Tag: static-monitors/03-tags[5] autokuma | INFO [autokuma::sync] Creating new Monitor: static-monitors/01-groups[1] autokuma | INFO [autokuma::sync] Creating new Monitor: static-monitors/01-groups[3] autokuma | INFO [autokuma::sync] Creating new Tag: static-monitors/03-tags[3] autokuma | INFO [autokuma::sync] Creating new Tag: static-monitors/03-tags[6] autokuma | INFO [autokuma::sync] Creating new Notification: static-monitors/05-notification autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | WARN [kuma_client::util] [/autokuma/static-monitors/07-edge1.json] No monitor named edge1 could be found autokuma | INFO [autokuma::sync] Updating Notification: static-monitors/05-notification ```

AutoKuma compose.yaml content

``` services: autokuma: image: ghcr.io/bigboot/autokuma:master container_name: ${CONTAINER_NAME1} hostname: ${HOSTNAME1} domainname: ${DOMAINNAME} environment: - AUTOKUMA__DOCKER__ENABLED=${AUTOKUMA__DOCKER__ENABLED} - AUTOKUMA__STATIC_MONITORS=${AUTOKUMA__STATIC_MONITORS} - AUTOKUMA__TAG_NAME=${AUTOKUMA__TAG_NAME} - AUTOKUMA__TAG_COLOR=${AUTOKUMA__TAG_COLOR} - AUTOKUMA__LOG_DIR=${AUTOKUMA__LOG_DIR} - AUTOKUMA__ON_DELETE=${AUTOKUMA__ON_DELETE} - AUTOKUMA__KUMA__URL=${AUTOKUMA__KUMA__URL} - AUTOKUMA__KUMA__USERNAME=${AUTOKUMA__KUMA__USERNAME} - AUTOKUMA__KUMA__PASSWORD=${AUTOKUMA__KUMA__PASSWORD} - AUTOKUMA__KUMA__CALL_TIMEOUT=${AUTOKUMA__KUMA__CALL_TIMEOUT} - AUTOKUMA__KUMA__CONNECT_TIMEOUT=${AUTOKUMA__KUMA__CONNECT_TIMEOUT} # - RUST_LOG=kuma_client=trace # - RUST_BACKTRACE=1 volumes: - ${DIRECTORY_DATA}:/data - ${DIRECTORY_STATIC}:/autokuma/static-monitors - ${DIRECTORY_LOGS}:/autokuma/logs - /etc/timezone:/etc/timezone:ro restart: unless-stopped ```

AutoKuma .env.example content

``` # Host specifics CONTAINER_NAME1=autokuma CONTAINER_PORT1= HOSTNAME1=autokuma DOMAINNAME=example.com # Directory locations DIRECTORY_DATA=/srv/autokuma/data DIRECTORY_STATIC=/srv/autokuma/config DIRECTORY_LOGS=/srv/autokuma/logs # Container specifics AUTOKUMA__DOCKER__ENABLED=false AUTOKUMA__STATIC_MONITORS=/autokuma/static-monitors AUTOKUMA__TAG_NAME=AutoKuma AUTOKUMA__TAG_COLOR="#42C0FB" AUTOKUMA__LOG_DIR=/autokuma/logs AUTOKUMA__ON_DELETE=keep AUTOKUMA__KUMA__URL=http://192.168.1.93:3002 AUTOKUMA__KUMA__USERNAME=admin AUTOKUMA__KUMA__PASSWORD=[password] AUTOKUMA__KUMA__CALL_TIMEOUT=15 AUTOKUMA__KUMA__CONNECT_TIMEOUT=30 ```

AutoKuma config/01-groups.json content

``` [ { "type": "group", "name": "edge1", "description": "All monitors for server edge1" }, { "type": "group", "name": "edge2", "description": "All monitors for server edge2" }, { "type": "group", "name": "services", "description": "All monitors for server services" }, { "type": "group", "name": "security", "description": "All monitors for server security" }, { "type": "group", "name": "media", "description": "All monitors for server media" } ] ```

AutoKuma config/03-tags.json content

``` [ { "name": "external", "color": "#e28743", "type": "tag" }, { "name": "internal", "color": "#de2348", "type": "tag" }, { "name": "reverse-proxy", "color": "#26aa38", "type": "tag" }, { "name": "local", "color": "#86B09A", "type": "tag" }, { "name": "azure", "color": "#007fff", "type": "tag" }, { "name": "direct", "color": "#FF00FF", "type": "tag" }, { "name": "dns", "color": "#FF00FF", "type": "tag" }, { "name": "network", "color": "#800080", "type": "tag" } ] ```

AutoKuma config/05-notification.json content

``` { "type": "notification", "name": "Instant Dreams Telegram", "active": true, "isDefault": true, "userId": 1, "config": { "applyExisting": true, "isDefault": true, "name": "Instant Dreams Telegram", "telegramBotToken": "[token]", "telegramChatID": -1001969298385, "telegramThreadId": 6 } } ```

AutoKuma config/07-edge1.json content

``` [ { "name": "edge1.node-exporter-1", "parent_name": "edge1", "type": "http", "url": "http://192.168.1.91:9100", "tag_names": [ { "name": "direct", "value": "" }, { "name": "internal", "value": "" } ], "notification_names": [ { "name": "Instant Dreams Telegram" } ] }, { "name": "edge1.pihole-1", "parent_name": "edge1", "type": "http", "url": "http://192.168.1.91:8080/admin", "tag_names": [ { "name": "direct", "value": "" }, { "name": "internal", "value": "" } ] }, { "name": "edge1.promtail-1", "parent_name": "edge1", "type": "http", "url": "http://192.168.1.91:9080/metrics", "tag_names": [ { "name": "direct", "value": "" }, { "name": "internal", "value": "" } ] }, { "name": "edge1.traefik", "parent_name": "edge1", "type": "http", "url": "http://192.168.1.91:8888", "tag_names": [ { "name": "direct", "value": "" }, { "name": "internal", "value": "" } ] }, { "name": "edge1.traefik-metrics", "parent_name": "edge1", "type": "http", "url": "http://192.168.1.91:8082/metrics", "tag_names": [ { "name": "direct", "value": "" }, { "name": "internal", "value": "" } ] }, { "name": "edge1.pihole-1.dns", "parent_name": "edge1", "type": "dns", "dns_resolve_server": "192.168.1.1", "dns_resolve_type": "A", "hostname": "pihole-1.example.com", "port": "53", "interval": "240", "max_retries": "3", "retry_interval": "240", "tag_names": [ { "name": "dns", "value": "" }, { "name": "internal", "value": "" } ] } ] ```

Uptime-Kuma status:

The error message indicates the parent group edge could not be found. I've tried this with the following references:

What am I missing here? Do the groups and the monitors have to be in the same file, as in multi_example.json? How do I get the autokuma id of the parent group?

BigBoot commented 2 weeks ago

Hi, there's currently an issue regarding the file provider not correctly stripping the base path: #93 So this causes your ids to end up as e.g.: static-monitors/01-groups[0]. Note that this is a bug and will be fixed in the future, so if you end up using these id's you'll need to change them back once it's fixed.

instantdreams commented 2 weeks ago

Thank you, that worked!

I changed:

I now have an issue with tags where the following are created:

But the http and dns monitors could not be created as the tags could not be found:

autokuma  |                                                        v0.8.0-132419e5
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[1]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[2]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[3]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[6]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[1]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[7]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[0]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[3]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[0]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[5]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[4]
autokuma  | INFO [autokuma::sync] Creating new Notification: static/05-notification
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[2]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[4]
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No tag named dns could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No tag named direct could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No tag named dns could be found
autokuma  | INFO [autokuma::sync] Updating Notification: static/05-notification

Should these also be static/03-tags[0-7] ?

instantdreams commented 2 weeks ago

I answered my own question - yes, they should. :)

autokuma  |                                                        v0.8.0-132419e5
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/07-edge1.json] No monitor named static/01-groups[0] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | WARN [kuma_client::util] [/autokuma/static/09-edge2.json] No monitor named static/01-groups[1] could be found
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[0]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[3]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[5]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[6]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[4]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[7]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[1]
autokuma  | INFO [autokuma::sync] Creating new Notification: static/05-notification
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[3]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/01-groups[2]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[0]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[2]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[4]
autokuma  | INFO [autokuma::sync] Creating new Tag: static/03-tags[1]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/07-edge1[4]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/07-edge1[2]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/09-edge2[1]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/09-edge2[3]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/07-edge1[0]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/07-edge1[1]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/07-edge1[5]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/09-edge2[0]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/09-edge2[2]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/07-edge1[3]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/09-edge2[4]
autokuma  | INFO [autokuma::sync] Creating new Monitor: static/09-edge2[5]

I'll continue to work on turning my ClickOps configuration into a GitOps configuration and monitoring the fixes on AutoKuma. Fantastic work so far.

instantdreams commented 2 weeks ago

I am aware of the issue with the folder name needing to be part of the reference. I will monitor the releases for when this is fixed and adjust my configuration.