Skip to content

Conversation

@Jontified
Copy link
Contributor

Summary: This PR adds support for tracking the number of backups that the watchtower client has recorded.

Purpose: We are interested in keeping track of if our watchtower is functioning and making sure that the number of backups corresponds to the number of transactions is one metric we would like to use for this purpose.

Code:
This PR adds a new collector, wt_client_collector.go, which works very similarly to previous collectors.
This PR relies on an updated version of lndclient (update here) to communicate with the watchtower client interface of lnd.

Semantics:
2 metrics are exposed num_backups and num_pending_backups.
The metrics will not show up at all if there is no tower active.
Each metric has a towers public key as a label.

@Jontified Jontified marked this pull request as draft August 19, 2025 12:31
@Jontified
Copy link
Contributor Author

This will have to wait for lightninglabs/lndclient#235 to be merged before the proper lndclient dependency can be added in go.mod

@Jontified Jontified force-pushed the add-wt-metrics branch 2 times, most recently from ee6a834 to 59787a0 Compare August 25, 2025 08:31
@Jontified Jontified marked this pull request as ready for review August 25, 2025 08:32
Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the addition 🗼! Could you make sure to change commit message headers to be consistent with the repo's (just have a look at the past ones). For example Update go.mod and go.sum would become mod: update go.mod and go.sum or Fix comment would be collectors: fix comment (i.e. prefixing with the system/topic it concerns).

We also don't have a long line linter active in this repo, please try to cap lines at 80 chars. Will do a test run after your fixes so that we can merge the lndclient PR and then update the library in here.

@Jontified
Copy link
Contributor Author

Things should be up to date now!

Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, we need to catch errors if the watchtower client wasn't enabled, see the comment, otherwise lndmon won't run. Please make sure to run the linter before you push, the code requires reformatting. I have tested backup metrics collection as well 🎉

@Jontified Jontified force-pushed the add-wt-metrics branch 5 times, most recently from 125bea3 to 96f3471 Compare September 8, 2025 07:16
@Jontified
Copy link
Contributor Author

Final look and final comments?

@bitromortac bitromortac self-requested a review September 9, 2025 17:04
Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested again, LGTM 🎉. Thanks again!

A next step would be to add a dashboard such that other users will have access to those numbers by default (if you like to do another project).

@hieblmi hieblmi self-requested a review September 10, 2025 08:27
Copy link

@hieblmi hieblmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your effort, I just flagged some minor improvements, otherwise looks good to go.

@hieblmi
Copy link

hieblmi commented Sep 11, 2025

Great work, LGTM✅

@hieblmi hieblmi self-requested a review September 11, 2025 13:40
Update dependencies affected by this upgrade through `go mod tidy`
Fix spelling mistake in comment
Add collector for the numBackups and numPendingBackups from the lnd
watchtower client API.
@bitromortac bitromortac merged commit f63626f into lightninglabs:master Sep 15, 2025
1 check passed
@Jontified Jontified deleted the add-wt-metrics branch September 23, 2025 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants