From 9f6d63cabee1743f034d64da18e78c1dd6131dd5 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 16 May 2024 09:49:22 +0200 Subject: [PATCH] automatic configure prometheus --- nixos/machines/chungus/telemetry/loki.nix | 32 +++++++++---------- .../machines/chungus/telemetry/prometheus.nix | 13 ++++++++ 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/nixos/machines/chungus/telemetry/loki.nix b/nixos/machines/chungus/telemetry/loki.nix index ca8b131..9890343 100644 --- a/nixos/machines/chungus/telemetry/loki.nix +++ b/nixos/machines/chungus/telemetry/loki.nix @@ -1,9 +1,13 @@ { config, pkgs, ... }: { + + + + services.opentelemetry-collector.settings = { exporters.loki = { - endpoint = "http://127.0.0.1:3100/loki/api/v1/push"; + endpoint = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push"; default_labels_enabled = { exporter = true; job = true; @@ -109,20 +113,16 @@ # user, group, dataDir, extraFlags, (configFile) }; - #services.nginx = { - # enable = true; - # virtualHosts.loki = { - # serverName = "loki.pepe.private"; - # locations."/" = { - # proxyWebsockets = true; - # proxyPass = "http://127.0.0.1:3100"; - # #extraConfig = '' - # # access_log off; - # # allow ${config.tinc.private.subnet}; - # # deny all; - # #''; - # }; - # }; - #}; + services.grafana.provision.datasources.settings = { + apiVersion = 1; + datasources = [ + { + name = "Loki"; + type = "loki"; + uid = "loki01"; + url = "http://localhost:${toString config.services.loki.configuration.server.http_listen_port}"; + } + ]; + }; } diff --git a/nixos/machines/chungus/telemetry/prometheus.nix b/nixos/machines/chungus/telemetry/prometheus.nix index 2e74728..14aea33 100644 --- a/nixos/machines/chungus/telemetry/prometheus.nix +++ b/nixos/machines/chungus/telemetry/prometheus.nix @@ -20,4 +20,17 @@ # keep data for 30 days extraFlags = [ "--storage.tsdb.retention.time=90d" ]; }; + + services.grafana.provision.datasources.settings = { + apiVersion = 1; + datasources = [ + { + name = "Prometheus"; + type = "prometheus"; + uid = "prometheus01"; + url = "http://localhost:${toString config.services.prometheus.port}"; + } + ]; + }; + }