2020-10-02 22:18:34 +00:00
|
|
|
# Prometheus configuration for a BIRD-enabled router.
|
|
|
|
|
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
nodeExporterPort = 9100;
|
|
|
|
birdExporterPort = 9101;
|
|
|
|
|
|
|
|
birdExporter = pkgs.buildGoModule rec {
|
|
|
|
pname = "bird-exporter";
|
2021-07-19 20:11:08 +00:00
|
|
|
version = "1.2.6";
|
2020-10-02 22:18:34 +00:00
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "czerwonk";
|
|
|
|
repo = "bird_exporter";
|
|
|
|
rev = version;
|
2021-07-19 20:11:08 +00:00
|
|
|
sha256 = "1yqizzlvwyxlrd2priqd1jx9s87yvsypqkmk81dacm1ra4xrs0nd";
|
2020-10-02 22:18:34 +00:00
|
|
|
};
|
|
|
|
|
2021-07-19 20:11:08 +00:00
|
|
|
vendorSha256 = "0wczj3g0c917hwjkz23xg5blb4z5a04v3wbx6kg0wfyb09c9bwx3";
|
2020-10-02 22:18:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in {
|
|
|
|
systemd.services.bird_exporter = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = "${birdExporter}/bin/bird_exporter -format.new=true -bird.v2=true -web.listen-address=127.0.0.1:${toString birdExporterPort}";
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "60";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.prometheus.exporters.node = {
|
|
|
|
enable = true;
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
port = nodeExporterPort;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.enable = true;
|
|
|
|
services.nginx.virtualHosts."${config.networking.hostName}.${config.networking.domain}" = let
|
|
|
|
allowMonitoring = ''
|
|
|
|
allow 209.250.231.127; # monitoring.hackerspace.pl
|
|
|
|
deny all;
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
locations."/metrics-node" = {
|
|
|
|
proxyPass = "http://127.0.0.1:${toString nodeExporterPort}/metrics";
|
|
|
|
extraConfig = allowMonitoring;
|
|
|
|
};
|
|
|
|
locations."/metrics-bird" = {
|
|
|
|
proxyPass = "http://127.0.0.1:${toString birdExporterPort}/metrics";
|
|
|
|
extraConfig = allowMonitoring;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|