diff --git a/modules/monitoring.nix b/modules/monitoring.nix index a5e884a..853a5a8 100644 --- a/modules/monitoring.nix +++ b/modules/monitoring.nix @@ -81,6 +81,109 @@ in port = 3001; }; + services.loki = { + enable = true; + dataDir = "/var/lib/loki"; + configuration = { + auth_enabled = false; + + server.http_listen_port = 3002; + + ingester = { + lifecycler = { + address = "127.0.0.1"; + ring = { + kvstore.store = "inmemory"; + replication_factor = 1; + }; + final_sleep = "0s"; + }; + chunk_idle_period = "5m"; + chunk_retain_period = "30s"; + }; + + schema_config = { + configs = [ + { + from = "2018-04-15"; + store = "boltdb"; + object_store = "filesystem"; + schema = "v9"; + index.prefix = "index_"; + index.period = "168h"; + } + ]; + }; + + storage_config = { + boltdb.directory = "/tmp/loki/index"; + filesystem.directory = "/tmp/loki/chunks"; + }; + + limits_config = { + enforce_metric_name = false; + reject_old_samples = true; + reject_old_samples_max_age = "168h"; + }; + + chunk_store_config = { + max_look_back_period = 0; + }; + + table_manager = { + chunk_tables_provisioning = { + inactive_read_throughput = 0; + inactive_write_throughput = 0; + provisioned_read_throughput = 0; + provisioned_write_throughput = 0; + }; + index_tables_provisioning = { + inactive_read_throughput = 0; + inactive_write_throughput = 0; + provisioned_read_throughput = 0; + provisioned_write_throughput = 0; + }; + retention_deletes_enabled = false; + retention_period = 0; + }; + }; + }; + + services.promtail = { + enable = true; + configuration = { + server = { + http_listen_port = 9080; + grpc_listen_port = 0; + }; + + positions.filename = "/tmp/positions.yaml"; + + client.url = "http://localhost:${toString config.services.loki.configuration.server.http_listen_port}/api/prom/push"; + + scrape_configs = [ + { + job_name = "systemd"; + journal = { + json = false; + max_age = "12h"; + path = "/var/log/journal"; + # matches = "_TRANSPORT=kernel"; + labels = { + job = "systemd-journal"; + }; + }; + relabel_configs = [ + { + source_labels = [ "__journal__systemd_unit" ]; + target_label = "unit"; + } + ]; + } + ]; + }; + }; + services.nginx = { enable = true;