Skip to content
Snippets Groups Projects
loki.nix 1.69 KiB
Newer Older
# Scope: Log ingester and aggregator to be run on the monitoring node
#
# See also:
#   - The configuration is adapted from
#     https://grafana.com/docs/loki/latest/configuration/examples/#complete-local-configyaml
#
  config.networking.firewall.interfaces.monitoringvpn.allowedTCPPorts = [ 3100 9095 ];

  config.services.loki = {
    enable = true;

    configuration =
      {
        auth_enabled = false;

        server = {
          http_listen_port = 3100;
          grpc_listen_port = 9095;
            interface_names = [ "monitoringvpn"];
            ring = {
              kvstore = {
                store = "inmemory";
              };
              replication_factor = 1;
            };
          final_sleep = "0s";
          chunk_target_size = 1536000; # As per https://grafana.com/docs/loki/v2.2.1/best-practices/
          max_transfer_retries = 0; # Chunk transfers disabled
        };

        schema_config = {
          configs = [{
            from = "2020-12-26";
            store = "boltdb";
            object_store = "filesystem";
            schema = "v11";
            index = {
              prefix = "index_";
            };
          }];
        };

        storage_config = {
          boltdb = {
            directory = "/var/lib/loki/index";
          filesystem = {
            directory = "/var/lib/loki/chunks";
          };
        };

        chunk_store_config = {
          max_look_back_period = "336h"; # two weeks
        };

        table_manager = {
          retention_deletes_enabled = true;
          retention_period = "336h"; # two weeks