Skip to content

Commit 86a80ee

Browse files
author
Shay Bergmann
committed
promtail: factor monitoring ref out of module
and into profile
1 parent 2d66fab commit 86a80ee

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

modules/promtail.nix

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ let
1111
inherit (cfg.server) grpc_listen_port;
1212
};
1313

14-
clients = [{
15-
url =
16-
"http://${config.cluster.nodes.monitoring.privateIP}:3100/loki/api/v1/push";
17-
}];
14+
inherit (cfg) clients;
1815

1916
positions = { filename = "/var/lib/promtail/positions.yaml"; };
2017

@@ -106,6 +103,17 @@ in {
106103
services.promtail = {
107104
enable = lib.mkEnableOption "Enable Promtail";
108105

106+
clients = lib.mkOption {
107+
default = [];
108+
type = with lib.types; listOf (submodule {
109+
options = {
110+
url = lib.mkOption {
111+
type = lib.types.string;
112+
};
113+
};
114+
});
115+
};
116+
109117
server = lib.mkOption {
110118
default = { };
111119
type = with lib.types;
@@ -126,7 +134,7 @@ in {
126134
};
127135
};
128136

129-
config = lib.mkIf (cfg.enable && config.cluster.nodes ? monitoring) {
137+
config = lib.mkIf cfg.enable {
130138
systemd.services.promtail = {
131139
description = "Promtail service for Loki";
132140
after = [ "network-online.target" ];

profiles/auxiliaries/promtail.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
_: { services.promtail.enable = true; }
1+
_: {
2+
services.promtail.enable = true;
3+
4+
services.promtail.clients = [{
5+
url =
6+
"http://${config.cluster.nodes.monitoring.privateIP}:3100/loki/api/v1/push";
7+
}];
8+
}

0 commit comments

Comments
 (0)