From a437a923d8b28a24ec58339ceec4a66be39ab717 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sun, 21 Jul 2024 14:19:08 +0530 Subject: [PATCH] rico0: enable loki --- hosts/rico0/services/apps/blocky.nix | 1 + hosts/rico0/services/apps/default.nix | 1 + hosts/rico0/services/apps/loki.nix | 65 +++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 hosts/rico0/services/apps/loki.nix diff --git a/hosts/rico0/services/apps/blocky.nix b/hosts/rico0/services/apps/blocky.nix index 0817500..e1f5c3c 100644 --- a/hosts/rico0/services/apps/blocky.nix +++ b/hosts/rico0/services/apps/blocky.nix @@ -61,6 +61,7 @@ _: { "blocky.labs.adtya.xyz" = "10.10.10.10,fd7c:585c:c4ae::10"; "frp.labs.adtya.xyz" = "10.10.10.10,fd7c:585c:c4ae::10"; "grafana.labs.adtya.xyz" = "10.10.10.10,fd7c:585c:c4ae::10"; + "loki.labs.adtya.xyz" = "10.10.10.10,fd7c:585c:c4ae::10"; "prometheus.labs.adtya.xyz" = "10.10.10.10,fd7c:585c:c4ae::10"; "transmission.labs.adtya.xyz" = "10.10.10.14,fd7c:585c:c4ae::14"; }; diff --git a/hosts/rico0/services/apps/default.nix b/hosts/rico0/services/apps/default.nix index 1c8742e..3ed5072 100644 --- a/hosts/rico0/services/apps/default.nix +++ b/hosts/rico0/services/apps/default.nix @@ -3,6 +3,7 @@ _: { ./alertmanager.nix ./blocky.nix ./grafana.nix + ./loki.nix ./prometheus.nix ../../../shared/prometheus-exporters.nix ]; diff --git a/hosts/rico0/services/apps/loki.nix b/hosts/rico0/services/apps/loki.nix new file mode 100644 index 0000000..4acc028 --- /dev/null +++ b/hosts/rico0/services/apps/loki.nix @@ -0,0 +1,65 @@ +_: { + services = { + caddy = { + virtualHosts."loki.labs.adtya.xyz" = { + extraConfig = '' + reverse_proxy 127.0.0.1:3100 + tls /persist/secrets/caddy/certs/default.crt /persist/secrets/caddy/certs/default.key + ''; + }; + }; + loki = { + enable = true; + dataDir = "/mnt/data/loki"; + configuration = { + auth_enabled = false; + + server = { + http_listen_port = 3100; + log_level = "warn"; + }; + + common = { + ring = { + instance_addr = "127.0.0.1"; + kvstore = { + store = "inmemory"; + }; + }; + storage = { + filesystem = { rules_directory = "/mnt/data/loki/rules"; }; + }; + replication_factor = 1; + path_prefix = "/mnt/data/loki"; + }; + + schema_config = { + configs = [ + { + from = "2024-07-01"; + store = "tsdb"; + object_store = "filesystem"; + scheme = "v13"; + index = { prefix = "index_"; period = "24h"; }; + } + ]; + }; + + storage_config = { + filesystem = { + directory = "/mnt/data/loki/chunks"; + }; + }; + + ruler = { + alertmanager_url = "https://alertmanager.labs.adtya.xyz"; + }; + + frontend = { + encoding = "protobuf"; + }; + }; + }; + }; + systemd.services.loki.unitConfig.RequiresMountsFor = [ "/mnt/data" ]; +}