Added new option to specify ip and port for other nodes, fixed server.name to go through deployment.hostname

This commit is contained in:
daragh 2024-05-22 01:51:21 +01:00
parent 82305d43ff
commit 9b3e7265dd
No known key found for this signature in database
2 changed files with 9 additions and 8 deletions

View file

@ -1,4 +1,5 @@
{ {
nodes,
lib, lib,
config, config,
... ...
@ -10,11 +11,6 @@ in {
imports = []; imports = [];
options.services.skynet."${name}" = { options.services.skynet."${name}" = {
#list of servers passed in for monitoring
servers = mkOption {
type = types.listOf types.str;
};
server = { server = {
enable = mkEnableOption "Prometheus Server"; enable = mkEnableOption "Prometheus Server";
host = { host = {
@ -31,6 +27,13 @@ in {
type = types.port; type = types.port;
default = 9001; default = 9001;
}; };
other_nodes = mkOption {
type = types.listOf types.str;
description = ''
To add other nodes outside of nix, specify ip and port that server should listen to here
'';
};
}; };
collecter_port = mkOption { collecter_port = mkOption {
@ -57,7 +60,7 @@ in {
job_name = "node_exporter"; job_name = "node_exporter";
static_configs = [ static_configs = [
{ {
targets = map (server: "${server}.skynet.ie:{collecter_port}") cfg.servers; targets = map (hostname: "${hostname}:${collecter_port}") lib.attrsets.mapAttrsToList (server: server.deployment.hostname) nodes ++ cfg.other_nodes;
} }
]; ];
} }

View file

@ -53,8 +53,6 @@ in {
}; };
services.skynet.prometheus = { services.skynet.prometheus = {
servers = lib.attrsets.mapAttrsToList (server: server.name) nodes;
server = { server = {
host = { host = {
ip = ip_pub; ip = ip_pub;