Changes for Prometheus
This commit is contained in:
parent
63b80fb5dc
commit
83fda1a391
|
@ -49,9 +49,9 @@ let
|
|||
};
|
||||
|
||||
gssapi-realm = mkOption {
|
||||
type = str;
|
||||
type = nullOr str;
|
||||
description = "GSSAPI (i.e. Kerberos) realm of this domain.";
|
||||
default = toUpper domain;
|
||||
default = null;
|
||||
};
|
||||
|
||||
kerberos-master = mkOption {
|
||||
|
|
|
@ -7,11 +7,11 @@ let
|
|||
|
||||
in {
|
||||
|
||||
options.fudo.prometheus = {
|
||||
options.fudo.prometheus = with types; {
|
||||
enable = mkEnableOption "Fudo Prometheus Data-Gathering Server";
|
||||
|
||||
service-discovery-dns = mkOption {
|
||||
type = with types; attrsOf (listOf str);
|
||||
type = attrsOf (listOf str);
|
||||
description = ''
|
||||
A map of exporter type to a list of domains to use for service discovery.
|
||||
'';
|
||||
|
@ -28,7 +28,7 @@ in {
|
|||
};
|
||||
|
||||
static-targets = mkOption {
|
||||
type = with types; attrsOf (listOf str);
|
||||
type = attrsOf (listOf str);
|
||||
description = ''
|
||||
A map of exporter type to a list of host:ports from which to collect metrics.
|
||||
'';
|
||||
|
@ -44,7 +44,7 @@ in {
|
|||
};
|
||||
|
||||
docker-hosts = mkOption {
|
||||
type = with types; listOf str;
|
||||
type = listOf str;
|
||||
description = ''
|
||||
A list of explicit <host:port> docker targets from which to gather node data.
|
||||
'';
|
||||
|
@ -52,7 +52,7 @@ in {
|
|||
};
|
||||
|
||||
push-url = mkOption {
|
||||
type = with types; nullOr str;
|
||||
type = nullOr str;
|
||||
description = ''
|
||||
The <host:port> that services can use to manually push data.
|
||||
'';
|
||||
|
@ -60,7 +60,7 @@ in {
|
|||
};
|
||||
|
||||
push-address = mkOption {
|
||||
type = with types; nullOr str;
|
||||
type = nullOr str;
|
||||
description = ''
|
||||
The <host:port> address on which to listen for incoming data.
|
||||
'';
|
||||
|
@ -68,10 +68,16 @@ in {
|
|||
};
|
||||
|
||||
hostname = mkOption {
|
||||
type = with types; str;
|
||||
type = str;
|
||||
description = "The hostname upon which Prometheus will serve.";
|
||||
example = "my-metrics-server.fudo.org";
|
||||
};
|
||||
|
||||
state-directory = mkOption {
|
||||
type = str;
|
||||
description = "Directory at which to store Prometheus state.";
|
||||
default = "/var/lib/prometheus";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
|
|
@ -51,13 +51,11 @@ let
|
|||
lines = splitString "\n" zonedata;
|
||||
in concatStringsSep "\n" (map formatter lines);
|
||||
|
||||
makeSrvRecords = protocol: service: records: let
|
||||
service-blah = service;
|
||||
record-blah = records;
|
||||
in join-lines (map (record:
|
||||
"_${service}._${protocol} IN SRV ${toString record.priority} ${
|
||||
toString record.weight
|
||||
} ${toString record.port} ${record.host}.") records);
|
||||
makeSrvRecords = protocol: service: records:
|
||||
join-lines (map (record:
|
||||
"_${service}._${protocol} IN SRV ${toString record.priority} ${
|
||||
toString record.weight
|
||||
} ${toString record.port} ${record.host}.") records);
|
||||
|
||||
makeSrvProtocolRecords = protocol: services:
|
||||
join-lines (mapAttrsToList (makeSrvRecords protocol) services);
|
||||
|
@ -96,13 +94,10 @@ let
|
|||
"${hostname} IN A ${nethost-data.ipv4-address}";
|
||||
aaaa-record = optional (nethost-data.ipv6-address != null)
|
||||
"${hostname} IN AAAA ${nethost-data.ipv6-address}";
|
||||
cname-record = optional (nethost-data.authoritative-hostname != null)
|
||||
"${hostname} IN CNAME ${nethost-data.authoritative-hostname}";
|
||||
description-record = optional (nethost-data.description != null)
|
||||
''${hostname} IN TXT "${nethost-data.description}"'';
|
||||
in join-lines (a-record ++
|
||||
aaaa-record ++
|
||||
cname-record ++
|
||||
sshfp-records ++
|
||||
description-record);
|
||||
|
||||
|
@ -114,26 +109,11 @@ let
|
|||
|
||||
mxRecords = mxs: map (mx: "@ IN MX 10 ${mx}.") mxs;
|
||||
|
||||
nsRecords = domain: ns-hosts:
|
||||
mapAttrsToList (host: _: "@ IN NS ${host}.${domain}.") ns-hosts;
|
||||
nsRecords = map (ns-host: "@ IN NS ${ns-host}");
|
||||
|
||||
flatmapAttrsToList = f: attrs:
|
||||
foldr (a: b: a ++ b) [] (mapAttrsToList f attrs);
|
||||
|
||||
# nsARecords = _: ns-hosts: let
|
||||
# a-record = host: hostOpts: optional (hostOpts.ipv4-address != null)
|
||||
# "${host} IN A ${hostOpts.ipv4-address}";
|
||||
# aaaa-record = host: hostOpts: optional (hostOpts.ipv6-address != null)
|
||||
# "${host} IN AAAA ${hostOpts.ipv6-address}";
|
||||
# description-record = host: hostOpts: optional (hostOpts.description != null)
|
||||
# ''${host} IN TXT "${hostOpts.description}"'';
|
||||
# in flatmapAttrsToList
|
||||
# (host: hostOpts:
|
||||
# (a-record host hostOpts) ++
|
||||
# (aaaa-record host hostOpts) ++
|
||||
# (description-record host hostOpts))
|
||||
# ns-hosts;
|
||||
|
||||
|
||||
srvRecordPair = domain: protocol: service: record: {
|
||||
"_${service}._${protocol}.${domain}" =
|
||||
|
@ -142,7 +122,7 @@ let
|
|||
} ${record.host}.";
|
||||
};
|
||||
|
||||
domain-record = dom: zone: ''
|
||||
domain-records = dom: zone: ''
|
||||
$ORIGIN ${dom}.
|
||||
$TTL ${zone.default-ttl}
|
||||
|
||||
|
@ -156,9 +136,7 @@ let
|
|||
${optionalString (zone.gssapi-realm != null)
|
||||
''_kerberos IN TXT "${zone.gssapi-realm}"''}
|
||||
|
||||
${join-lines (nsRecords dom zone.nameservers)}
|
||||
|
||||
${join-lines (mapAttrsToList hostRecords zone.nameservers)}
|
||||
${join-lines (nsRecords zone.nameservers)}
|
||||
|
||||
${join-lines (mapAttrsToList makeSrvProtocolRecords zone.srv-records)}
|
||||
|
||||
|
@ -171,7 +149,7 @@ let
|
|||
${join-lines zone.verbatim-dns-records}
|
||||
|
||||
${join-lines (mapAttrsToList
|
||||
(subdom: subdomCfg: domain-record "${subdom}.${dom}" subdomCfg)
|
||||
(subdom: subdomCfg: domain-records "${subdom}.${dom}" subdomCfg)
|
||||
zone.subdomains)}
|
||||
'';
|
||||
|
||||
|
@ -203,6 +181,6 @@ in rec {
|
|||
3w
|
||||
5m)
|
||||
|
||||
${domain-record dom zone}
|
||||
${domain-records dom zone}
|
||||
'');
|
||||
}
|
||||
|
|
|
@ -16,16 +16,9 @@ with lib;
|
|||
};
|
||||
|
||||
mac-address = mkOption {
|
||||
type = nullOr types.str;
|
||||
description =
|
||||
"The MAC address of a given host, if desired for IP reservation.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
authoritative-hostname = mkOption {
|
||||
type = nullOr str;
|
||||
description =
|
||||
"The 'real' hostname of this host, i.e. CNAME. Prefer aliases!";
|
||||
"The MAC address of a given host, if desired for IP reservation.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
|
|
|
@ -48,15 +48,13 @@ let
|
|||
};
|
||||
|
||||
nameservers = mkOption {
|
||||
type = attrsOf (submodule networkHostOpts);
|
||||
description = "Map of domain nameservers to host data.";
|
||||
example = {
|
||||
"ns1" = {
|
||||
ipv4-address = "1.1.1.1";
|
||||
ipv6-address = "1::1";
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
type = listOf str;
|
||||
description = "List of zone nameservers.";
|
||||
example = [
|
||||
"ns1.fudo.org."
|
||||
"10.0.0.1"
|
||||
];
|
||||
default = [];
|
||||
};
|
||||
|
||||
srv-records = mkOption {
|
||||
|
|
Loading…
Reference in New Issue