Skip to content

Commit 46900fe

Browse files
author
macgyver13
committed
Add lnd exporter test data
Extend lnd pod template with extraContainers
1 parent 296e0ba commit 46900fe

File tree

6 files changed

+112
-29
lines changed

6 files changed

+112
-29
lines changed

docs/logging_monitoring.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ outbounds 0.0
116116
mempool_size 0.0
117117
```
118118
119+
### Defining lnd metrics to capture
120+
121+
Lightning nodes can also be configured to export metrics to prometheus using `lnd-exporter`.
122+
Example configuration is provided in `test/data/ln/`. Review `node-defauts.yaml` for a typical logging configuration. All default metrics reported to prometheus are prefixed with `lnd_`
123+
lnd-exporter
124+
125+
[lnd-exporter configuration reference](https://github.com/macgyver13/lnd-exporter/tree/main?tab=readme-ov-file#configuration)
126+
lnd-exporter assumes same macarroon referenced in ln_framework (can be overridden by env variable)
127+
128+
**Note: `test/data/ln` takes advantage of **extraContainers** configuration option to add containers to default `lnd/templates/pod`*
129+
119130
### Grafana
120131
121132
Data from Prometheus exporters is collected and fed into Grafana for a

resources/charts/bitcoincore/charts/lnd/templates/pod.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ spec:
5656
- mountPath: /root/.lnd/tls.cert
5757
name: config
5858
subPath: tls.cert
59-
{{- if .Values.circuitBreaker }}
60-
- name: circuitbreaker
61-
image: pinheadmz/circuitbreaker:278737d
62-
imagePullPolicy: IfNotPresent
63-
{{- end}}
59+
{{- with .Values.extraContainers }}
60+
{{- toYaml . | nindent 4 }}
61+
{{- end }}
6462
volumes:
6563
{{- with .Values.volumes }}
6664
{{- toYaml . | nindent 4 }}

resources/charts/bitcoincore/charts/lnd/templates/service.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@ spec:
2020
targetPort: rest
2121
protocol: TCP
2222
name: rest
23+
{{- if .Values.metricsExport }}
24+
- port: {{ .Values.prometheusMetricsPort }}
25+
targetPort: prom-metrics
26+
protocol: TCP
27+
name: prometheus-metrics
28+
{{- end }}
2329
selector:
2430
{{- include "lnd.selectorLabels" . | nindent 4 }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.metricsExport }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
name: {{ include "lnd.fullname" . }}
6+
labels:
7+
app.kubernetes.io/name: lnd-metrics
8+
release: prometheus
9+
spec:
10+
endpoints:
11+
- port: prometheus-metrics
12+
selector:
13+
matchLabels:
14+
app: {{ include "lnd.fullname" . }}
15+
{{- end }}

test/data/ln/network.yaml

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,46 @@ nodes:
22
- name: tank-0000
33
addnode:
44
- tank-0001
5-
ln:
6-
lnd: true
7-
5+
- tank-0002
6+
lnd:
7+
channels:
8+
- id:
9+
block: 300
10+
index: 6
11+
target: tank-0001-ln
12+
capacity: 100000
13+
push_amt: 50000
814
- name: tank-0001
915
addnode:
10-
- tank-0002
11-
ln:
12-
lnd: true
13-
16+
- tank-0000
17+
lnd:
18+
channels:
19+
- id:
20+
block: 300
21+
index: 5
22+
target: tank-0000-ln
23+
capacity: 50000
24+
push_amt: 25000
25+
- id:
26+
block: 300
27+
index: 4
28+
target: tank-0002-ln
29+
capacity: 100000
30+
push_amt: 50000
1431
- name: tank-0002
1532
addnode:
16-
- tank-0000
17-
ln:
18-
lnd: true
19-
33+
- tank-0001
34+
lnd:
35+
channels:
36+
- id:
37+
block: 300
38+
index: 2
39+
target: tank-0001-ln
40+
capacity: 50000
41+
push_amt: 25000
2042
- name: tank-0003
2143
addnode:
22-
- tank-0000
23-
ln:
24-
lnd: true
44+
- tank-0002
2545
lnd:
2646
config: |
2747
bitcoin.timelockdelta=33
@@ -32,23 +52,25 @@ nodes:
3252
target: tank-0004-ln
3353
capacity: 100000
3454
push_amt: 50000
35-
3655
- name: tank-0004
3756
addnode:
3857
- tank-0000
39-
ln:
40-
lnd: true
4158
lnd:
4259
channels:
4360
- id:
4461
block: 300
45-
index: 2
62+
index: 3
4663
target: tank-0005-ln
4764
capacity: 50000
4865
push_amt: 25000
49-
5066
- name: tank-0005
5167
addnode:
52-
- tank-0000
53-
ln:
54-
lnd: true
68+
- tank-0004
69+
plugins:
70+
postDeploy:
71+
simln:
72+
entrypoint: "../../../resources/plugins/simln" # This is the path to the simln plugin folder (relative to the network.yaml file).
73+
activity: >
74+
[{"source": "tank-0002-ln", "destination": "tank-0000-ln", "interval_secs": 1, "amount_msat": 400000},
75+
{"source": "tank-0000-ln", "destination": "tank-0001-ln", "interval_secs": 1, "amount_msat": 200000},
76+
{"source": "tank-0001-ln", "destination": "tank-0002-ln", "interval_secs": 1, "amount_msat": 20000}]

test/data/ln/node-defaults.yaml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1+
caddy:
2+
enabled: true
3+
4+
#Core configs
15
image:
26
repository: bitcoindevproject/bitcoin
37
pullPolicy: IfNotPresent
4-
tag: "27.0"
8+
tag: '27.0'
9+
collectLogs: true
10+
metricsExport: true
511

12+
#LN configs
13+
ln:
14+
lnd: true
615
lnd:
716
defaultConfig: |
8-
color=#000000
17+
color=#000000
18+
config: |
19+
bitcoin.timelockdelta=33
20+
metricsExport: true
21+
prometheusMetricsPort: 9332
22+
extraContainers:
23+
- name: lnd-exporter
24+
image: bitdonkey/lnd-exporter:0.1.1
25+
imagePullPolicy: IfNotPresent
26+
env:
27+
- name: ADMIN_MACAROON_HEX
28+
value: 0201036c6e6402f801030a1062beabbf2a614b112128afa0c0b4fdd61201301a160a0761646472657373120472656164120577726974651a130a04696e666f120472656164120577726974651a170a08696e766f69636573120472656164120577726974651a210a086d616361726f6f6e120867656e6572617465120472656164120577726974651a160a076d657373616765120472656164120577726974651a170a086f6666636861696e120472656164120577726974651a160a076f6e636861696e120472656164120577726974651a140a057065657273120472656164120577726974651a180a067369676e6572120867656e657261746512047265616400000620b17be53e367290871681055d0de15587f6d1cd47d1248fe2662ae27f62cfbdc6
29+
- name: METRICS
30+
value: >
31+
lnd_balance_channels=parse("/v1/balance/channels","balance")
32+
lnd_local_balance_channels=parse("/v1/balance/channels","local_balance.sat")
33+
lnd_remote_balance_channels=parse("/v1/balance/channels","remote_balance.sat")
34+
lnd_block_height=parse("/v1/getinfo","block_height")
35+
lnd_peers=parse("/v1/getinfo","num_peers")
36+
ports:
37+
- name: prom-metrics
38+
containerPort: 9332
39+
protocol: TCP

0 commit comments

Comments
 (0)