{
  pkgs,
  config,
  ...
}:
{
  services = {
    loki = {
      enable = true;
      configuration = {
        auth_enabled = false;
        server.http_listen_port = 3100;

        common = {
          ring.kvstore.store = "inmemory";
          ring.instance_addr = "127.0.0.1";
          replication_factor = 1;
        };

        storage_config = {
          filesystem.directory = "/var/lib/loki/chunks";
          tsdb_shipper = {
            active_index_directory = "tsdb_active_index";
            cache_location = "tsdb_cache";
          };
        };

        compactor = {
          working_directory = "/var/lib/loki/compactor";
          compaction_interval = "10m";
          retention_enabled = true;
          retention_delete_delay = "1s";
          retention_delete_worker_count = 150;
          delete_request_store = "filesystem";
        };

        limits_config.retention_period = "1y";

        schema_config = {
          configs = [
            {
              from = "2025-03-01";
              store = "tsdb";
              object_store = "filesystem";
              schema = "v13";
              index = {
                prefix = "index_";
                period = "24h";
              };
            }
          ];
        };
      };
    };

    nginx = {
      upstreams.loki = {
        servers."127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}" = { };
        extraConfig = "keepalive 20;";
      };

      virtualHosts."loki.noc.eh22.intern" = {
        locations."/loki/api/v1/push" = {
          proxyPass = "http://loki";
          basicAuthFile = config.sops.secrets."services/loki/nginx".path;
        };
      };
    };
  };
}