about summary refs log tree commit diff
path: root/modules/tempo.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/tempo.nix')
-rw-r--r--modules/tempo.nix74
1 files changed, 74 insertions, 0 deletions
diff --git a/modules/tempo.nix b/modules/tempo.nix
new file mode 100644
index 0000000..55beb4f
--- /dev/null
+++ b/modules/tempo.nix
@@ -0,0 +1,74 @@
+{
+  config,
+  inputs,
+  lib,
+  libNginx,
+  this,
+  ...
+}:
+let
+  cfg = config.nixfiles.modules.tempo;
+in
+{
+  options.nixfiles.modules.tempo = {
+    enable = lib.mkEnableOption "Tempo";
+
+    port = lib.mkOption {
+      description = "Port.";
+      type = lib.types.port;
+      default = 30181;
+    };
+
+    domain = lib.mkOption {
+      description = "Domain name sans protocol scheme.";
+      type = lib.types.str;
+      default = "tempo.${config.networking.domain}";
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    nixfiles.modules.nginx = {
+      enable = true;
+      upstreams.tempo.servers."127.0.0.1:${toString cfg.port}" = { };
+      virtualHosts.${cfg.domain} = {
+        locations."/".proxyPass = "http://tempo";
+        extraConfig = libNginx.config.internalOnly;
+      };
+    };
+
+    services.tempo = {
+      enable = true;
+      settings = rec {
+        multitenancy_enabled = false;
+
+        server = {
+          http_listen_address = "127.0.0.1";
+          http_listen_port = cfg.port;
+
+          grpc_listen_address = "0.0.0.0";
+          grpc_listen_port = server.http_listen_port + 1;
+
+          log_format = "logfmt";
+          log_level = "warn";
+          log_source_ips_enabled = true;
+        };
+
+        storage.trace.backend = "local";
+
+        memberlist = {
+          bind_port = 7947;
+          message_history_buffer_bytes = lib.pow 2 13;
+        };
+
+        compactor.compaction.block_retention = "168h";
+      };
+    };
+
+    topology.nodes.${this.hostname}.services.tempo = {
+      name = "Tempo";
+      icon = "${inputs.homelab-svg-assets}/assets/tempo.svg";
+      info = cfg.domain;
+      details.listen.text = "127.0.0.1:${toString cfg.port}";
+    };
+  };
+}

Consider giving Nix/NixOS a try! <3