nixos/graphite: update docs, add graphite pager
This commit is contained in:
parent
38ed4d4d0f
commit
09c8d909fb
@ -24,6 +24,8 @@ let
|
||||
GRAPHITE_URL = cfg.seyren.graphiteUrl;
|
||||
} // cfg.seyren.extraConfig;
|
||||
|
||||
pagerConfig = pkgs.writeText "alarms.yaml" cfg.pager.alerts;
|
||||
|
||||
configDir = pkgs.buildEnv {
|
||||
name = "graphite-config";
|
||||
paths = lists.filter (el: el != null) [
|
||||
@ -83,13 +85,21 @@ in {
|
||||
|
||||
api = {
|
||||
enable = mkOption {
|
||||
description = "Whether to enable graphite api.";
|
||||
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="http://graphite.readthedocs.org/en/1.0/index.html"/>
|
||||
'';
|
||||
default = false;
|
||||
type = types.uniq types.bool;
|
||||
};
|
||||
|
||||
finders = mkOption {
|
||||
description = "List of finder plugins load.";
|
||||
description = "List of finder plugins to load.";
|
||||
default = [];
|
||||
example = [ pkgs.python27Packages.graphite_influxdb ];
|
||||
type = types.listOf types.package;
|
||||
@ -301,20 +311,56 @@ in {
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
pager = {
|
||||
enable = mkOption {
|
||||
description = ''
|
||||
Whether to enable graphite-pager service. For more information visit
|
||||
<link xlink:href="https://github.com/seatgeek/graphite-pager"/>
|
||||
'';
|
||||
default = false;
|
||||
type = types.uniq types.bool;
|
||||
};
|
||||
|
||||
redisUrl = mkOption {
|
||||
description = "Redis connection string.";
|
||||
default = "redis://localhost:${toString config.services.redis.port}/";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
graphiteUrl = mkOption {
|
||||
description = "URL to your graphite service.";
|
||||
default = "http://${cfg.web.host}:${toString cfg.web.port}";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
alerts = mkOption {
|
||||
description = "Alerts configuration for graphite-pager.";
|
||||
default = ''
|
||||
alerts:
|
||||
- target: constantLine(100)
|
||||
warning: 90
|
||||
critical: 200
|
||||
name: Test
|
||||
'';
|
||||
example = literalExample ''
|
||||
pushbullet_key: pushbullet_api_key
|
||||
alerts:
|
||||
- target: stats.seatgeek.app.deal_quality.venue_info_cache.hit
|
||||
warning: .5
|
||||
critical: 1
|
||||
name: Deal quality venue cache hits
|
||||
'';
|
||||
type = types.lines;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf (
|
||||
cfg.carbon.enableAggregator ||
|
||||
cfg.carbon.enableCache ||
|
||||
cfg.carbon.enableRelay ||
|
||||
cfg.web.enable ||
|
||||
cfg.api.enable ||
|
||||
cfg.seyren.enable
|
||||
) {
|
||||
config = mkMerge [
|
||||
(mkIf cfg.carbon.enableCache {
|
||||
systemd.services.carbonCache = {
|
||||
enable = cfg.carbon.enableCache;
|
||||
description = "Graphite Data Storage Backend";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-interfaces.target" ];
|
||||
@ -331,7 +377,9 @@ in {
|
||||
chown -R graphite:graphite ${cfg.dataDir}
|
||||
'';
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.carbon.enableAggregator {
|
||||
systemd.services.carbonAggregator = {
|
||||
enable = cfg.carbon.enableAggregator;
|
||||
description = "Carbon Data Aggregator";
|
||||
@ -344,9 +392,10 @@ in {
|
||||
Group = "graphite";
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.carbon.enableRelay {
|
||||
systemd.services.carbonRelay = {
|
||||
enable = cfg.carbon.enableRelay;
|
||||
description = "Carbon Data Relay";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-interfaces.target" ];
|
||||
@ -357,9 +406,16 @@ in {
|
||||
Group = "graphite";
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf (cfg.carbon.enableCache || cfg.carbon.enableAggregator || cfg.carbon.enableRelay) {
|
||||
environment.systemPackages = [
|
||||
pkgs.pythonPackages.carbon
|
||||
];
|
||||
})
|
||||
|
||||
(mkIf cfg.web.enable {
|
||||
systemd.services.graphiteWeb = {
|
||||
enable = cfg.web.enable;
|
||||
description = "Graphite Web Interface";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-interfaces.target" ];
|
||||
@ -397,8 +453,11 @@ in {
|
||||
'';
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.python27Packages.graphite_web ];
|
||||
})
|
||||
|
||||
(mkIf cfg.api.enable {
|
||||
systemd.services.graphiteApi = {
|
||||
enable = cfg.api.enable;
|
||||
description = "Graphite Api Interface";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-interfaces.target" ];
|
||||
@ -430,9 +489,10 @@ in {
|
||||
fi
|
||||
'';
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.seyren.enable {
|
||||
systemd.services.seyren = {
|
||||
enable = cfg.seyren.enable;
|
||||
description = "Graphite Alerting Dashboard";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-interfaces.target" "mongodb.service" ];
|
||||
@ -451,14 +511,31 @@ in {
|
||||
'';
|
||||
};
|
||||
|
||||
services.mongodb.enable = mkDefault cfg.seyren.enable;
|
||||
services.mongodb.enable = mkDefault true;
|
||||
})
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.pythonPackages.carbon
|
||||
pkgs.python27Packages.graphite_web
|
||||
pkgs.python27Packages.waitress
|
||||
];
|
||||
(mkIf cfg.pager.enable {
|
||||
systemd.services.graphitePager = {
|
||||
description = "Graphite Pager Alerting Daemon";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-interfaces.target" "redis.service" ];
|
||||
environment = {
|
||||
REDIS_URL = cfg.pager.redisUrl;
|
||||
GRAPHITE_URL = cfg.pager.graphiteUrl;
|
||||
};
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.pythonPackages.graphite_pager}/bin/graphite-pager --config ${pagerConfig}";
|
||||
User = "graphite";
|
||||
Group = "graphite";
|
||||
};
|
||||
};
|
||||
|
||||
services.redis.enable = mkDefault true;
|
||||
|
||||
environment.systemPackages = [ pkgs.pythonPackages.graphite_pager ];
|
||||
})
|
||||
|
||||
{
|
||||
users.extraUsers = singleton {
|
||||
name = "graphite";
|
||||
uid = config.ids.uids.graphite;
|
||||
@ -466,5 +543,6 @@ in {
|
||||
home = dataDir;
|
||||
};
|
||||
users.extraGroups.graphite.gid = config.ids.gids.graphite;
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user