From f0224cfac56c54b8cb7e5925bae26c0de8cf15dd Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sat, 27 Jul 2024 17:33:39 +0530 Subject: [PATCH] all: cleanup loki/promtail --- hosts/rico0/services/apps/alertmanager.nix | 2 +- hosts/rico0/services/apps/loki-config.yaml | 58 ++++++++++++++++++++++ hosts/rico0/services/apps/loki.nix | 49 +----------------- hosts/shared/promtail.nix | 5 +- 4 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 hosts/rico0/services/apps/loki-config.yaml diff --git a/hosts/rico0/services/apps/alertmanager.nix b/hosts/rico0/services/apps/alertmanager.nix index c901258..7764055 100644 --- a/hosts/rico0/services/apps/alertmanager.nix +++ b/hosts/rico0/services/apps/alertmanager.nix @@ -3,7 +3,7 @@ _: { caddy = { virtualHosts."alertmanager.labs.adtya.xyz" = { extraConfig = '' - reverse_proxy 127.0.0.1:3100 + reverse_proxy 127.0.0.1:9093 tls /persist/secrets/caddy/certs/default.crt /persist/secrets/caddy/certs/default.key ''; }; diff --git a/hosts/rico0/services/apps/loki-config.yaml b/hosts/rico0/services/apps/loki-config.yaml new file mode 100644 index 0000000..f0e6206 --- /dev/null +++ b/hosts/rico0/services/apps/loki-config.yaml @@ -0,0 +1,58 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + grpc_listen_port: 9096 + log_level: debug + grpc_server_max_concurrent_streams: 1000 + +common: + instance_addr: 127.0.0.1 + path_prefix: /mnt/data/loki + storage: + filesystem: + chunks_directory: /mnt/data/loki/chunks + rules_directory: /mnt/data/loki/rules + replication_factor: 1 + ring: + kvstore: + store: inmemory + +query_range: + results_cache: + cache: + embedded_cache: + enabled: true + max_size_mb: 100 + +schema_config: + configs: + - from: 2020-10-24 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +pattern_ingester: + enabled: true + +ruler: + alertmanager_url: https://alertmanager.labs.adtya.xyz + +frontend: + encoding: protobuf + +# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration +# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/ +# +# Statistics help us better understand how Loki is used, and they show us performance +# levels for most users. This helps us prioritize features and documentation. +# For more information on what's sent, look at +# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go +# Refer to the buildReport method to see what goes into a report. +# +# If you would like to disable reporting, uncomment the following lines: +analytics: + reporting_enabled: false diff --git a/hosts/rico0/services/apps/loki.nix b/hosts/rico0/services/apps/loki.nix index b2aa0b3..5f8a11a 100644 --- a/hosts/rico0/services/apps/loki.nix +++ b/hosts/rico0/services/apps/loki.nix @@ -11,54 +11,7 @@ _: { loki = { enable = true; dataDir = "/mnt/data/loki"; - configuration = { - auth_enabled = false; - - server = { - http_listen_port = 3100; - log_level = "warn"; - }; - - common = { - ring = { - instance_addr = "127.0.0.1"; - kvstore = { - store = "inmemory"; - }; - }; - storage = { - filesystem = { rules_directory = "/mnt/data/loki/rules"; }; - }; - replication_factor = 1; - path_prefix = "/mnt/data/loki"; - }; - - schema_config = { - configs = [ - { - from = "2024-07-01"; - store = "tsdb"; - object_store = "filesystem"; - schema = "v13"; - index = { prefix = "index_"; period = "24h"; }; - } - ]; - }; - - storage_config = { - filesystem = { - directory = "/mnt/data/loki/chunks"; - }; - }; - - ruler = { - alertmanager_url = "https://alertmanager.labs.adtya.xyz"; - }; - - frontend = { - encoding = "protobuf"; - }; - }; + configFile = ./loki-config.yaml; }; }; systemd.services.loki.unitConfig.RequiresMountsFor = [ "/mnt/data" ]; diff --git a/hosts/shared/promtail.nix b/hosts/shared/promtail.nix index 9ee374d..0e0deb9 100644 --- a/hosts/shared/promtail.nix +++ b/hosts/shared/promtail.nix @@ -14,11 +14,11 @@ server = { http_listen_address = "127.0.0.1"; http_listen_port = 9080; + grpc_listen_port = 0; }; clients = [ { - url = "https://loki.labs.adtya.xyz/api/v1/push"; - tenant_id = 1; + url = "https://loki.labs.adtya.xyz/loki/api/v1/push"; } ]; positions = { filename = "/tmp/promtail-positions.yaml"; }; @@ -29,7 +29,6 @@ json = false; max_age = "12h"; path = "/var/log/journal"; - matches = "_TRANSPORT=kernel"; labels = { job = "systemd-journal"; host = "${config.networking.hostName}"; }; }; relabel_configs = [