From 38be6c13f76e893cf47636257071b440dec0c5b2 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Sun, 7 Sep 2025 17:32:13 +0200 Subject: initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- bundles/prometheus/items.py | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 bundles/prometheus/items.py (limited to 'bundles/prometheus/items.py') diff --git a/bundles/prometheus/items.py b/bundles/prometheus/items.py new file mode 100644 index 0000000..234aca5 --- /dev/null +++ b/bundles/prometheus/items.py @@ -0,0 +1,47 @@ +from sys import exit +from os.path import join + +files = { + "/etc/deployments/prometheus/kube.yaml": { + "content_type": "text", + "source": "kube.yaml", + "triggers": {"svc_s6rc:prometheus:restart"}, + }, + "/etc/prometheus/prometheus.yml": { + "content_type": "text", + "source": "prometheus.yml", + "triggers": {"svc_s6rc:prometheus:restart"}, + }, +} + +repo.libs.gen.add_files_recursive( + files, + join(repo.path, "bundles", "prometheus", "files", "consoles"), + 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_libraries"), + target_root="/etc/prometheus", + files_root=join(repo.path, "bundles", "prometheus", "files"), +) + +directories = { + "/etc/prometheus/services": {}, + "/etc/prometheus/consoles": {}, + "/etc/prometheus/console_libraries": {}, +} + +# NOTE: services that want to have their metrics scraped need to expose them +# under traefik:4000/metrics/ and set metadata.metrics. +for node in repo.nodes: + for job_name, _ in node.metadata.get("metrics", {}).items(): + files[f"/etc/prometheus/services/{node.hostname}.{job_name}.json"] = { + "content_type": "mako", + "source": "service.json", + "context": { + "job_name": job_name, + "hostname": node.hostname, + }, + } -- cgit 1.4.1