nixos/prometheus-lnd-exporter: init
This commit is contained in:
parent
0a5eab2692
commit
876bf3abc9
@ -30,6 +30,7 @@ let
|
|||||||
"fritzbox"
|
"fritzbox"
|
||||||
"json"
|
"json"
|
||||||
"keylight"
|
"keylight"
|
||||||
|
"lnd"
|
||||||
"mail"
|
"mail"
|
||||||
"mikrotik"
|
"mikrotik"
|
||||||
"minio"
|
"minio"
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
{ config, lib, pkgs, options }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.prometheus.exporters.lnd;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
port = 9092;
|
||||||
|
extraOpts = {
|
||||||
|
lndHost = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "localhost:10009";
|
||||||
|
description = ''
|
||||||
|
lnd instance gRPC address:port.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
lndTlsPath = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
description = ''
|
||||||
|
Path to lnd TLS certificate.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
lndMacaroonDir = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
description = ''
|
||||||
|
Path to lnd macaroons.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
serviceOpts.serviceConfig = {
|
||||||
|
ExecStart = ''
|
||||||
|
${pkgs.prometheus-lnd-exporter}/bin/lndmon \
|
||||||
|
--prometheus.listenaddr=${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
--prometheus.logdir=/var/log/prometheus-lnd-exporter \
|
||||||
|
--lnd.host=${cfg.lndHost} \
|
||||||
|
--lnd.tlspath=${cfg.lndTlsPath} \
|
||||||
|
--lnd.macaroondir=${cfg.lndMacaroonDir} \
|
||||||
|
${concatStringsSep " \\\n " cfg.extraFlags}
|
||||||
|
'';
|
||||||
|
LogsDirectory = "prometheus-lnd-exporter";
|
||||||
|
ReadOnlyPaths = [ cfg.lndTlsPath cfg.lndMacaroonDir ];
|
||||||
|
};
|
||||||
|
}
|
@ -236,6 +236,50 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lnd = {
|
||||||
|
exporterConfig = {
|
||||||
|
enable = true;
|
||||||
|
lndTlsPath = "/var/lib/lnd/tls.cert";
|
||||||
|
lndMacaroonDir = "/var/lib/lnd";
|
||||||
|
};
|
||||||
|
metricProvider = {
|
||||||
|
systemd.services.prometheus-lnd-exporter.serviceConfig.DynamicUser = false;
|
||||||
|
services.bitcoind.enable = true;
|
||||||
|
services.bitcoind.extraConfig = ''
|
||||||
|
rpcauth=bitcoinrpc:e8fe33f797e698ac258c16c8d7aadfbe$872bdb8f4d787367c26bcfd75e6c23c4f19d44a69f5d1ad329e5adf3f82710f7
|
||||||
|
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
|
||||||
|
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
|
||||||
|
'';
|
||||||
|
systemd.services.lnd = {
|
||||||
|
serviceConfig.ExecStart = ''
|
||||||
|
${pkgs.lnd}/bin/lnd \
|
||||||
|
--datadir=/var/lib/lnd \
|
||||||
|
--tlscertpath=/var/lib/lnd/tls.cert \
|
||||||
|
--tlskeypath=/var/lib/lnd/tls.key \
|
||||||
|
--logdir=/var/log/lnd \
|
||||||
|
--bitcoin.active \
|
||||||
|
--bitcoin.mainnet \
|
||||||
|
--bitcoin.node=bitcoind \
|
||||||
|
--bitcoind.rpcuser=bitcoinrpc \
|
||||||
|
--bitcoind.rpcpass=hunter2 \
|
||||||
|
--bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332 \
|
||||||
|
--bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333 \
|
||||||
|
--readonlymacaroonpath=/var/lib/lnd/readonly.macaroon
|
||||||
|
'';
|
||||||
|
serviceConfig.StateDirectory = "lnd";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
exporterTest = ''
|
||||||
|
wait_for_unit("lnd.service")
|
||||||
|
wait_for_open_port(10009)
|
||||||
|
wait_for_unit("prometheus-lnd-exporter.service")
|
||||||
|
wait_for_open_port(9092)
|
||||||
|
succeed("curl -sSf localhost:9092/metrics | grep -q '^promhttp_metric_handler'")
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
mail = {
|
mail = {
|
||||||
exporterConfig = {
|
exporterConfig = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user