From a2f71ba12064f2ee530fb789e4bb6525e3ae0300 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Tue, 20 Dec 2022 00:26:29 +0100 Subject: [PATCH] ildkule-grafana upgrades --- hosts/ildkule/configuration.nix | 2 ++ hosts/ildkule/services/metrics/grafana.nix | 16 ++++++++++++---- hosts/ildkule/services/metrics/prometheus.nix | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hosts/ildkule/configuration.nix b/hosts/ildkule/configuration.nix index 0febbae..cb9dd7d 100644 --- a/hosts/ildkule/configuration.nix +++ b/hosts/ildkule/configuration.nix @@ -8,6 +8,8 @@ ../../misc/rust-motd.nix ../../misc/metrics-exporters.nix # Users can just import any configuration they want even for non-user things. Improve the users/default.nix to just load some specific attributes if this isn't wanted + + ./services/nginx ./services/metrics ]; diff --git a/hosts/ildkule/services/metrics/grafana.nix b/hosts/ildkule/services/metrics/grafana.nix index 5adacc3..78e1b00 100644 --- a/hosts/ildkule/services/metrics/grafana.nix +++ b/hosts/ildkule/services/metrics/grafana.nix @@ -8,20 +8,28 @@ http_port = 2342; http_addr = "127.0.0.1"; }; + provision = { + enable = true; + datasources.settings.datasources = [ + { + name = "Ildkule Prometheus"; + type = "prometheus"; + url = ("http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}"); + isDefault = true; + } + ]; + }; }; services.nginx.virtualHosts.${config.services.grafana.domain} = { locations = { "/" = { - proxyPass = "http://${config.services.grafana.addr}:${toString config.services.grafana.port}"; + proxyPass = "http://${config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}"; proxyWebsockets = true; extraConfig = '' proxy_buffers 8 1024k; proxy_buffer_size 1024k; proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; ''; }; }; diff --git a/hosts/ildkule/services/metrics/prometheus.nix b/hosts/ildkule/services/metrics/prometheus.nix index 375a3f3..3ea124a 100644 --- a/hosts/ildkule/services/metrics/prometheus.nix +++ b/hosts/ildkule/services/metrics/prometheus.nix @@ -3,6 +3,7 @@ { services.prometheus = { enable = true; + listenAddress = "127.0.0.1"; port = 9001; scrapeConfigs = [