diff --git a/modules/services/grafana.nix b/modules/services/grafana.nix index 5ef8b47..1df0e2f 100644 --- a/modules/services/grafana.nix +++ b/modules/services/grafana.nix @@ -87,4 +87,44 @@ in # metrics-addr = "127.0.0.1:9323"; # experimental = true; #}; + + # Logs + services.loki = { + enable = true; + dataDir = "/mnt/250ssd/loki"; + configFile = ./grafana/loki.yml; + }; + + services.promtail = { + enable = true; + configuration = { + server = { + http_listen_port = 28183; + grpc_listen_port = 0; + log_level = "warn"; + }; + positions.filename = "/tmp/positions.yaml"; + clients = [ + { url = "http://127.0.0.1:3100/loki/api/v1/push"; } + ]; + scrape_configs = [ + { + job_name = "journal"; + journal = { + max_age = "24h"; + labels = { + job = "systemd-journal"; + host = "127.0.0.1"; + }; + }; + relabel_configs = [ + { + source_labels = [ "__journal__systemd_unit" ]; + target_label = "unit"; + } + ]; + } + ]; + }; + }; } diff --git a/modules/services/grafana/loki.yml b/modules/services/grafana/loki.yml new file mode 100644 index 0000000..ceabe5c --- /dev/null +++ b/modules/services/grafana/loki.yml @@ -0,0 +1,29 @@ + +# This is a complete configuration to deploy Loki backed by the filesystem. +# The index will be shipped to the storage via tsdb-shipper. + +auth_enabled: false + +server: + http_listen_port: 3100 + +common: + ring: + instance_addr: 127.0.0.1 + kvstore: + store: inmemory + replication_factor: 1 + path_prefix: /mnt/250ssd/loki/common + +schema_config: + configs: + - from: 2020-05-15 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +analytics: + reporting_enabled: false