forked from mirrors/nixpkgs
ef176dcf7e
conversions were done using https://github.com/pennae/nix-doc-munge using (probably) rev f34e145 running nix-doc-munge nixos/**/*.nix nix-doc-munge --import nixos/**/*.nix the tool ensures that only changes that could affect the generated manual *but don't* are committed, other changes require manual review and are discarded.
85 lines
2 KiB
Nix
85 lines
2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.heartbeat;
|
|
|
|
heartbeatYml = pkgs.writeText "heartbeat.yml" ''
|
|
name: ${cfg.name}
|
|
tags: ${builtins.toJSON cfg.tags}
|
|
|
|
${cfg.extraConfig}
|
|
'';
|
|
|
|
in
|
|
{
|
|
options = {
|
|
|
|
services.heartbeat = {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "heartbeat");
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.heartbeat;
|
|
defaultText = literalExpression "pkgs.heartbeat";
|
|
example = literalExpression "pkgs.heartbeat7";
|
|
description = lib.mdDoc ''
|
|
The heartbeat package to use.
|
|
'';
|
|
};
|
|
|
|
name = mkOption {
|
|
type = types.str;
|
|
default = "heartbeat";
|
|
description = lib.mdDoc "Name of the beat";
|
|
};
|
|
|
|
tags = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
description = lib.mdDoc "Tags to place on the shipped log messages";
|
|
};
|
|
|
|
stateDir = mkOption {
|
|
type = types.str;
|
|
default = "/var/lib/heartbeat";
|
|
description = lib.mdDoc "The state directory. heartbeat's own logs and other data are stored here.";
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = ''
|
|
heartbeat.monitors:
|
|
- type: http
|
|
urls: ["http://localhost:9200"]
|
|
schedule: '@every 10s'
|
|
'';
|
|
description = lib.mdDoc "Any other configuration options you want to add";
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d '${cfg.stateDir}' - nobody nogroup - -"
|
|
];
|
|
|
|
systemd.services.heartbeat = with pkgs; {
|
|
description = "heartbeat log shipper";
|
|
wantedBy = [ "multi-user.target" ];
|
|
preStart = ''
|
|
mkdir -p "${cfg.stateDir}"/{data,logs}
|
|
'';
|
|
serviceConfig = {
|
|
User = "nobody";
|
|
AmbientCapabilities = "cap_net_raw";
|
|
ExecStart = "${cfg.package}/bin/heartbeat -c \"${heartbeatYml}\" -path.data \"${cfg.stateDir}/data\" -path.logs \"${cfg.stateDir}/logs\"";
|
|
};
|
|
};
|
|
};
|
|
}
|