This application will query a Lightning Node (LND Rest API) and push all metrics into an InfluxDB which can be used as a data source for Grafana Dashboards similar to the popular Telegraf agent.
The RaspiBolt project served as motivation for setting this up. If you're looking to run this on a Raspberry Pi that was setup using the guide above click here
- list_channels
- tags:
- host
- remote_alias
- fields:
- active
- capacity
- local_balance
- remote_balance
- unsettled_balance
- total_satoshis_received
- total_satoshis_sent
- commit_fee
- commit_weight
- fee_per_kw
- num_updates
- tags:
- pending_open_channels
- tags:
- host
- remote_alias
- fields:
- capacity
- local_balance
- remote_balance
- commit_fee
- commit_weight
- fee_per_kw
- tags:
- forced_closed_channels
- tags:
- host
- remote_node_pub
- fields:
- capacity
- remote_balance
- local_balance
- blocks_til_maturity
- limbo_balance
- maturity_height
- recovered_balance
- tags:
- pending_htlcs (as child of forced_closed_channels)
- tags:
- closing_txid
- fields:
- Amount
- Stage
- Outpoint
- Blocks_til_maturity
- Maturity_height
- tags:
- channel_balance
- tags:
- host
- fields:
- balance
- pending_open_balance
- tags:
- balance
- tags:
- host
- fields:
- confirmed_balance
- total_balance
- unconfirmed_balance
- tags:
- networkinfo
- tags:
- host
- fields:
- max_channel_size
- min_channel_size
- total_network_capacity
- avg_channel_size
- avg_out_degree
- num_channels
- num_nodes
- graph_diameter
- max_out_degree
- tags:
- recommended_onchain_fees
- tags:
- host
- fields:
- fastestFee
- halfHourFee
- hourFee
- tags:
The application is compiled as lnd-metrics.exe
and uses the LND Rest API which
requires the following configuration in the lnd.conf
file.
[Application Options]
tlsextraip=0.0.0.0
restlisten=0.0.0.0:8080
The tlsextraip
is required if you plan on running the application on different machine to where the Lightning Network Daemon ️is running.
When adding the
tlsextraip
setting you may need to regenerate the tls.cert, tls.key and macaroon files. To test it's all working access the/v1/getinfo
endpoint, e.g. https://192.168.1.40:8080/v1/getinfo. You should see{"error":"expected 1 macaroon, got 0","code":2}
as the response.
Your Lightning Wallet needs to be unlocked for the LND REST API to return any data.
lnd-metrics.exe
--influxDbUri http://192.168.1.40:8086
--network testnet
--lndRestApiUri https://192.168.1.40:8080
--certThumbprintHex "long hex string"
--macaroonHex "long hashed string"
To view all the options run
lnd-metrics.exe --help
On a Linux machine execute at the location where your macaroon files are, e.g. for testnet /home/bitcoin/.lnd/data/chain/bitcoin/testnet
xxd -p admin.macaroon | tr -d '\n' && echo " "
On a Linux machine execute at the location where you certificate files are, e.g. /home/bitcoin/.lnd
openssl x509 -noout -fingerprint -sha256 -inform pem -in tls.cert
docker run badokun/lnd-metrics:latest --help
docker run badokun/lnd-metrics:arm32 --help
docker build -t lnd-metrics:arm32 -f arm32.generic.Dockerfile .
docker tag lnd-metrics:arm32 badokun/lnd-metrics:arm32
docker push badokun/lnd-metrics:arm32
docker build -t lnd-metrics:arm32 -f arm32.on.raspberry.Dockerfile .
docker tag lnd-metrics:arm32 badokun/lnd-metrics:arm32
docker push badokun/lnd-metrics:arm32
docker build -t lnd-metrics:latest -f Dockerfile .
docker tag lnd-metrics:latest badokun/lnd-metrics:latest
docker push badokun/lnd-metrics:latest
- Bump the release version in Lightning.Metrics.App.csproj
- Run
powershell ./publish-docker.ps1
which will create git tags and push to GitHub. - Docker images are automatically built
Get some free testnet bitcoins at https://lnroute.com/testnet-faucets/
- Lnd Rest Api
- Setting the
tlsextraip
to0.0.0.0
was suggested here - Lnd configuration reference
Donations
If you feel like this has been useful and wish to donate, feel free to send a satoshi or two to this address, obviously use Lightning for near free instant transfers:
- 👉 BTC:
bc1qx2hn38vc8f0fkn3hu8pmpuglg35ctqvx2rzzjs
- 👉 Lightning: https://tippin.me/@rubberroad