Skip to content

Enable lnd pod logging #691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/logging_monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ outbounds 0.0
mempool_size 0.0
```

### Defining lnd metrics to capture

Lightning nodes can also be configured to export metrics to prometheus using `lnd-exporter`.
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_`
lnd-exporter

[lnd-exporter configuration reference](https://github.com/macgyver13/lnd-exporter/tree/main?tab=readme-ov-file#configuration)
lnd-exporter assumes same macarroon referenced in ln_framework (can be overridden by env variable)

**Note: `test/data/ln` takes advantage of **extraContainers** configuration option to add containers to default `lnd/templates/pod`*

### Grafana

Data from Prometheus exporters is collected and fed into Grafana for a
Expand Down
10 changes: 5 additions & 5 deletions resources/charts/bitcoincore/charts/lnd/templates/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ metadata:
collect_logs: "true"
{{- end }}
chain: {{ .Values.global.chain }}
annotations:
kubectl.kubernetes.io/default-container: "lnd"
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -56,11 +58,9 @@ spec:
- mountPath: /root/.lnd/tls.cert
name: config
subPath: tls.cert
{{- if .Values.circuitBreaker }}
- name: circuitbreaker
image: pinheadmz/circuitbreaker:278737d
imagePullPolicy: IfNotPresent
{{- end}}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 4 }}
{{- end }}
volumes:
{{- with .Values.volumes }}
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ spec:
targetPort: rest
protocol: TCP
name: rest
{{- if .Values.metricsExport }}
- port: {{ .Values.prometheusMetricsPort }}
targetPort: prom-metrics
protocol: TCP
name: prometheus-metrics
{{- end }}
selector:
{{- include "lnd.selectorLabels" . | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.metricsExport }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "lnd.fullname" . }}
labels:
app.kubernetes.io/name: lnd-metrics
release: prometheus
spec:
endpoints:
- port: prometheus-metrics
selector:
matchLabels:
app: {{ include "lnd.fullname" . }}
{{- end }}
58 changes: 36 additions & 22 deletions test/data/ln/network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,46 @@ nodes:
- name: tank-0000
addnode:
- tank-0001
ln:
lnd: true

- tank-0002
lnd:
channels:
- id:
block: 300
index: 6
target: tank-0001-ln
capacity: 100000
push_amt: 50000
- name: tank-0001
addnode:
- tank-0002
ln:
lnd: true

- tank-0000
lnd:
channels:
- id:
block: 300
index: 5
target: tank-0000-ln
capacity: 50000
push_amt: 25000
- id:
block: 300
index: 4
target: tank-0002-ln
capacity: 100000
push_amt: 50000
- name: tank-0002
addnode:
- tank-0000
ln:
lnd: true

- tank-0001
lnd:
channels:
- id:
block: 300
index: 2
target: tank-0001-ln
capacity: 50000
push_amt: 25000
- name: tank-0003
addnode:
- tank-0000
ln:
lnd: true
- tank-0002
lnd:
config: |
bitcoin.timelockdelta=33
Expand All @@ -32,23 +52,17 @@ nodes:
target: tank-0004-ln
capacity: 100000
push_amt: 50000

- name: tank-0004
addnode:
- tank-0000
ln:
lnd: true
lnd:
channels:
- id:
block: 300
index: 2
index: 3
target: tank-0005-ln
capacity: 50000
push_amt: 25000

- name: tank-0005
addnode:
- tank-0000
ln:
lnd: true
- tank-0004
35 changes: 33 additions & 2 deletions test/data/ln/node-defaults.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
caddy:
enabled: true

#Core configs
image:
repository: bitcoindevproject/bitcoin
pullPolicy: IfNotPresent
tag: "27.0"
tag: '27.0'
collectLogs: false
metricsExport: false

#LN configs
ln:
lnd: true
lnd:
defaultConfig: |
color=#000000
color=#000000
config: |
bitcoin.timelockdelta=33
metricsExport: false
prometheusMetricsPort: 9332
extraContainers:
- name: lnd-exporter
image: bitdonkey/lnd-exporter:0.1.1
imagePullPolicy: IfNotPresent
env:
- name: ADMIN_MACAROON_HEX
value: 0201036c6e6402f801030a1062beabbf2a614b112128afa0c0b4fdd61201301a160a0761646472657373120472656164120577726974651a130a04696e666f120472656164120577726974651a170a08696e766f69636573120472656164120577726974651a210a086d616361726f6f6e120867656e6572617465120472656164120577726974651a160a076d657373616765120472656164120577726974651a170a086f6666636861696e120472656164120577726974651a160a076f6e636861696e120472656164120577726974651a140a057065657273120472656164120577726974651a180a067369676e6572120867656e657261746512047265616400000620b17be53e367290871681055d0de15587f6d1cd47d1248fe2662ae27f62cfbdc6
- name: METRICS
value: >
lnd_balance_channels=parse("/v1/balance/channels","balance")
lnd_local_balance_channels=parse("/v1/balance/channels","local_balance.sat")
lnd_remote_balance_channels=parse("/v1/balance/channels","remote_balance.sat")
lnd_block_height=parse("/v1/getinfo","block_height")
lnd_peers=parse("/v1/getinfo","num_peers")
ports:
- name: prom-metrics
containerPort: 9332
protocol: TCP
Loading