From 67873179ce4be8ace39b59175764c84387926a18 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Wed, 30 Oct 2024 16:23:03 +0700 Subject: [PATCH] loki: added derivedFields for tempo --- system/services/telemetry/loki.nix | 17 +++++++++++++++++ system/services/telemetry/tempo.nix | 1 + 2 files changed, 18 insertions(+) diff --git a/system/services/telemetry/loki.nix b/system/services/telemetry/loki.nix index 3b29992..7bb9072 100644 --- a/system/services/telemetry/loki.nix +++ b/system/services/telemetry/loki.nix @@ -2,6 +2,7 @@ let cfg = config.profile.services.telemetry.loki; inherit (lib) mkIf; + inherit (lib.lists) optional; lokiDomain = "loki.tigor.web.id"; server = config.services.loki.configuration.server; in @@ -96,6 +97,22 @@ in jsonData = { timeout = 60; maxLines = 1000; + derivedFields = + [ ] + ++ (optional config.services.tempo.enable { + datasourceUid = "tempo"; + matcherRegex = ''traceID=(\\w+)''; + name = "TraceID"; + url = "$\${__value.raw}"; + urlDisplayLabel = "Trace"; + }) + ++ (optional config.services.tempo.enable { + datasourceUid = "tempo"; + matcherRegex = ''"trace_id":"(\\w+)"''; + name = "TraceID"; + url = "$\${__value.raw}"; + urlDisplayLabel = "Trace"; + }); }; } ]; diff --git a/system/services/telemetry/tempo.nix b/system/services/telemetry/tempo.nix index d4cae57..edf5c31 100644 --- a/system/services/telemetry/tempo.nix +++ b/system/services/telemetry/tempo.nix @@ -53,6 +53,7 @@ in { name = "Tempo"; type = "tempo"; + uid = "tempo"; access = "proxy"; url = "http://${server.http_listen_address}:${toString server.http_listen_port}"; basicAuth = false;