diff options
Diffstat (limited to 'nixpkgs/nixos/modules/services/monitoring/graphite.nix')
-rw-r--r-- | nixpkgs/nixos/modules/services/monitoring/graphite.nix | 208 |
1 files changed, 27 insertions, 181 deletions
diff --git a/nixpkgs/nixos/modules/services/monitoring/graphite.nix b/nixpkgs/nixos/modules/services/monitoring/graphite.nix index baa943302a00..8edb2ca09974 100644 --- a/nixpkgs/nixos/modules/services/monitoring/graphite.nix +++ b/nixpkgs/nixos/modules/services/monitoring/graphite.nix @@ -24,16 +24,6 @@ let + cfg.web.extraConfig ); - graphiteApiConfig = pkgs.writeText "graphite-api.yaml" '' - search_index: ${dataDir}/index - ${optionalString (config.time.timeZone != null) "time_zone: ${config.time.timeZone}"} - ${optionalString (cfg.api.finders != []) "finders:"} - ${concatMapStringsSep "\n" (f: " - " + f.moduleName) cfg.api.finders} - ${optionalString (cfg.api.functions != []) "functions:"} - ${concatMapStringsSep "\n" (f: " - " + f) cfg.api.functions} - ${cfg.api.extraConfig} - ''; - seyrenConfig = { SEYREN_URL = cfg.seyren.seyrenUrl; MONGO_URL = cfg.seyren.mongoUrl; @@ -72,6 +62,8 @@ let in { imports = [ + (mkRemovedOptionModule ["services" "graphite" "api"] "") + (mkRemovedOptionModule ["services" "graphite" "beacon"] "") (mkRemovedOptionModule ["services" "graphite" "pager"] "") ]; @@ -81,26 +73,26 @@ in { dataDir = mkOption { type = types.path; default = "/var/db/graphite"; - description = '' + description = lib.mdDoc '' Data directory for graphite. ''; }; web = { enable = mkOption { - description = "Whether to enable graphite web frontend."; + description = lib.mdDoc "Whether to enable graphite web frontend."; default = false; type = types.bool; }; listenAddress = mkOption { - description = "Graphite web frontend listen address."; + description = lib.mdDoc "Graphite web frontend listen address."; default = "127.0.0.1"; type = types.str; }; port = mkOption { - description = "Graphite web frontend port."; + description = lib.mdDoc "Graphite web frontend port."; default = 8080; type = types.int; }; @@ -108,98 +100,16 @@ in { extraConfig = mkOption { type = types.str; default = ""; - description = '' + description = lib.mdDoc '' Graphite webapp settings. See: - <link xlink:href="http://graphite.readthedocs.io/en/latest/config-local-settings.html"/> + <http://graphite.readthedocs.io/en/latest/config-local-settings.html> ''; }; }; - api = { - enable = mkOption { - description = '' - Whether to enable graphite api. Graphite api is lightweight alternative - to graphite web, with api and without dashboard. It's advised to use - grafana as alternative dashboard and influxdb as alternative to - graphite carbon. - - For more information visit - <link xlink:href="https://graphite-api.readthedocs.org/en/latest/"/> - ''; - default = false; - type = types.bool; - }; - - finders = mkOption { - description = "List of finder plugins to load."; - default = []; - example = literalExpression "[ pkgs.python3Packages.influxgraph ]"; - type = types.listOf types.package; - }; - - functions = mkOption { - description = "List of functions to load."; - default = [ - "graphite_api.functions.SeriesFunctions" - "graphite_api.functions.PieFunctions" - ]; - type = types.listOf types.str; - }; - - listenAddress = mkOption { - description = "Graphite web service listen address."; - default = "127.0.0.1"; - type = types.str; - }; - - port = mkOption { - description = "Graphite api service port."; - default = 8080; - type = types.int; - }; - - package = mkOption { - description = "Package to use for graphite api."; - default = pkgs.python3Packages.graphite_api; - defaultText = literalExpression "pkgs.python3Packages.graphite_api"; - type = types.package; - }; - - extraConfig = mkOption { - description = "Extra configuration for graphite api."; - default = '' - whisper: - directories: - - ${dataDir}/whisper - ''; - defaultText = literalExpression '' - ''' - whisper: - directories: - - ''${config.${opt.dataDir}}/whisper - ''' - ''; - example = '' - allowed_origins: - - dashboard.example.com - cheat_times: true - influxdb: - host: localhost - port: 8086 - user: influxdb - pass: influxdb - db: metrics - cache: - CACHE_TYPE: 'filesystem' - CACHE_DIR: '/tmp/graphite-api-cache' - ''; - type = types.lines; - }; - }; - carbon = { config = mkOption { - description = "Content of carbon configuration file."; + description = lib.mdDoc "Content of carbon configuration file."; default = '' [cache] # Listen on localhost by default for security reasons @@ -215,13 +125,13 @@ in { }; enableCache = mkOption { - description = "Whether to enable carbon cache, the graphite storage daemon."; + description = lib.mdDoc "Whether to enable carbon cache, the graphite storage daemon."; default = false; type = types.bool; }; storageAggregation = mkOption { - description = "Defines how to aggregate data to lower-precision retentions."; + description = lib.mdDoc "Defines how to aggregate data to lower-precision retentions."; default = null; type = types.nullOr types.str; example = '' @@ -233,7 +143,7 @@ in { }; storageSchemas = mkOption { - description = "Defines retention rates for storing metrics."; + description = lib.mdDoc "Defines retention rates for storing metrics."; default = ""; type = types.nullOr types.str; example = '' @@ -244,21 +154,21 @@ in { }; blacklist = mkOption { - description = "Any metrics received which match one of the experssions will be dropped."; + description = lib.mdDoc "Any metrics received which match one of the experssions will be dropped."; default = null; type = types.nullOr types.str; example = "^some\\.noisy\\.metric\\.prefix\\..*"; }; whitelist = mkOption { - description = "Only metrics received which match one of the experssions will be persisted."; + description = lib.mdDoc "Only metrics received which match one of the experssions will be persisted."; default = null; type = types.nullOr types.str; example = ".*"; }; rewriteRules = mkOption { - description = '' + description = lib.mdDoc '' Regular expression patterns that can be used to rewrite metric names in a search and replace fashion. ''; @@ -272,13 +182,13 @@ in { }; enableRelay = mkOption { - description = "Whether to enable carbon relay, the carbon replication and sharding service."; + description = lib.mdDoc "Whether to enable carbon relay, the carbon replication and sharding service."; default = false; type = types.bool; }; relayRules = mkOption { - description = "Relay rules are used to send certain metrics to a certain backend."; + description = lib.mdDoc "Relay rules are used to send certain metrics to a certain backend."; default = null; type = types.nullOr types.str; example = '' @@ -289,13 +199,13 @@ in { }; enableAggregator = mkOption { - description = "Whether to enable carbon aggregator, the carbon buffering service."; + description = lib.mdDoc "Whether to enable carbon aggregator, the carbon buffering service."; default = false; type = types.bool; }; aggregationRules = mkOption { - description = "Defines if and how received metrics will be aggregated."; + description = lib.mdDoc "Defines if and how received metrics will be aggregated."; default = null; type = types.nullOr types.str; example = '' @@ -307,13 +217,13 @@ in { seyren = { enable = mkOption { - description = "Whether to enable seyren service."; + description = lib.mdDoc "Whether to enable seyren service."; default = false; type = types.bool; }; port = mkOption { - description = "Seyren listening port."; + description = lib.mdDoc "Seyren listening port."; default = 8081; type = types.int; }; @@ -321,29 +231,29 @@ in { seyrenUrl = mkOption { default = "http://localhost:${toString cfg.seyren.port}/"; defaultText = literalExpression ''"http://localhost:''${toString config.${opt.seyren.port}}/"''; - description = "Host where seyren is accessible."; + description = lib.mdDoc "Host where seyren is accessible."; type = types.str; }; graphiteUrl = mkOption { default = "http://${cfg.web.listenAddress}:${toString cfg.web.port}"; defaultText = literalExpression ''"http://''${config.${opt.web.listenAddress}}:''${toString config.${opt.web.port}}"''; - description = "Host where graphite service runs."; + description = lib.mdDoc "Host where graphite service runs."; type = types.str; }; mongoUrl = mkOption { default = "mongodb://${config.services.mongodb.bind_ip}:27017/seyren"; defaultText = literalExpression ''"mongodb://''${config.services.mongodb.bind_ip}:27017/seyren"''; - description = "Mongodb connection string."; + description = lib.mdDoc "Mongodb connection string."; type = types.str; }; extraConfig = mkOption { default = {}; - description = '' + description = lib.mdDoc '' Extra seyren configuration. See - <link xlink:href='https://github.com/scobal/seyren#config' /> + <https://github.com/scobal/seyren#config> ''; type = types.attrsOf types.str; example = literalExpression '' @@ -354,16 +264,6 @@ in { ''; }; }; - - beacon = { - enable = mkEnableOption "graphite beacon"; - - config = mkOption { - description = "Graphite beacon configuration."; - default = {}; - type = types.attrs; - }; - }; }; ###### implementation @@ -489,44 +389,6 @@ in { environment.systemPackages = [ pkgs.python3Packages.graphite-web ]; })) - (mkIf cfg.api.enable { - systemd.services.graphiteApi = { - description = "Graphite Api Interface"; - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; - environment = { - PYTHONPATH = let - aenv = pkgs.python3.buildEnv.override { - extraLibs = [ cfg.api.package pkgs.cairo pkgs.python3Packages.cffi ] ++ cfg.api.finders; - }; - in "${aenv}/${pkgs.python3.sitePackages}"; - GRAPHITE_API_CONFIG = graphiteApiConfig; - LD_LIBRARY_PATH = "${pkgs.cairo.out}/lib"; - }; - serviceConfig = { - ExecStart = '' - ${pkgs.python3Packages.waitress}/bin/waitress-serve \ - --host=${cfg.api.listenAddress} --port=${toString cfg.api.port} \ - graphite_api.app:app - ''; - User = "graphite"; - Group = "graphite"; - PermissionsStartOnly = true; - }; - preStart = '' - if ! test -e ${dataDir}/db-created; then - mkdir -p ${dataDir}/cache/ - chmod 0700 ${dataDir}/cache/ - - chown graphite:graphite ${cfg.dataDir} - chown -R graphite:graphite ${cfg.dataDir}/cache - - touch ${dataDir}/db-created - fi - ''; - }; - }) - (mkIf cfg.seyren.enable { systemd.services.seyren = { description = "Graphite Alerting Dashboard"; @@ -550,25 +412,9 @@ in { services.mongodb.enable = mkDefault true; }) - (mkIf cfg.beacon.enable { - systemd.services.graphite-beacon = { - description = "Grpahite Beacon Alerting Daemon"; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - ExecStart = '' - ${pkgs.python3Packages.graphite_beacon}/bin/graphite-beacon \ - --config=${pkgs.writeText "graphite-beacon.json" (builtins.toJSON cfg.beacon.config)} - ''; - User = "graphite"; - Group = "graphite"; - }; - }; - }) - (mkIf ( cfg.carbon.enableCache || cfg.carbon.enableAggregator || cfg.carbon.enableRelay || - cfg.web.enable || cfg.api.enable || - cfg.seyren.enable || cfg.beacon.enable + cfg.web.enable || cfg.seyren.enable ) { users.users.graphite = { uid = config.ids.uids.graphite; |