Merge pull request #89449 from mmilata/lnd-exporter
nixos/prometheus-lnd-exporter: init
This commit is contained in:
commit
efd8f66119
@ -30,6 +30,7 @@ let
|
||||
"fritzbox"
|
||||
"json"
|
||||
"keylight"
|
||||
"lnd"
|
||||
"mail"
|
||||
"mikrotik"
|
||||
"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 = {
|
||||
exporterConfig = {
|
||||
enable = true;
|
||||
|
22
pkgs/servers/monitoring/prometheus/lnd-exporter.nix
Normal file
22
pkgs/servers/monitoring/prometheus/lnd-exporter.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{ stdenv, buildGoModule, fetchFromGitHub }:
|
||||
|
||||
buildGoModule rec {
|
||||
pname = "lndmon-unstable";
|
||||
version = "2020-01-09";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "lightninglabs";
|
||||
repo = "lndmon";
|
||||
sha256 = "0d4z8yv2459wsi4c91qs5an13acn73fd8s321xya5vxxiyf51q24";
|
||||
rev = "2c7c5ce0fcb4e7eef4df60efe8a644587a309f6c";
|
||||
};
|
||||
|
||||
vendorSha256 = "083h2ksnqmcr48958r5pag9a28xvljpc3prip6wn70ifp2wpjpin";
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
inherit (src.meta) homepage;
|
||||
description = "Prometheus exporter for lnd (Lightning Network Daemon)";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ mmilata ];
|
||||
};
|
||||
}
|
@ -16170,6 +16170,7 @@ in
|
||||
prometheus-haproxy-exporter = callPackage ../servers/monitoring/prometheus/haproxy-exporter.nix { };
|
||||
prometheus-json-exporter = callPackage ../servers/monitoring/prometheus/json-exporter.nix { };
|
||||
prometheus-keylight-exporter = callPackage ../servers/monitoring/prometheus/keylight-exporter.nix { };
|
||||
prometheus-lnd-exporter = callPackage ../servers/monitoring/prometheus/lnd-exporter.nix { };
|
||||
prometheus-mail-exporter = callPackage ../servers/monitoring/prometheus/mail-exporter.nix { };
|
||||
prometheus-mesos-exporter = callPackage ../servers/monitoring/prometheus/mesos-exporter.nix { };
|
||||
prometheus-mikrotik-exporter = callPackage ../servers/monitoring/prometheus/mikrotik-exporter.nix { };
|
||||
|
Loading…
Reference in New Issue
Block a user