From fdda65eea9d1fee75515613bb23b1b4b303c938f Mon Sep 17 00:00:00 2001 From: teutat3s Date: Tue, 5 Dec 2023 13:53:33 +0100 Subject: [PATCH] feat: init loki --- hosts/flora-6/apps/loki.nix | 76 +++++++++++++++++++++++++++++++++++++ hosts/flora-6/default.nix | 1 + 2 files changed, 77 insertions(+) create mode 100644 hosts/flora-6/apps/loki.nix diff --git a/hosts/flora-6/apps/loki.nix b/hosts/flora-6/apps/loki.nix new file mode 100644 index 00000000..943b0017 --- /dev/null +++ b/hosts/flora-6/apps/loki.nix @@ -0,0 +1,76 @@ +{ + config, + lib, + pkgs, + flake, + ... +}: { + # source: https://gist.github.com/rickhull/895b0cb38fdd537c1078a858cf15d63e + # https://grafana.com/docs/loki/latest/configure/examples/#1-local-configuration-exampleyaml + services.loki = { + enable = true; + configuration = { + server.http_listen_port = 3100; + auth_enabled = false; + common = { + ring = { + instance_addr = "127.0.0.1"; + kvstore = { + store = "inmemory"; + }; + }; + replication_factor = 1; + path_prefix = "/var/lib/loki"; + storage = { + filesystem = { + chunks_directory = "chunks/"; + rules_directory = "rules/"; + }; + }; + }; + + schema_config = { + configs = [{ + from = "2020-05-15"; + store = "boltdb-shipper"; + object_store = "filesystem"; + schema = "v11"; + index = { + prefix = "index_"; + period = "24h"; + }; + }]; + }; + }; + }; + + services.promtail = { + enable = true; + configuration = { + server = { + http_listen_port = 9080; + grpc_listen_port = 0; + }; + positions = { + filename = "/tmp/positions.yaml"; + }; + clients = [{ + url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push"; + }]; + scrape_configs = [{ + job_name = "journal"; + journal = { + max_age = "24h"; + labels = { + job = "systemd-journal"; + host = "flora-6"; + }; + }; + relabel_configs = [{ + source_labels = [ "__journal__systemd_unit" ]; + target_label = "unit"; + }]; + }]; + }; + }; +} diff --git a/hosts/flora-6/default.nix b/hosts/flora-6/default.nix index 6478858d..52b50e9c 100644 --- a/hosts/flora-6/default.nix +++ b/hosts/flora-6/default.nix @@ -13,5 +13,6 @@ ./apps/forgejo-actions-runner.nix ./apps/grafana.nix ./apps/prometheus.nix + ./apps/loki.nix ]; }