Skip to content

Commit 2d12e2a

Browse files
docs: better explain the architecture and more clearly separate docker setup from lndmon setup
1 parent f63626f commit 2d12e2a

File tree

3 files changed

+251
-112
lines changed

3 files changed

+251
-112
lines changed

Docker_Usage.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Docker Compose Setup Instructions for Collecting Data From `lnd` _AND_ `lndmon`
2+
3+
# Table of Contents
4+
1. [Setup](#setup)
5+
1. [Requirements](#requirements)
6+
2. [Lnd](#lnd)
7+
3. [Lndmon](#basic-lndmon-and-docker-compose-setup)
8+
2. [Usage](#usage)
9+
1. [Option 1: Nginx Proxy Usage](#option-1-nginx-proxy-usage-requires-domain-name)
10+
2. [Option 2: Local Usage](#option-2-local-usage)
11+
3. [Customizing Grafana Metrics](#customizing-grafana-metrics)
12+
13+
## Setup
14+
15+
### Requirements
16+
* docker >= 18.09.6
17+
* docker-compose >= 1.24
18+
19+
### Lnd
20+
21+
- You need to have an `lnd` node built with the `monitoring` tag up and running
22+
with ports exposed and reachable.
23+
- Run lnd with
24+
* `prometheus.enable=true`
25+
* `prometheus.listen=<IP>:8989`
26+
* `rpclisten=<IP>`
27+
* `tlsextraip=<IP>`
28+
- Make sure you have the node's reachable IP defined in the cert.
29+
- You may need to delete the existing `tls.cert` and `tls.key` in your lnd
30+
data directory and restart lnd to regenerate the cert.
31+
- Start `lnd` *before* `lndmon`.
32+
33+
34+
Note: See README.md for some additional consideration about the options that
35+
are set above.
36+
37+
38+
### Basic `lndmon` and Docker Compose Setup
39+
40+
- Clone this repo
41+
```
42+
git clone https://github.com/lightninglabs/lndmon
43+
cd lndmon/
44+
```
45+
- In the `.env` file in this repo
46+
* Fill in the `TLS_CERT_PATH` and `MACAROON_PATH` variables relative to the
47+
host filesystem to allow `lndmon` to connect to your `lnd` node.
48+
- By default, `.lnd` lives in your home directory.
49+
* Fill in the `LND_HOST` variable to match your lnd node's IP and port.
50+
* Ensure the other lnd variables are also up-to-date.
51+
* If you wish to run `lndmon` connecting to an `lnd` node on testnet or simnet:
52+
- modify the `LND_NETWORK` variable to match your desired network.
53+
- make sure the `MACAROON_PATH` matches the desired network as well.
54+
- Edit `prometheus.yml` `lnd` `targets` section to match your node's IP.
55+
56+
57+
58+
## Usage
59+
### Option 1: Nginx Proxy Usage (requires domain name)
60+
If you want to enable the built-in nginx proxy feature in order to access your Prometheus and Grafana dashboards remotely, these are the steps:
61+
1. In the `lndmon` repository, edit the `.env` file and fill in the email, FQDN, and (optionally) timezone fields.
62+
2. Ensure ports 80 and 443 on your machine are exposed to the internet.
63+
3. (Optional) Basic auth setup for your Prometheus dashboard:
64+
- Install `apache2-utils` package.
65+
- Run `htpasswd -c nginx/etc/.htpasswd <YOUR_USERNAME>` and follow the prompts to enter and confirm your desired password.
66+
- In `lndmon/nginx/etc/service.conf`, uncomment the lines indicated in the file to enable basic auth.
67+
4. If you want to use your own TLS certs:
68+
- Uncomment the lines beginning with `SSL_` in `.env` and fill in the paths to your cert files.
69+
- Uncomment the lines beginning with `- SSL_` in `docker-compose.nginx.yml`.
70+
5. Start everything up
71+
- `docker-compose -f docker-compose.yml -f docker-compose.nginx.yml up`
72+
- Run this command within the `lndmon` repository directory
73+
- Unless you opted to use your own certs above, this will result in the automatic generation of TLS certificates through Let's Encrypt if they haven't been generated already, or their renewal if the current certs have expired. The certs will automatically renew when they expire.
74+
6. Grafana is located at `https://<YOUR_DOMAIN>/grafana/`
75+
7. Prometheus's expression browser is located at `https://<YOUR_DOMAIN>/prometheus/graph`.
76+
77+
### Option 2: Local Usage
78+
1. Start everything up
79+
- `docker-compose up`
80+
* Run this command within the `lndmon` repository directory
81+
* If you get the error "transport: Error while dialing dial tcp 172.17.0.1:10009: i/o timeout", your docker interface may not have the default IP. Make sure your docker interface's IP matches the IP for `LND_HOST` in `.env` and the lnd target's IP in `prometheus.yml`.
82+
2. Access Grafana dashboard:
83+
- Get Grafana's IP:
84+
- `docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' lndmon_grafana_1`
85+
- Grafana's dashboard is located at `http://<GRAFANA_IP>:3000/`.
86+
- The default password for the admin user is also admin (you can change it after the first login).
87+
3. Access Prometheus expression browser:
88+
- Get Prometheus's IP:
89+
-`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' lndmon_prometheus_1`
90+
- Prometheus's expression browser is located at `http://<PROMETHEUS_IP>:9090/graph`.
91+
92+
93+
### Customizing Grafana Metrics
94+
`lndmon`'s Grafana instance comes with a set of basic dashboards. Add additional dashboards by clicking the `+' sign on the left.

INSTALL.md

Lines changed: 0 additions & 88 deletions
This file was deleted.

README.md

Lines changed: 157 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,117 @@
11
# lndmon
22

3-
#### A drop-in monitoring solution for your lnd node using Prometheus and Grafana.
3+
#### A drop-in monitoring solution for your lnd node that integrates with Prometheus and Grafana.
44

55
<img src="dashboard.png">
66

77
## What is this?
88

9-
`lndmon` is a drop-in, dockerized monitoring/metric collection solution for your
10-
individual lnd nodes connected to bitcoin. With this system, you'll be able to
11-
closely monitor the health and status of your `lnd` node.
9+
`lndmon` is a drop-in, monitoring/metric collection solution for your
10+
individual lnd nodes connected to bitcoin which allows you to closely monitor
11+
the health and status of your `lnd` node.
1212

13-
There are three primary components of the `lndmon` system:
13+
There are four primary components of this monitoring system:
1414

1515
1. [lnd](https://github.com/lightningnetwork/lnd) built with the `monitoring`
16-
tag, which enables lnd to export metrics about its gRPC performance and
17-
usage. These metrics provide insights such as how many bytes lnd is
18-
transmitting over gRPC, whether any calls are taking a long time to complete,
19-
and other related statistics.
20-
21-
2. `lndmon`: while lnd provides some information, `lndmon` by far does the heavy
22-
lifting with regards to metrics. With `lndmon`'s data, you can track routing
23-
fees over time, track how the channel graph evolves, and have a highly
24-
configurable "crystal ball" to forecast and de-escalate potential issues as
25-
the network changes over time. There is also a strong set of metrics for
26-
users who want to keep track of their own node and channels, or just explore
27-
and create their own lightning data visualizations.
28-
29-
3. Last but not least, `lndmon` uses [Grafana](https://grafana.com/) as its
16+
tag, which enables lnd to export metrics about its gRPC performance and
17+
usage.
18+
- These metrics provide insights such as how many bytes lnd is transmitting
19+
over gRPC, whether any calls are taking a long time to complete, and other
20+
related statistics.
21+
- `lnd` build notes:
22+
* If you are using a release build of `lnd` or `litd`, this was enabled
23+
during build and no action is required.
24+
* If you are building from source, make sure to include the `monitoring`
25+
tag (i.e. `make && make install tags=monitoring`)
26+
- Default `lnd` config options:
27+
* `prometheus.enable=false`
28+
- Need to change to `true` to enable.
29+
* `prometheus.listen=127.0.0.1:8989`
30+
- You may want to change to `0.0.0.0:8989` to listen on all interfaces.
31+
* `prometheus.perfhistograms=false`
32+
- Enabling this uses more RAM and disk space.
33+
- Note: This data can be obtained from `lnd` without `lndmon` being
34+
installed.
35+
36+
2. `lndmon`: while lnd provides some information about gRPC performance
37+
statistics directly via its own prometheus exporter, `lndmon` by far does
38+
the heavy lifting with regards to metrics.
39+
- With `lndmon`'s data, you can track routing fees over time, track how the
40+
channel graph evolves, and have a highly configurable "crystal ball" to
41+
forecast and de-escalate potential issues as the network changes over time.
42+
- There is also a strong set of metrics for users who want to keep track of
43+
their own node and channels, or just explore and create their own
44+
lightning data visualizations.
45+
- See [Options](#options) below for `lndmon` config options.
46+
- Note: This data can be obtained without lnd being built with the
47+
`monitoring` tag and without the `prometheus.enable` config option enabled,
48+
but it does require `lnd` to be listening for gRPC connections.
49+
50+
3. Prometheus is a time series database that scrapes data from `lnd` and
51+
`lndmon` and stores it for later analysis.
52+
53+
4. `lndmon` uses [Grafana](https://grafana.com/) as its
3054
primary dashboard to display all its collected metrics. Grafana is highly
3155
configurable and can create beautiful and detailed graphs organized by
3256
category (i.e., chain-related graphs, fee-related graphs, etc). Users have
3357
the option of making their Grafana dashboards remotely accessible over TLS
3458
with passwords to ensure their data is kept private.
3559

60+
61+
# Architectural Layout
62+
```mermaid
63+
---
64+
config:
65+
flowchart:
66+
subGraphTitleMargin:
67+
bottom: 30
68+
---
69+
flowchart
70+
subgraph s1["**LND**"]
71+
n15@{ shape: "stadium", label: "gRPC Server \n(TCP/10009)" }
72+
n20@{ shape: "stadium", label: "Prometheus Exporter \n (TCP/8989) " }
73+
end
74+
s1
75+
76+
n15
77+
subgraph s2["**LNDmon**
78+
(aggregate, cache)"]
79+
80+
n17@{ shape: "stadium", label: "Prometheus Exporter \n (TCP/9092)" }
81+
n16@{ shape: "stadium", label: "gRPC Client \n (TCP/9090)" }
82+
end
83+
n16@{ shape: "stadium", label: "gRPC Client<br>(TCP/9090)" }
84+
n21@{ shape: "fr-rect", label: "gRPC Performance Stats" }
85+
n20@{ shape: "stadium", label: "Prometheus Exporter<br>(TCP/8989)" } --- n21
86+
subgraph s3["**Prometheus**<br/>(time series DB)"]
87+
n23@{ shape: "stadium", label: "HTTP Server" }
88+
n22@{ shape: "stadium", label: "Prometheus Scraper" }
89+
end
90+
n21 --- n22
91+
n7@{ shape: "fr-rect", label: "gRPC Call Data" }
92+
n17@{ shape: "stadium", label: "Prometheus Exporter<br>(TCP/9092)" } --- n7
93+
n7 --- n22
94+
subgraph s4["**Grafana**<br/>(dashboard generation)"]
95+
n25@{ shape: "stadium", label: "HTTP Server" }
96+
n24@{ shape: "stadium", label: "HTTP Client" }
97+
end
98+
subgraph s5["**Firefox**<br/>(dashboard display)"]
99+
n26@{ shape: "stadium", label: "HTTP Client" }
100+
end
101+
n23@{ shape: "stadium", label: "HTTP Server<br>(TCP/9090)" } --- n24
102+
n25@{ shape: "stadium", label: "HTTP Server<br>(TCP/3000)" } --- n26
103+
n15 --- n16@{ shape: "stadium", label: "gRPC Client" }
104+
s1
105+
n21
106+
n22 --- n23
107+
n24 --- n25
108+
n16 --- n17
109+
```
110+
111+
112+
113+
114+
36115
## Why would I want to use this?
37116

38117
Monitoring can provide crucial insights into the health of large-scale
@@ -46,9 +125,63 @@ ecosystem (i.e., "wow, the day [Lightning
46125
App](https://github.com/lightninglabs/lightning-app) was released coincides with
47126
the addition of 3000 channels to the network!").
48127

49-
## How do I install this?
50128

51-
Head over to [`INSTALL.md`](https://github.com/lightninglabs/lndmon/blob/master/INSTALL.md). It
52-
also includes instructions to set up, access, and password-protect the dashboard
53-
that comes with Prometheus, called the Prometheus expression browser, for those
54-
interested in using it.
129+
## Build
130+
131+
```
132+
git clone https://github.com/lightninglabs/lndmon
133+
cd lndmon/cmd/lndmon
134+
go build
135+
```
136+
137+
## Options
138+
139+
```
140+
$ lndmon -h
141+
Usage:
142+
lndmon [OPTIONS]
143+
144+
Application Options:
145+
--primarynode= Public key of the primary node in a primary-gateway setup
146+
--disablegraph Do not collect graph metrics
147+
--disablehtlc Do not collect HTLCs metrics
148+
--disablepayments Do not collect payments metrics
149+
150+
prometheus:
151+
--prometheus.listenaddr= the interface we should listen on for prometheus (default:
152+
localhost:9092)
153+
--prometheus.logdir= Directory to log output (default: /home/user/.lndmon/logs)
154+
--prometheus.maxlogfiles= Maximum log files to keep (0 for no rotation) (default: 3)
155+
--prometheus.maxlogfilesize= Maximum log file size in MB (default: 10)
156+
157+
lnd:
158+
--lnd.host= lnd instance rpc address (default: localhost:10009)
159+
--lnd.network=[regtest|testnet|testnet4|mainnet|simnet|signet] network to run on (default: mainnet)
160+
--lnd.macaroondir= Path to lnd macaroons (default: /home/user/.lnd)
161+
--lnd.macaroonname= The name of our macaroon in macaroon dir to use. (default:
162+
readonly.macaroon)
163+
--lnd.rpctimeout= The timeout for rpc calls to lnd. Valid time units are {s,
164+
m, h}. (default: 30s)
165+
--lnd.tlspath= Path to lnd tls certificate
166+
167+
Help Options:
168+
-h, --help Show this help message
169+
```
170+
171+
172+
173+
174+
175+
176+
177+
178+
179+
180+
181+
## How do I use this?
182+
183+
Head over to [`Docker_Usage.md`](https://github.com/lightninglabs/lndmon/blob/master/Docker_Usage.md)
184+
for information on how to setup a dockerized version. It also includes
185+
instructions to set up, access, and password-protect the dashboard that comes
186+
with Prometheus, called the "Prometheus Expression Browser", for those interested
187+
in using it.

0 commit comments

Comments
 (0)