about summary refs log tree commit diff
path: root/modules/nixos/loki.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-04-21 02:15:42 +0300
committerAzat Bahawi <azat@bahawi.net>2024-04-21 02:15:42 +0300
commite6ed60548397627bf10f561f9438201dbba0a36e (patch)
treef9a84c5957d2cc4fcd148065ee9365a0c851ae1c /modules/nixos/loki.nix
parent2024-04-18 (diff)
2024-04-21
Diffstat (limited to 'modules/nixos/loki.nix')
-rw-r--r--modules/nixos/loki.nix124
1 files changed, 0 insertions, 124 deletions
diff --git a/modules/nixos/loki.nix b/modules/nixos/loki.nix
deleted file mode 100644
index c446848..0000000
--- a/modules/nixos/loki.nix
+++ /dev/null
@@ -1,124 +0,0 @@
-{
-  config,
-  lib,
-  libNginx,
-  ...
-}:
-with lib;
-let
-  cfg = config.nixfiles.modules.loki;
-in
-{
-  options.nixfiles.modules.loki = {
-    enable = mkEnableOption "Loki";
-
-    port = mkOption {
-      description = "Port.";
-      type = with types; port;
-      default = 30171;
-    };
-
-    domain = mkOption {
-      description = "Domain name sans protocol scheme.";
-      type = with types; str;
-      default = "loki.${config.networking.domain}";
-    };
-  };
-
-  config = mkIf cfg.enable {
-    ark.directories = [ config.services.loki.configuration.common.path_prefix ];
-
-    nixfiles.modules.nginx = with cfg; {
-      enable = true;
-      upstreams.loki.servers."127.0.0.1:${toString cfg.port}" = { };
-      virtualHosts.${domain} = {
-        locations."/".proxyPass = "http://loki";
-        extraConfig = libNginx.config.internalOnly;
-      };
-    };
-
-    services.loki = {
-      enable = true;
-
-      configuration = rec {
-        auth_enabled = false;
-
-        server = {
-          http_listen_address = "127.0.0.1";
-          http_listen_port = cfg.port;
-
-          grpc_listen_address = "127.0.0.1";
-          grpc_listen_port = server.http_listen_port + 1;
-
-          log_level = "warn";
-        };
-
-        common = {
-          path_prefix = config.services.loki.dataDir;
-          storage.filesystem = {
-            chunks_directory = "${common.path_prefix}/chunks";
-            rules_directory = "${common.path_prefix}/rules";
-          };
-          replication_factor = 1;
-          ring = {
-            instance_addr = "127.0.0.1";
-            kvstore.store = "inmemory";
-          };
-        };
-
-        ingester = {
-          chunk_idle_period = "15m";
-          max_chunk_age = "15m";
-        };
-
-        compactor = {
-          working_directory = "${common.path_prefix}/compactor";
-          retention_enabled = true;
-          retention_delete_delay = "1h";
-          retention_delete_worker_count = 64;
-        };
-
-        ruler = {
-          enable_api = true;
-          storage = {
-            type = "local";
-            local.directory = common.storage.filesystem.rules_directory;
-          };
-        };
-
-        limits_config = {
-          max_streams_per_user = 0;
-          max_global_streams_per_user = 0;
-          max_query_series = 4096;
-          retention_period = "720h";
-          deletion_mode = "filter-and-delete";
-        };
-
-        schema_config.configs = [
-          {
-            from = "2024-01-01";
-            store = "tsdb";
-            object_store = "filesystem";
-            schema = "v12";
-            index = {
-              prefix = "index_";
-              period = "24h";
-            };
-            chunks = {
-              prefix = "chunks_";
-              period = "24h";
-            };
-          }
-        ];
-
-        analytics.reporting_enabled = false;
-      };
-    };
-
-    systemd.tmpfiles.rules = with config.services.loki.configuration.common; [
-      "d ${path_prefix} 0700 loki loki - -"
-      "d ${storage.filesystem.chunks_directory} 0700 loki loki - -"
-      "d ${storage.filesystem.rules_directory} 0700 loki loki - -"
-    ];
-  };
-}

Consider giving Nix/NixOS a try! <3