2017-01-30 21:56:43 +00:00
|
|
|
{pkgs, config, ...}:
|
|
|
|
with import <stockholm/lib>;
|
|
|
|
{
|
2017-02-04 23:25:39 +00:00
|
|
|
services.influxdb.enable = true;
|
2017-01-30 21:56:43 +00:00
|
|
|
|
|
|
|
services.influxdb.extraConfig = {
|
|
|
|
meta.hostname = config.krebs.build.host.name;
|
|
|
|
# meta.logging-enabled = true;
|
|
|
|
http.bind-address = ":8086";
|
|
|
|
admin.bind-address = ":8083";
|
2017-02-07 16:11:30 +00:00
|
|
|
http.log-enabled = false;
|
2017-01-30 21:56:43 +00:00
|
|
|
monitoring = {
|
|
|
|
enabled = false;
|
|
|
|
# write-interval = "24h";
|
|
|
|
};
|
2017-02-02 23:23:00 +00:00
|
|
|
collectd = [{
|
|
|
|
enabled = true;
|
|
|
|
typesdb = "${pkgs.collectd}/share/collectd/types.db";
|
|
|
|
database = "collectd_db";
|
|
|
|
port = 25826;
|
|
|
|
}];
|
2017-01-30 21:56:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
lass.kapacitor =
|
|
|
|
let
|
2017-02-07 16:10:34 +00:00
|
|
|
db = "telegraf_db";
|
2017-01-30 21:56:43 +00:00
|
|
|
echoToIrc = pkgs.writeDash "echo_irc" ''
|
|
|
|
set -euf
|
|
|
|
data="$(${pkgs.jq}/bin/jq -r .message)"
|
|
|
|
export LOGNAME=prism-alarm
|
|
|
|
${pkgs.irc-announce}/bin/irc-announce \
|
2017-02-04 23:25:39 +00:00
|
|
|
ni.r 6667 prism-alarm \#retiolum "$data" >/dev/null
|
2017-01-30 21:56:43 +00:00
|
|
|
'';
|
|
|
|
in {
|
|
|
|
enable = true;
|
|
|
|
alarms = {
|
2017-02-07 16:10:34 +00:00
|
|
|
cpu = {
|
|
|
|
database = db;
|
|
|
|
text = ''
|
|
|
|
var data = batch
|
|
|
|
|query(${"'''"}
|
|
|
|
SELECT mean("usage_user") AS mean
|
|
|
|
FROM "${db}"."default"."cpu"
|
|
|
|
${"'''"})
|
|
|
|
.period(10m)
|
|
|
|
.every(1m)
|
|
|
|
.groupBy('host')
|
|
|
|
data |alert()
|
|
|
|
.crit(lambda: "mean" > 90)
|
|
|
|
.exec('${echoToIrc}')
|
|
|
|
data |deadman(1.0,5m)
|
|
|
|
.stateChangesOnly()
|
|
|
|
.exec('${echoToIrc}')
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
ram = {
|
|
|
|
database = db;
|
|
|
|
text = ''
|
|
|
|
var data = batch
|
|
|
|
|query(${"'''"}
|
|
|
|
SELECT mean("used_percent") AS mean
|
|
|
|
FROM "${db}"."default"."mem"
|
|
|
|
${"'''"})
|
|
|
|
.period(10m)
|
|
|
|
.every(1m)
|
|
|
|
.groupBy('host')
|
|
|
|
data |alert()
|
|
|
|
.crit(lambda: "mean" > 90)
|
|
|
|
.exec('${echoToIrc}')
|
|
|
|
'';
|
|
|
|
};
|
2017-01-30 21:56:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.grafana = {
|
|
|
|
enable = true;
|
|
|
|
addr = "0.0.0.0";
|
|
|
|
auth.anonymous.enable = true;
|
|
|
|
security = import <secrets/grafana_security.nix>; # { AdminUser = ""; adminPassword = ""}
|
|
|
|
};
|
2017-02-07 16:12:21 +00:00
|
|
|
|
|
|
|
services.elasticsearch = {
|
|
|
|
enable = true;
|
|
|
|
listenAddress = "0.0.0.0";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.kibana = {
|
|
|
|
enable = true;
|
|
|
|
listenAddress = "0.0.0.0";
|
|
|
|
};
|
|
|
|
|
|
|
|
krebs.iptables.tables.filter.INPUT.rules = [
|
|
|
|
{ predicate = "-p tcp -i retiolum --dport 8086"; target = "ACCEPT"; }
|
|
|
|
{ predicate = "-p tcp -i retiolum --dport 3000"; target = "ACCEPT"; }
|
|
|
|
{ predicate = "-p udp -i retiolum --dport 25826"; target = "ACCEPT"; }
|
|
|
|
{ predicate = "-p tcp -i retiolum --dport 9200"; target = "ACCEPT"; }
|
|
|
|
{ predicate = "-p tcp -i retiolum --dport 5601"; target = "ACCEPT"; }
|
|
|
|
];
|
2017-01-30 21:56:43 +00:00
|
|
|
}
|