Skip to content

Conversation

Jontified
Copy link

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
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.

Update dependencies affected by this upgrade through go mod tidy
Temporary commit which depends on lndclient fork for testing new
features.
Remove this commit before merging.
Fix spelling mistake in comment
@Jontified
Copy link
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 🎉

Comment on lines 75 to 76
numBackups uint32
numPendingBackups uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

that code is not formatted, the linter complains (recommend to set up auto-formatting with go fmt)

Copy link
Author

Choose a reason for hiding this comment

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

go fmt does not change this for me. Not sure what formatting you'd like here but I indented the uint32 to be on the same indentation.

Add collector for the numBackups and numPendingBackups from the lnd
watchtower client API.
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.

2 participants