Skip to content
Snippets Groups Projects
Commit c605f391 authored by Tom Prince's avatar Tom Prince
Browse files

Stop using `/etc/hosts` to name the monitoring host.

parent 4a28b54e
No related tags found
No related merge requests found
Pipeline #1821 failed
......@@ -18,6 +18,12 @@
corresponding private keys for the system.
'';
};
monitoringEndpoint = lib.mkOption {
type = lib.types.str;
description = ''
The IPv4 address of the monitoring node this node should conenct to.
'';
};
monitoringvpnIPv4 = lib.mkOption {
type = lib.types.str;
description = ''
......@@ -57,15 +63,17 @@
# qualified domain name.
deployment.targetHost = config.networking.fqdn;
networking.hosts = {
# This is the host that nodes should connect to for push-based monitoring.
# Note that this needs to be overridden on the monitoring host, otherwise
# we'd end up with infinite recursion.
grid.monitoringEndpoint = nodes.monitoring.config.grid.monitoringEndpoint;
# To stream logs to the monitoring host, all nodes need to know its address
${nodes.monitoring.config.services.private-storage.monitoring.vpn.server.ip} = [
"monitoring" "monitoring.monitoringvpn"
];
services.private-storage.monitoring.exporters.promtail = {
enable = true;
serverHost = config.grid.monitoringEndpoint;
};
services.private-storage.monitoring.exporters.promtail.enable = true;
assertions = [
# This is a check to save somebody in the future trying to debug why
# setting `nixpkgs.config` is not having an effect.
......
......@@ -92,6 +92,11 @@ in {
}
];
# We use `mkForce` here, to override the value specified in `morph/lib/base.nix`,
# Since the default value depends on the value defined on this node, there
# would otherwise be infinite recursiion.
grid.monitoringEndpoint = lib.mkForce monitoringvpnIPv4;
deployment.secrets = lib.mkMerge [
{
"monitoringvpn-private-key" = {
......
......@@ -15,6 +15,12 @@ let
in {
options.services.private-storage.monitoring.exporters.promtail = {
enable = lib.mkEnableOption "Promtail log exporter service";
serverHost = lib.mkOption {
type = lib.types.str;
description = ''
The server host that logs should be pushed to.
'';
};
};
config = lib.mkIf cfg.enable {
......@@ -28,7 +34,7 @@ in {
};
clients = [{
url = "http://monitoring:3100/loki/api/v1/push";
url = "http://${cfg.serverHost}:3100/loki/api/v1/push";
}];
scrape_configs = [{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment