2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2013-08-11 12:16:19 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.graphite;
|
2014-03-10 10:57:51 +01:00
|
|
|
writeTextOrNull = f: t: if t == null then null else pkgs.writeTextDir f t;
|
|
|
|
|
|
|
|
dataDir = cfg.dataDir;
|
|
|
|
|
2014-09-11 13:39:48 +02:00
|
|
|
graphiteApiConfig = pkgs.writeText "graphite-api.yaml" ''
|
|
|
|
time_zone: ${config.time.timeZone}
|
|
|
|
search_index: ${dataDir}/index
|
|
|
|
${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}
|
|
|
|
'';
|
|
|
|
|
2014-09-17 18:31:02 +02:00
|
|
|
seyrenConfig = {
|
|
|
|
SEYREN_URL = cfg.seyren.seyrenUrl;
|
|
|
|
MONGO_URL = cfg.seyren.mongoUrl;
|
|
|
|
GRAPHITE_URL = cfg.seyren.graphiteUrl;
|
|
|
|
} // cfg.seyren.extraConfig;
|
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
pagerConfig = pkgs.writeText "alarms.yaml" cfg.pager.alerts;
|
|
|
|
|
2014-03-10 10:57:51 +01:00
|
|
|
configDir = pkgs.buildEnv {
|
|
|
|
name = "graphite-config";
|
|
|
|
paths = lists.filter (el: el != null) [
|
|
|
|
(writeTextOrNull "carbon.conf" cfg.carbon.config)
|
2014-06-07 23:40:58 +02:00
|
|
|
(writeTextOrNull "storage-aggregation.conf" cfg.carbon.storageAggregation)
|
2014-03-10 10:57:51 +01:00
|
|
|
(writeTextOrNull "storage-schemas.conf" cfg.carbon.storageSchemas)
|
|
|
|
(writeTextOrNull "blacklist.conf" cfg.carbon.blacklist)
|
|
|
|
(writeTextOrNull "whitelist.conf" cfg.carbon.whitelist)
|
|
|
|
(writeTextOrNull "rewrite-rules.conf" cfg.carbon.rewriteRules)
|
|
|
|
(writeTextOrNull "relay-rules.conf" cfg.carbon.relayRules)
|
|
|
|
(writeTextOrNull "aggregation-rules.conf" cfg.carbon.aggregationRules)
|
|
|
|
];
|
|
|
|
};
|
2013-10-13 23:10:29 +02:00
|
|
|
|
|
|
|
carbonOpts = name: with config.ids; ''
|
2014-03-10 10:57:51 +01:00
|
|
|
--nodaemon --syslog --prefix=${name} --pidfile ${dataDir}/${name}.pid ${name}
|
2013-10-13 23:10:29 +02:00
|
|
|
'';
|
|
|
|
carbonEnv = {
|
|
|
|
PYTHONPATH = "${pkgs.python27Packages.carbon}/lib/python2.7/site-packages";
|
|
|
|
GRAPHITE_ROOT = dataDir;
|
2014-03-10 10:57:51 +01:00
|
|
|
GRAPHITE_CONF_DIR = configDir;
|
2013-11-07 11:29:18 +01:00
|
|
|
GRAPHITE_STORAGE_DIR = dataDir;
|
2013-10-13 23:10:29 +02:00
|
|
|
};
|
|
|
|
|
2013-08-11 12:16:19 +02:00
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options.services.graphite = {
|
2014-03-10 10:57:51 +01:00
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/db/graphite";
|
|
|
|
description = ''
|
|
|
|
Data directory for graphite.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
web = {
|
|
|
|
enable = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Whether to enable graphite web frontend.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = false;
|
2015-06-15 18:10:26 +02:00
|
|
|
type = types.bool;
|
2013-08-19 04:14:53 +02:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
host = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Graphite web frontend listen address.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = "127.0.0.1";
|
2013-10-30 11:02:04 +01:00
|
|
|
type = types.str;
|
2013-08-19 04:14:53 +02:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
port = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Graphite web frontend port.";
|
2014-03-10 10:57:51 +01:00
|
|
|
default = 8080;
|
|
|
|
type = types.int;
|
2013-08-19 04:14:53 +02:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
};
|
|
|
|
|
2014-09-11 13:39:48 +02:00
|
|
|
api = {
|
|
|
|
enable = mkOption {
|
2014-10-20 13:27:21 +02:00
|
|
|
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
|
2014-10-20 13:32:58 +02:00
|
|
|
<link xlink:href="http://graphite-api.readthedocs.org/en/latest/"/>
|
2014-10-20 13:27:21 +02:00
|
|
|
'';
|
2014-09-11 13:39:48 +02:00
|
|
|
default = false;
|
2015-06-15 18:10:26 +02:00
|
|
|
type = types.bool;
|
2014-09-11 13:39:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
finders = mkOption {
|
2014-10-20 13:27:21 +02:00
|
|
|
description = "List of finder plugins to load.";
|
2014-09-11 13:39:48 +02:00
|
|
|
default = [];
|
|
|
|
example = [ pkgs.python27Packages.graphite_influxdb ];
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2014-09-15 11:38:39 +02:00
|
|
|
host = 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;
|
|
|
|
};
|
|
|
|
|
2014-09-17 18:32:51 +02:00
|
|
|
package = mkOption {
|
|
|
|
description = "Package to use for graphite api.";
|
|
|
|
default = pkgs.python27Packages.graphite_api;
|
|
|
|
type = types.package;
|
|
|
|
};
|
|
|
|
|
2014-09-11 13:39:48 +02:00
|
|
|
extraConfig = mkOption {
|
|
|
|
description = "Extra configuration for graphite api.";
|
|
|
|
default = ''
|
|
|
|
whisper:
|
|
|
|
directories:
|
|
|
|
- ${dataDir}/whisper
|
|
|
|
'';
|
2014-09-16 10:41:27 +02:00
|
|
|
example = literalExample ''
|
|
|
|
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'
|
|
|
|
'';
|
2014-09-11 13:39:48 +02:00
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
carbon = {
|
|
|
|
config = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Content of carbon configuration file.";
|
2013-10-11 11:44:26 +02:00
|
|
|
default = ''
|
|
|
|
[cache]
|
|
|
|
# Listen on localhost by default for security reasons
|
|
|
|
UDP_RECEIVER_INTERFACE = 127.0.0.1
|
|
|
|
PICKLE_RECEIVER_INTERFACE = 127.0.0.1
|
|
|
|
LINE_RECEIVER_INTERFACE = 127.0.0.1
|
|
|
|
CACHE_QUERY_INTERFACE = 127.0.0.1
|
2013-10-28 17:09:53 +01:00
|
|
|
# Do not log every update
|
|
|
|
LOG_UPDATES = False
|
|
|
|
LOG_CACHE_HITS = False
|
2013-10-11 11:44:26 +02:00
|
|
|
'';
|
2013-10-30 11:02:04 +01:00
|
|
|
type = types.str;
|
2013-08-19 04:14:53 +02:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
enableCache = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Whether to enable carbon cache, the graphite storage daemon.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = false;
|
2015-06-15 18:10:26 +02:00
|
|
|
type = types.bool;
|
2013-08-19 04:14:53 +02:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
storageAggregation = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Defines how to aggregate data to lower-precision retentions.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = null;
|
|
|
|
type = types.uniq (types.nullOr types.string);
|
|
|
|
example = ''
|
|
|
|
[all_min]
|
|
|
|
pattern = \.min$
|
|
|
|
xFilesFactor = 0.1
|
2013-10-13 23:10:29 +02:00
|
|
|
aggregationMethod = min
|
2013-08-19 04:14:53 +02:00
|
|
|
'';
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
storageSchemas = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Defines retention rates for storing metrics.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = "";
|
|
|
|
type = types.uniq (types.nullOr types.string);
|
|
|
|
example = ''
|
|
|
|
[apache_busyWorkers]
|
|
|
|
pattern = ^servers\.www.*\.workers\.busyWorkers$
|
|
|
|
retentions = 15s:7d,1m:21d,15m:5y
|
|
|
|
'';
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
blacklist = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Any metrics received which match one of the experssions will be dropped.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = null;
|
|
|
|
type = types.uniq (types.nullOr types.string);
|
|
|
|
example = "^some\.noisy\.metric\.prefix\..*";
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
whitelist = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Only metrics received which match one of the experssions will be persisted.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = null;
|
|
|
|
type = types.uniq (types.nullOr types.string);
|
|
|
|
example = ".*";
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
rewriteRules = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = ''
|
|
|
|
Regular expression patterns that can be used to rewrite metric names
|
|
|
|
in a search and replace fashion.
|
|
|
|
'';
|
2013-08-19 04:14:53 +02:00
|
|
|
default = null;
|
|
|
|
type = types.uniq (types.nullOr types.string);
|
|
|
|
example = ''
|
|
|
|
[post]
|
|
|
|
_sum$ =
|
|
|
|
_avg$ =
|
|
|
|
'';
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
enableRelay = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Whether to enable carbon relay, the carbon replication and sharding service.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = false;
|
2015-06-15 18:10:26 +02:00
|
|
|
type = types.bool;
|
2013-08-19 04:14:53 +02:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
relayRules = mkOption {
|
|
|
|
description = "Relay rules are used to send certain metrics to a certain backend.";
|
|
|
|
default = null;
|
|
|
|
type = types.uniq (types.nullOr types.string);
|
|
|
|
example = ''
|
|
|
|
[example]
|
|
|
|
pattern = ^mydata\.foo\..+
|
|
|
|
servers = 10.1.2.3, 10.1.2.4:2004, myserver.mydomain.com
|
|
|
|
'';
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2013-08-19 04:14:53 +02:00
|
|
|
enableAggregator = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Whether to enable carbon agregator, the carbon buffering service.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = false;
|
2015-06-15 18:10:26 +02:00
|
|
|
type = types.bool;
|
2013-08-19 04:14:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
aggregationRules = mkOption {
|
2014-06-09 11:26:22 +02:00
|
|
|
description = "Defines if and how received metrics will be agregated.";
|
2013-08-19 04:14:53 +02:00
|
|
|
default = null;
|
|
|
|
type = types.uniq (types.nullOr types.string);
|
|
|
|
example = ''
|
|
|
|
<env>.applications.<app>.all.requests (60) = sum <env>.applications.<app>.*.requests
|
|
|
|
<env>.applications.<app>.all.latency (60) = avg <env>.applications.<app>.*.latency
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2014-09-17 18:31:02 +02:00
|
|
|
|
|
|
|
seyren = {
|
|
|
|
enable = mkOption {
|
|
|
|
description = "Whether to enable seyren service.";
|
|
|
|
default = false;
|
2015-06-15 18:10:26 +02:00
|
|
|
type = types.bool;
|
2014-09-17 18:31:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
description = "Seyren listening port.";
|
|
|
|
default = 8081;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
|
|
|
seyrenUrl = mkOption {
|
|
|
|
default = "http://localhost:${toString cfg.seyren.port}/";
|
|
|
|
description = "Host where seyren is accessible.";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
graphiteUrl = mkOption {
|
|
|
|
default = "http://${cfg.web.host}:${toString cfg.web.port}";
|
|
|
|
description = "Host where graphite service runs.";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
mongoUrl = mkOption {
|
|
|
|
default = "mongodb://${config.services.mongodb.bind_ip}:27017/seyren";
|
|
|
|
description = "Mongodb connection string.";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Extra seyren configuration. See
|
|
|
|
<link xlink:href='https://github.com/scobal/seyren#config' />
|
|
|
|
'';
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
GRAPHITE_USERNAME = "user";
|
2014-11-02 12:40:00 +01:00
|
|
|
GRAPHITE_PASSWORD = "pass";
|
2014-09-17 18:31:02 +02:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
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;
|
2015-06-15 18:10:26 +02:00
|
|
|
type = types.bool;
|
2014-10-20 13:27:21 +02:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
redisUrl = mkOption {
|
|
|
|
description = "Redis connection string.";
|
|
|
|
default = "redis://localhost:${toString config.services.redis.port}/";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
graphiteUrl = mkOption {
|
|
|
|
description = "URL to your graphite service.";
|
|
|
|
default = "http://${cfg.web.host}:${toString cfg.web.port}";
|
|
|
|
type = types.str;
|
2014-03-10 10:57:51 +01:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
alerts = mkOption {
|
|
|
|
description = "Alerts configuration for graphite-pager.";
|
|
|
|
default = ''
|
|
|
|
alerts:
|
|
|
|
- target: constantLine(100)
|
|
|
|
warning: 90
|
|
|
|
critical: 200
|
|
|
|
name: Test
|
|
|
|
'';
|
|
|
|
example = literalExample ''
|
2014-11-02 12:40:00 +01:00
|
|
|
pushbullet_key: pushbullet_api_key
|
2014-10-20 13:27:21 +02:00
|
|
|
alerts:
|
|
|
|
- target: stats.seatgeek.app.deal_quality.venue_info_cache.hit
|
|
|
|
warning: .5
|
|
|
|
critical: 1
|
|
|
|
name: Deal quality venue cache hits
|
|
|
|
'';
|
|
|
|
type = types.lines;
|
2014-03-10 10:57:51 +01:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
};
|
2015-04-25 15:13:38 +02:00
|
|
|
|
|
|
|
beacon = {
|
2015-06-21 17:19:46 +02:00
|
|
|
enable = mkEnableOption "graphite beacon";
|
2015-04-25 15:13:38 +02:00
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
description = "Graphite beacon configuration.";
|
|
|
|
default = {};
|
|
|
|
type = types.attrs;
|
|
|
|
};
|
|
|
|
};
|
2014-10-20 13:27:21 +02:00
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
###### implementation
|
2014-04-17 15:40:02 +02:00
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf cfg.carbon.enableCache {
|
|
|
|
systemd.services.carbonCache = {
|
|
|
|
description = "Graphite Data Storage Backend";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network-interfaces.target" ];
|
|
|
|
environment = carbonEnv;
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.twisted}/bin/twistd ${carbonOpts "carbon-cache"}";
|
|
|
|
User = "graphite";
|
|
|
|
Group = "graphite";
|
|
|
|
PermissionsStartOnly = true;
|
|
|
|
};
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p ${cfg.dataDir}/whisper
|
|
|
|
chmod 0700 ${cfg.dataDir}/whisper
|
2014-04-17 15:40:02 +02:00
|
|
|
chown -R graphite:graphite ${cfg.dataDir}
|
2014-09-11 13:39:48 +02:00
|
|
|
'';
|
|
|
|
};
|
2014-10-20 13:27:21 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.carbon.enableAggregator {
|
|
|
|
systemd.services.carbonAggregator = {
|
|
|
|
enable = cfg.carbon.enableAggregator;
|
|
|
|
description = "Carbon Data Aggregator";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network-interfaces.target" ];
|
|
|
|
environment = carbonEnv;
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.twisted}/bin/twistd ${carbonOpts "carbon-aggregator"}";
|
|
|
|
User = "graphite";
|
|
|
|
Group = "graphite";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.carbon.enableRelay {
|
|
|
|
systemd.services.carbonRelay = {
|
|
|
|
description = "Carbon Data Relay";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network-interfaces.target" ];
|
|
|
|
environment = carbonEnv;
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.twisted}/bin/twistd ${carbonOpts "carbon-relay"}";
|
|
|
|
User = "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 = {
|
|
|
|
description = "Graphite Web Interface";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network-interfaces.target" ];
|
|
|
|
path = [ pkgs.perl ];
|
|
|
|
environment = {
|
|
|
|
PYTHONPATH = "${pkgs.python27Packages.graphite_web}/lib/python2.7/site-packages";
|
|
|
|
DJANGO_SETTINGS_MODULE = "graphite.settings";
|
|
|
|
GRAPHITE_CONF_DIR = configDir;
|
|
|
|
GRAPHITE_STORAGE_DIR = dataDir;
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.python27Packages.waitress}/bin/waitress-serve \
|
|
|
|
--host=${cfg.web.host} --port=${toString cfg.web.port} \
|
|
|
|
--call django.core.handlers.wsgi:WSGIHandler'';
|
|
|
|
User = "graphite";
|
|
|
|
Group = "graphite";
|
|
|
|
PermissionsStartOnly = true;
|
|
|
|
};
|
|
|
|
preStart = ''
|
|
|
|
if ! test -e ${dataDir}/db-created; then
|
|
|
|
mkdir -p ${dataDir}/{whisper/,log/webapp/}
|
|
|
|
chmod 0700 ${dataDir}/{whisper/,log/webapp/}
|
|
|
|
|
|
|
|
# populate database
|
|
|
|
${pkgs.python27Packages.graphite_web}/bin/manage-graphite.py syncdb --noinput
|
|
|
|
|
|
|
|
# create index
|
|
|
|
${pkgs.python27Packages.graphite_web}/bin/build-index.sh
|
|
|
|
|
|
|
|
touch ${dataDir}/db-created
|
|
|
|
|
|
|
|
chown -R graphite:graphite ${cfg.dataDir}
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
2014-09-17 18:31:02 +02:00
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
environment.systemPackages = [ pkgs.python27Packages.graphite_web ];
|
|
|
|
})
|
|
|
|
|
2014-11-02 12:40:00 +01:00
|
|
|
(mkIf cfg.api.enable {
|
2014-10-20 13:27:21 +02:00
|
|
|
systemd.services.graphiteApi = {
|
|
|
|
description = "Graphite Api Interface";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network-interfaces.target" ];
|
|
|
|
environment = {
|
|
|
|
PYTHONPATH =
|
|
|
|
"${cfg.api.package}/lib/python2.7/site-packages:" +
|
|
|
|
concatMapStringsSep ":" (f: f + "/lib/python2.7/site-packages") cfg.api.finders;
|
|
|
|
GRAPHITE_API_CONFIG = graphiteApiConfig;
|
|
|
|
LD_LIBRARY_PATH = "${pkgs.cairo}/lib";
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.python27Packages.waitress}/bin/waitress-serve \
|
|
|
|
--host=${cfg.api.host} --port=${toString cfg.api.port} \
|
2014-11-02 12:40:00 +01:00
|
|
|
graphite_api.app:app
|
2014-10-20 13:27:21 +02:00
|
|
|
'';
|
|
|
|
User = "graphite";
|
|
|
|
Group = "graphite";
|
|
|
|
PermissionsStartOnly = true;
|
|
|
|
};
|
|
|
|
preStart = ''
|
|
|
|
if ! test -e ${dataDir}/db-created; then
|
|
|
|
mkdir -p ${dataDir}/cache/
|
|
|
|
chmod 0700 ${dataDir}/cache/
|
|
|
|
|
|
|
|
touch ${dataDir}/db-created
|
|
|
|
|
|
|
|
chown -R graphite:graphite ${cfg.dataDir}
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.seyren.enable {
|
|
|
|
systemd.services.seyren = {
|
|
|
|
description = "Graphite Alerting Dashboard";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network-interfaces.target" "mongodb.service" ];
|
|
|
|
environment = seyrenConfig;
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.seyren}/bin/seyren -httpPort ${toString cfg.seyren.port}";
|
|
|
|
WorkingDirectory = dataDir;
|
|
|
|
User = "graphite";
|
2014-11-02 12:40:00 +01:00
|
|
|
Group = "graphite";
|
2014-10-20 13:27:21 +02:00
|
|
|
};
|
|
|
|
preStart = ''
|
|
|
|
if ! test -e ${dataDir}/db-created; then
|
|
|
|
mkdir -p ${dataDir}
|
|
|
|
chown -R graphite:graphite ${dataDir}
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
2013-08-11 12:16:19 +02:00
|
|
|
|
2014-10-20 13:27:21 +02:00
|
|
|
services.mongodb.enable = mkDefault true;
|
|
|
|
})
|
|
|
|
|
|
|
|
(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";
|
2014-11-02 12:40:00 +01:00
|
|
|
Group = "graphite";
|
2014-10-20 13:27:21 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.redis.enable = mkDefault true;
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.pythonPackages.graphite_pager ];
|
|
|
|
})
|
|
|
|
|
2015-04-25 15:13:38 +02:00
|
|
|
(mkIf cfg.beacon.enable {
|
|
|
|
systemd.services.graphite-beacon = {
|
|
|
|
description = "Grpahite Beacon Alerting Daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.pythonPackages.graphite_beacon}/bin/graphite-beacon \
|
|
|
|
--config ${pkgs.writeText "graphite-beacon.json" (builtins.toJSON cfg.beacon.config)}
|
|
|
|
'';
|
|
|
|
User = "graphite";
|
|
|
|
Group = "graphite";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
2014-11-04 19:38:24 +01:00
|
|
|
(mkIf (
|
|
|
|
cfg.carbon.enableCache || cfg.carbon.enableAggregator || cfg.carbon.enableRelay ||
|
|
|
|
cfg.web.enable || cfg.api.enable ||
|
2015-04-25 15:13:38 +02:00
|
|
|
cfg.seyren.enable || cfg.pager.enable || cfg.beacon.enable
|
2014-11-04 19:38:24 +01:00
|
|
|
) {
|
|
|
|
users.extraUsers = singleton {
|
|
|
|
name = "graphite";
|
|
|
|
uid = config.ids.uids.graphite;
|
|
|
|
description = "Graphite daemon user";
|
|
|
|
home = dataDir;
|
|
|
|
};
|
|
|
|
users.extraGroups.graphite.gid = config.ids.gids.graphite;
|
|
|
|
})
|
2014-10-20 13:27:21 +02:00
|
|
|
];
|
2013-08-11 12:16:19 +02:00
|
|
|
}
|