aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/mo/monitoring/components/loki.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/mo/monitoring/components/loki.nix')
-rw-r--r--modules/by-name/mo/monitoring/components/loki.nix170
1 files changed, 0 insertions, 170 deletions
diff --git a/modules/by-name/mo/monitoring/components/loki.nix b/modules/by-name/mo/monitoring/components/loki.nix
deleted file mode 100644
index 149e577..0000000
--- a/modules/by-name/mo/monitoring/components/loki.nix
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- config,
- lib,
- pkgs,
- ...
-}: let
- cfg = config.vhack.monitoring.loki;
-in {
- options.vhack.monitoring.loki = {
- enable = lib.mkEnableOption "loki";
-
- port = lib.mkOption {
- type = lib.types.port;
- description = "Port where Loki listens to HTTP requests.";
- default = 3002;
- };
- };
-
- config = lib.mkIf cfg.enable {
- vhack = {
- persist.directories = [
- {
- directory = "/var/lib/loki";
- user = "loki";
- group = "loki";
- mode = "0700";
- }
- {
- directory = "/var/lib/fluent-bit";
- user = "fluent-bit";
- group = "fluent-bit";
- mode = "0700";
- }
- ];
- };
-
- users = {
- groups = {
- fluent-bit = {
- gid = config.vhack.constants.ids.gids.fluent-bit;
- };
- loki = {
- gid = config.vhack.constants.ids.gids.loki;
- };
- };
- users = {
- fluent-bit = {
- isSystemUser = true;
- group = "fluent-bit";
- uid = config.vhack.constants.ids.uids.fluent-bit;
- };
- loki = {
- isSystemUser = true;
- group = "loki";
- uid = config.vhack.constants.ids.uids.loki;
- };
- };
- };
-
- # I decided to switch to fluent-bit because it can be tested locally https://docs.fluentbit.io/manual/local-testing/logging-pipeline
- systemd.services.fluent-bit = {
- serviceConfig = {
- StateDirectory = "fluent-bit";
- User = "fluent-bit";
- Group = "fluent-bit";
- DynamicUser = lib.mkForce false;
- };
- };
- services = {
- fluent-bit = {
- enable = true;
- settings = {
- service = {
- flush = 1;
- log_level = "info";
- http_server = "true";
- http_listen = "127.0.0.1";
- http_port = 9080;
- grace = 30;
- };
-
- pipeline = {
- inputs = [
- {
- name = "systemd";
-
- # The asterisk appends the _SYSTEMD_UNIT to the prefix.
- tag = "systemd.*";
-
- # Read logs from this systemd journal directory.
- path = "/var/log/journal";
-
- # Database file to keep track of the journald cursor.
- db = "/var/lib/fluent-bit/systemd.db";
-
- # Start reading new entries. Skip entries already stored in journald.
- read_from_tail = true;
-
- # Max entries to lookback on start.
- max_entries = 10000;
- }
- ];
-
- outputs = [
- {
- name = "loki";
-
- match = "systemd.*";
-
- host = "localhost";
- port = config.services.loki.configuration.server.http_listen_port;
-
- labels = lib.concatMapAttrsStringSep ", " (n: v: "${n}=${v}") {
- job = "systemd-journal";
- inherit (config.vhack.monitoring.grafana) fqdn;
- hostname = config.networking.hostName;
- };
-
- label_keys = "$unit";
- }
- ];
- };
- };
- graceLimit = "1m";
- };
-
- loki = {
- enable = true;
- dataDir = "/var/lib/loki";
- package = pkgs.grafana-loki;
- configuration = {
- auth_enabled = false;
-
- server.http_listen_port = cfg.port;
-
- common = {
- ring = {
- instance_addr = "127.0.0.1";
- kvstore = {
- store = "inmemory";
- };
- };
-
- replication_factor = 1;
- path_prefix = "/tmp/loki";
- };
-
- schema_config = {
- configs = [
- {
- from = "2020-05-15";
- store = "tsdb";
- object_store = "filesystem";
- schema = "v13";
- index = {
- prefix = "index_";
- period = "24h";
- };
- }
- ];
- };
-
- storage_config = {
- filesystem.directory = "/tmp/loki/chunks";
- };
- };
- };
- };
- };
-}