nixpkgs/nixos/modules/services/networking/trickster.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

126 lines
3.4 KiB
Nix
Raw Normal View History

2019-11-01 09:57:29 +00:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.trickster;
in
{
2022-06-13 22:50:58 +00:00
imports = [
(mkRenamedOptionModule [ "services" "trickster" "origin" ] [ "services" "trickster" "origin-url" ])
];
2019-11-01 09:57:29 +00:00
options = {
services.trickster = {
enable = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc ''
2019-11-01 09:57:29 +00:00
Enable Trickster.
'';
};
package = mkOption {
type = types.package;
default = pkgs.trickster;
defaultText = literalExpression "pkgs.trickster";
description = lib.mdDoc ''
2019-11-01 09:57:29 +00:00
Package that should be used for trickster.
'';
};
configFile = mkOption {
type = types.nullOr types.path;
default = null;
description = lib.mdDoc ''
2019-11-01 09:57:29 +00:00
Path to configuration file.
'';
};
instance-id = mkOption {
type = types.nullOr types.int;
default = null;
description = lib.mdDoc ''
2019-11-01 09:57:29 +00:00
Instance ID for when running multiple processes (default null).
'';
};
log-level = mkOption {
type = types.str;
default = "info";
description = lib.mdDoc ''
2019-11-01 09:57:29 +00:00
Level of Logging to use (debug, info, warn, error) (default "info").
'';
};
metrics-port = mkOption {
type = types.port;
default = 8082;
description = lib.mdDoc ''
2019-11-01 09:57:29 +00:00
Port that the /metrics endpoint will listen on.
'';
};
2022-06-13 22:50:58 +00:00
origin-type = mkOption {
type = types.enum [ "prometheus" "influxdb" ];
default = "prometheus";
description = lib.mdDoc ''
2022-06-13 22:50:58 +00:00
Type of origin (prometheus, influxdb)
'';
};
origin-url = mkOption {
2019-11-01 09:57:29 +00:00
type = types.str;
default = "http://prometheus:9090";
description = lib.mdDoc ''
2022-06-13 22:50:58 +00:00
URL to the Origin. Enter it like you would in grafana, e.g., http://prometheus:9090 (default http://prometheus:9090).
2019-11-01 09:57:29 +00:00
'';
};
profiler-port = mkOption {
type = types.nullOr types.port;
default = null;
description = lib.mdDoc ''
2019-11-01 09:57:29 +00:00
Port that the /debug/pprof endpoint will listen on.
'';
};
proxy-port = mkOption {
type = types.port;
default = 9090;
description = lib.mdDoc ''
2019-11-01 09:57:29 +00:00
Port that the Proxy server will listen on.
'';
};
};
};
config = mkIf cfg.enable {
systemd.services.trickster = {
2022-06-13 22:50:58 +00:00
description = "Reverse proxy cache and time series dashboard accelerator";
2019-11-01 09:57:29 +00:00
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${cfg.package}/bin/trickster \
-log-level ${cfg.log-level} \
-metrics-port ${toString cfg.metrics-port} \
2022-06-13 22:50:58 +00:00
-origin-type ${cfg.origin-type} \
-origin-url ${cfg.origin-url} \
2019-11-01 09:57:29 +00:00
-proxy-port ${toString cfg.proxy-port} \
${optionalString (cfg.configFile != null) "-config ${cfg.configFile}"} \
${optionalString (cfg.profiler-port != null) "-profiler-port ${cfg.profiler-port}"} \
${optionalString (cfg.instance-id != null) "-instance-id ${cfg.instance-id}"}
'';
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
Restart = "always";
};
};
};
2020-07-29 10:57:20 +00:00
meta.maintainers = with maintainers; [ _1000101 ];
2019-11-01 09:57:29 +00:00
}