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;
|
GRAPHITE_URL = cfg.seyren.graphiteUrl;
|
||||||
} // cfg.seyren.extraConfig;
|
} // cfg.seyren.extraConfig;
|
||||||
|
|
||||||
|
pagerConfig = pkgs.writeText "alarms.yaml" cfg.pager.alerts;
|
||||||
|
|
||||||
configDir = pkgs.buildEnv {
|
configDir = pkgs.buildEnv {
|
||||||
name = "graphite-config";
|
name = "graphite-config";
|
||||||
paths = lists.filter (el: el != null) [
|
paths = lists.filter (el: el != null) [
|
||||||
@ -83,13 +85,21 @@ in {
|
|||||||
|
|
||||||
api = {
|
api = {
|
||||||
enable = mkOption {
|
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;
|
default = false;
|
||||||
type = types.uniq types.bool;
|
type = types.uniq types.bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
finders = mkOption {
|
finders = mkOption {
|
||||||
description = "List of finder plugins load.";
|
description = "List of finder plugins to load.";
|
||||||
default = [];
|
default = [];
|
||||||
example = [ pkgs.python27Packages.graphite_influxdb ];
|
example = [ pkgs.python27Packages.graphite_influxdb ];
|
||||||
type = types.listOf types.package;
|
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
|
###### implementation
|
||||||
|
|
||||||
config = mkIf (
|
config = mkMerge [
|
||||||
cfg.carbon.enableAggregator ||
|
(mkIf cfg.carbon.enableCache {
|
||||||
cfg.carbon.enableCache ||
|
|
||||||
cfg.carbon.enableRelay ||
|
|
||||||
cfg.web.enable ||
|
|
||||||
cfg.api.enable ||
|
|
||||||
cfg.seyren.enable
|
|
||||||
) {
|
|
||||||
systemd.services.carbonCache = {
|
systemd.services.carbonCache = {
|
||||||
enable = cfg.carbon.enableCache;
|
|
||||||
description = "Graphite Data Storage Backend";
|
description = "Graphite Data Storage Backend";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network-interfaces.target" ];
|
after = [ "network-interfaces.target" ];
|
||||||
@ -331,7 +377,9 @@ in {
|
|||||||
chown -R graphite:graphite ${cfg.dataDir}
|
chown -R graphite:graphite ${cfg.dataDir}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.carbon.enableAggregator {
|
||||||
systemd.services.carbonAggregator = {
|
systemd.services.carbonAggregator = {
|
||||||
enable = cfg.carbon.enableAggregator;
|
enable = cfg.carbon.enableAggregator;
|
||||||
description = "Carbon Data Aggregator";
|
description = "Carbon Data Aggregator";
|
||||||
@ -344,9 +392,10 @@ in {
|
|||||||
Group = "graphite";
|
Group = "graphite";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.carbon.enableRelay {
|
||||||
systemd.services.carbonRelay = {
|
systemd.services.carbonRelay = {
|
||||||
enable = cfg.carbon.enableRelay;
|
|
||||||
description = "Carbon Data Relay";
|
description = "Carbon Data Relay";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network-interfaces.target" ];
|
after = [ "network-interfaces.target" ];
|
||||||
@ -357,9 +406,16 @@ in {
|
|||||||
Group = "graphite";
|
Group = "graphite";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf (cfg.carbon.enableCache || cfg.carbon.enableAggregator || cfg.carbon.enableRelay) {
|
||||||
|
environment.systemPackages = [
|
||||||
|
pkgs.pythonPackages.carbon
|
||||||
|
];
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.web.enable {
|
||||||
systemd.services.graphiteWeb = {
|
systemd.services.graphiteWeb = {
|
||||||
enable = cfg.web.enable;
|
|
||||||
description = "Graphite Web Interface";
|
description = "Graphite Web Interface";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network-interfaces.target" ];
|
after = [ "network-interfaces.target" ];
|
||||||
@ -397,8 +453,11 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = [ pkgs.python27Packages.graphite_web ];
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.api.enable {
|
||||||
systemd.services.graphiteApi = {
|
systemd.services.graphiteApi = {
|
||||||
enable = cfg.api.enable;
|
|
||||||
description = "Graphite Api Interface";
|
description = "Graphite Api Interface";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network-interfaces.target" ];
|
after = [ "network-interfaces.target" ];
|
||||||
@ -430,9 +489,10 @@ in {
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.seyren.enable {
|
||||||
systemd.services.seyren = {
|
systemd.services.seyren = {
|
||||||
enable = cfg.seyren.enable;
|
|
||||||
description = "Graphite Alerting Dashboard";
|
description = "Graphite Alerting Dashboard";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network-interfaces.target" "mongodb.service" ];
|
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 = [
|
(mkIf cfg.pager.enable {
|
||||||
pkgs.pythonPackages.carbon
|
systemd.services.graphitePager = {
|
||||||
pkgs.python27Packages.graphite_web
|
description = "Graphite Pager Alerting Daemon";
|
||||||
pkgs.python27Packages.waitress
|
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 {
|
users.extraUsers = singleton {
|
||||||
name = "graphite";
|
name = "graphite";
|
||||||
uid = config.ids.uids.graphite;
|
uid = config.ids.uids.graphite;
|
||||||
@ -466,5 +543,6 @@ in {
|
|||||||
home = dataDir;
|
home = dataDir;
|
||||||
};
|
};
|
||||||
users.extraGroups.graphite.gid = config.ids.gids.graphite;
|
users.extraGroups.graphite.gid = config.ids.gids.graphite;
|
||||||
};
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user