From 39b9726be72f17f4d58a6fe9c7f1bf666608093f Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Sat, 31 May 2025 19:30:04 +0200 Subject: [PATCH] feat: add Loki datasource configuration for Grafana --- .../modules/grafana/datasources/loki.nix | 17 +++++++++++++++++ hosts/web-arm/modules/grafana/default.nix | 1 + 2 files changed, 18 insertions(+) create mode 100644 hosts/web-arm/modules/grafana/datasources/loki.nix diff --git a/hosts/web-arm/modules/grafana/datasources/loki.nix b/hosts/web-arm/modules/grafana/datasources/loki.nix new file mode 100644 index 0000000..efd3804 --- /dev/null +++ b/hosts/web-arm/modules/grafana/datasources/loki.nix @@ -0,0 +1,17 @@ +{ lib, pkgs, config, ... }: +{ + services.grafana.provision.datasources.settings.datasources = [ + { + name = "Loki"; + uid = "loki-datasource-uid"; # Stable UID + type = "loki"; + url = "http://localhost:3100"; # Loki's local address + access = "proxy"; # Grafana proxies requests + isDefault = false; # Can be set to true if desired + jsonData = { + # Loki-specific options (e.g., derivedFields) can go here + }; + editable = false; # Recommended for provisioned datasources + } + ]; +} \ No newline at end of file diff --git a/hosts/web-arm/modules/grafana/default.nix b/hosts/web-arm/modules/grafana/default.nix index 03eb58f..54787e7 100644 --- a/hosts/web-arm/modules/grafana/default.nix +++ b/hosts/web-arm/modules/grafana/default.nix @@ -38,6 +38,7 @@ in ./alerting/service/default.nix # Added: Imports the new service alerts module # ... other rule files can be added here ... ./datasources/victoriametrics.nix + ./datasources/loki.nix # Add Loki datasource ]; systemd.services.grafana.script = lib.mkBefore ''