tlaternet-server/configuration/services/metrics/exporters.nix

46 lines
1.2 KiB
Nix
Raw Normal View History

2023-10-02 21:54:21 +01:00
{
config,
lib,
...
}: {
options.services.prometheus.local-exporters = lib.mkOption {
type = lib.types.anything;
};
config.systemd.services = lib.mapAttrs (_: exporter:
lib.mkMerge [
{
wantedBy = ["multi-user.target"];
after = ["network.target"];
serviceConfig = {
Restart = "always";
PrivateTmp = true;
WorkingDirectory = "/tmp";
DynamicUser = true;
LockPersonality = true;
MemoryDenyWriteExecute = true;
NonNewPrivileges = true;
PrivateDevices = true;
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectSystem = "strict";
RemoveIPC = true;
RestrictAddressFamilies = ["AF_INET" "AF_INET6"];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
UMask = "0077";
};
}
(removeAttrs exporter ["port" "listenAddress"])
])
config.services.prometheus.local-exporters;
}