about summary refs log tree commit diff
path: root/bundles/prometheus/items.py
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2026-02-23 14:19:55 +0100
committerRobert Günzler <r@gnzler.io>2026-02-23 14:19:55 +0100
commitc9197b9bfd5cd3ab49ee7dfdc81d207715ccd5d8 (patch)
treece772751fa5fbde24b69f8de95280fe0b01a5b6a /bundles/prometheus/items.py
parent98470f7be2244d2c40c0bd547eeef5b3bde2e858 (diff)
prometheus: modernize console + alerts
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bundles/prometheus/items.py')
-rw-r--r--bundles/prometheus/items.py40
1 files changed, 33 insertions, 7 deletions
diff --git a/bundles/prometheus/items.py b/bundles/prometheus/items.py
index 234aca5..99aecbc 100644
--- a/bundles/prometheus/items.py
+++ b/bundles/prometheus/items.py
@@ -1,16 +1,34 @@
 from sys import exit
 from os.path import join
 
+actions = {
+    "reload_prometheus": {
+        "command": "podman kill -s HUP prometheus-prom",
+        "triggered": True,
+    },
+    "reload_alertmanager": {
+        "command": "podman kill -s HUP prometheus-alert",
+        "triggered": True,
+    },
+}
+
 files = {
     "/etc/deployments/prometheus/kube.yaml": {
-        "content_type": "text",
-        "source": "kube.yaml",
+        "content_type": "mako",
+        "context": node.metadata.get("containers")["prometheus"],
         "triggers": {"svc_s6rc:prometheus:restart"},
     },
     "/etc/prometheus/prometheus.yml": {
         "content_type": "text",
-        "source": "prometheus.yml",
-        "triggers": {"svc_s6rc:prometheus:restart"},
+        "triggers": {"action:reload_prometheus"},
+    },
+    "/etc/prometheus/rules/generic.yml": {
+        "source": "rules.yml",
+        "triggers": {"action:reload_prometheus"},
+    },
+    "/etc/prometheus/alertmanager.yml": {
+        "content_type": "mako",
+        "triggers": {"action:reload_alertmanager"},
     },
 }
 
@@ -26,11 +44,19 @@ repo.libs.gen.add_files_recursive(
     target_root="/etc/prometheus",
     files_root=join(repo.path, "bundles", "prometheus", "files"),
 )
+repo.libs.gen.add_files_recursive(
+    files,
+    join(repo.path, "bundles", "prometheus", "files", "console_assets"),
+    target_root="/etc/prometheus",
+    files_root=join(repo.path, "bundles", "prometheus", "files"),
+)
 
 directories = {
-        "/etc/prometheus/services": {},
-        "/etc/prometheus/consoles": {},
-        "/etc/prometheus/console_libraries": {},
+    "/etc/prometheus/services": {"purge": True},
+    "/etc/prometheus/rules": {"purge": True},
+    "/etc/prometheus/consoles": {"purge": True},
+    "/etc/prometheus/console_libraries": {"purge": True},
+    "/etc/prometheus/console_assets": {"purge": True},
 }
 
 # NOTE: services that want to have their metrics scraped need to expose them