From 7fe99b62a3a71b51cfe2945302986f9084d5dda4 Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Wed, 14 Jun 2023 16:41:23 +0200 Subject: [PATCH 1/3] Read loki config file from redis --- imageroot/bin/provision | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/imageroot/bin/provision b/imageroot/bin/provision index 3c7d278..f37e55e 100755 --- a/imageroot/bin/provision +++ b/imageroot/bin/provision @@ -28,8 +28,10 @@ rdb = agent.redis_connect() default_instance = rdb.get(f'node/{os.environ["NODE_ID"]}/default_instance/prometheus') or "prometheus1" node_path = rdb.hget(f'module/{default_instance}/environment', 'PROMETHEUS_PATH') or "/prometheus" -# Read loki config from local node -logcli = agent.read_envfile("/etc/nethserver/logcli.env") +# Read loki config from Redis +loki = agent.resolve_agent_id("loki@cluster") +logcli = rdb.hgetall(f'{loki}/environment') +logcli["LOKI_ADDR"] = 'http://'+logcli["LOKI_ADDR"]+':'+logcli["LOKI_HTTP_PORT"] with open('local.yml', 'w') as fp: fp.write("apiVersion: 1\n") @@ -46,6 +48,6 @@ with open('local.yml', 'w') as fp: fp.write(' access: proxy\n') fp.write(f' url: {logcli["LOKI_ADDR"]}\n') fp.write(f' basicAuth: true\n') - fp.write(f' basicAuthUser: {logcli["LOKI_USERNAME"]}\n') + fp.write(f' basicAuthUser: {logcli["LOKI_API_AUTH_USERNAME"]}\n') fp.write(' secureJsonData:\n') - fp.write(f' basicAuthPassword: {logcli["LOKI_PASSWORD"]}\n') + fp.write(f' basicAuthPassword: {logcli["LOKI_API_AUTH_PASSWORD"]}\n') From d1ff37d02e68703328884f66801d81f620650360 Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Wed, 14 Jun 2023 16:41:48 +0200 Subject: [PATCH 2/3] Read prometheus default instance from redis --- imageroot/bin/provision | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imageroot/bin/provision b/imageroot/bin/provision index f37e55e..ebfa77f 100755 --- a/imageroot/bin/provision +++ b/imageroot/bin/provision @@ -24,9 +24,9 @@ import os import agent # Read prometheus config from local node -rdb = agent.redis_connect() -default_instance = rdb.get(f'node/{os.environ["NODE_ID"]}/default_instance/prometheus') or "prometheus1" -node_path = rdb.hget(f'module/{default_instance}/environment', 'PROMETHEUS_PATH') or "/prometheus" +rdb = agent.redis_connect(use_replica=True) +default_instance = agent.resolve_agent_id("prometheus@cluster") or "module/prometheus1" +node_path = rdb.hget(f'{default_instance}/environment', 'PROMETHEUS_PATH') or "/prometheus" # Read loki config from Redis loki = agent.resolve_agent_id("loki@cluster") From 6a274e7dd1055c33416b8082bd6001f9a60d0b7c Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Thu, 15 Jun 2023 15:45:26 +0200 Subject: [PATCH 3/3] Warnings about the default value of prometheus --- imageroot/bin/provision | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imageroot/bin/provision b/imageroot/bin/provision index ebfa77f..aec12a1 100755 --- a/imageroot/bin/provision +++ b/imageroot/bin/provision @@ -23,6 +23,11 @@ import os import agent +## +## we need to made a first discover with default value, +## probably prometheus will be instally later if not found yet +## + # Read prometheus config from local node rdb = agent.redis_connect(use_replica=True) default_instance = agent.resolve_agent_id("prometheus@cluster") or "module/prometheus1"