From c0b5932432baf74165fb5a822475aa9e4fda09cb Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Tue, 20 Dec 2022 13:08:26 +0100 Subject: [PATCH] Improve grafana config, enable boltdb-shipper --- hosts/ildkule/services/metrics/grafana.nix | 8 ++++++-- hosts/ildkule/services/metrics/loki.nix | 15 ++++++++++----- misc/metrics-exporters.nix | 3 --- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/hosts/ildkule/services/metrics/grafana.nix b/hosts/ildkule/services/metrics/grafana.nix index 3474266..383936f 100644 --- a/hosts/ildkule/services/metrics/grafana.nix +++ b/hosts/ildkule/services/metrics/grafana.nix @@ -17,6 +17,11 @@ url = ("http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}"); isDefault = true; } + { + name = "Ildkule loki"; + type = "loki"; + url = ("http://${config.services.loki.configuration.server.http_listen_address}:${toString config.services.loki.configuration.server.http_listen_port}"); + } ]; dashboards.settings.providers = [ { @@ -30,7 +35,7 @@ }; }; - services.nginx.virtualHosts.${config.services.grafana.domain} = { + services.nginx.virtualHosts.${config.services.grafana.settings.server.domain} = { locations = { "/" = { proxyPass = "http://${config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}"; @@ -38,7 +43,6 @@ extraConfig = '' proxy_buffers 8 1024k; proxy_buffer_size 1024k; - proxy_set_header Host $host; ''; }; }; diff --git a/hosts/ildkule/services/metrics/loki.nix b/hosts/ildkule/services/metrics/loki.nix index 603b409..07a9de8 100644 --- a/hosts/ildkule/services/metrics/loki.nix +++ b/hosts/ildkule/services/metrics/loki.nix @@ -7,6 +7,7 @@ auth_enabled = false; server = { http_listen_port = 3100; + http_listen_address = "127.0.0.1"; grpc_listen_port = 9096; }; @@ -16,6 +17,7 @@ dir = "/var/lib/loki/wal"; }; lifecycler = { + address = "127.0.0.1"; ring = { kvstore = { store = "inmemory"; @@ -24,19 +26,19 @@ }; final_sleep = "0s"; }; - chunk_idle_period = "10m"; + chunk_idle_period = "1h"; }; schema_config = { configs = [ { - from = "2022-01-01"; - store = "boltdb"; + from = "2022-12-01"; + store = "boltdb-shipper"; object_store = "filesystem"; schema = "v11"; index = { prefix = "index_"; - period = "48h"; + period = "24h"; }; } ]; @@ -44,7 +46,8 @@ storage_config = { boltdb_shipper = { - active_index_directory = "/var/lib/loki/index"; + active_index_directory = "/var/lib/loki/boltdb-shipper-index"; + cache_location = "/var/lib/loki/boltdb-shipper-cache"; shared_store = "filesystem"; cache_ttl = "24h"; }; @@ -76,4 +79,6 @@ # }; }; }; + + networking.firewall.allowedTCPPorts = [ config.services.loki.configuration.server.http_listen_port ]; } diff --git a/misc/metrics-exporters.nix b/misc/metrics-exporters.nix index e3c4fae..7d0b929 100644 --- a/misc/metrics-exporters.nix +++ b/misc/metrics-exporters.nix @@ -14,9 +14,6 @@ http_listen_port = 28183; grpc_listen_port = 0; }; - positions = { - filename = "/var/lib/promtail/positions.yaml"; - }; clients = [ { url = "http://ildkule.pvv.ntnu.no:3100/loki/api/v1/push";