diff --git a/imageroot/actions/configure-module/20configure b/imageroot/actions/configure-module/20configure index 4b747ba..3c5df70 100755 --- a/imageroot/actions/configure-module/20configure +++ b/imageroot/actions/configure-module/20configure @@ -77,6 +77,13 @@ with open('grafana.env', 'w') as gfp: with open('prometheus.env', 'w') as pfp: pass +with open('prometheus-config.yml', 'w', encoding='utf-8') as fp: + fp.write("global:\n") + fp.write("scrape_configs:\n") + fp.write(' - job_name: "units"\n') + fp.write(' file_sd_configs:\n') + fp.write(' - files:\n') + fp.write(' - "/prometheus/prometheus.d/*.yml"\n') network = agent.read_envfile('network.env') tun = network.get('OVPN_TUN') diff --git a/imageroot/systemd/user/loki.service b/imageroot/systemd/user/loki.service index 3c45b9d..2e05ef5 100644 --- a/imageroot/systemd/user/loki.service +++ b/imageroot/systemd/user/loki.service @@ -1,7 +1,7 @@ [Unit] Description=Podman loki.service BindsTo=controller.service -ABefore=promtail.service +Before=promtail.service [Service] Environment=PODMAN_SYSTEMD_UNIT=%n diff --git a/imageroot/systemd/user/prometheus.service b/imageroot/systemd/user/prometheus.service index 2f8b12e..82c0e59 100644 --- a/imageroot/systemd/user/prometheus.service +++ b/imageroot/systemd/user/prometheus.service @@ -6,26 +6,29 @@ After=vpn.service [Service] Environment=PODMAN_SYSTEMD_UNIT=%n EnvironmentFile=%S/state/environment +WorkingDirectory=%S/state Restart=always TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/prometheus.pid %t/prometheus.ctr-id +ExecStartPre=/usr/bin/mkdir -vp %S/state/prometheus.d ExecStart=/usr/bin/podman run \ --conmon-pidfile %t/prometheus.pid \ --cidfile %t/prometheus.ctr-id \ --cgroups=no-conmon \ --pod-id-file %t/controller.pod-id \ --replace -d --name prometheus \ - --volume %S/etc/prometheus-config.yml:/etc/prometheus/prometheus.yml:z \ - -v prometheus-data:/prometheus \ + --volume=%S/state/prometheus.yml:/prometheus/prometheus.yml:z \ + --volume=./prometheus.d/:/prometheus/prometheus.d/:z \ + --volume=prometheus-data:/prometheus:z \ --network=host \ --env-file=%S/state/prometheus.env \ --env-file=%S/state/config.env \ - ${prometheus_IMAGE} \ - -config.expand-env=true -config.file=/etc/prometheus/config.yml + ${PROMETHEUS_IMAGE} \ + -config.file=/etc/prometheus/prometheus.yml ExecStop=/usr/bin/podman stop --ignore --cidfile %t/prometheus.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/prometheus.ctr-id PIDFile=%t/prometheus.pid Type=forking [Install] -WantedBy=default.target +WantedBy=default.target \ No newline at end of file