-
Notifications
You must be signed in to change notification settings - Fork 50
Add wallet_key_count metric #76
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
Conversation
f721b6a
to
55a8065
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Sorry that it took some time to get to review.
Just some versioning comments from me.
Any interest in adding these metrics to our provisioned grafana dashboards so they're more easily available?
collectors/errors.go
Outdated
code := status.Code(err) | ||
return code == codes.Unimplemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could inline this to status.Code(err) == codes.Unimplemented
?
go.mod
Outdated
github.com/prometheus/client_golang v0.9.3 | ||
github.com/stretchr/testify v1.5.1 | ||
golang.org/x/text v0.3.2 // indirect | ||
github.com/lightninglabs/lndclient v1.0.1-0.20211001112454-5bb2b557e003 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to stick to tagged versions of lndclient
, could you use v0.13.0-9
? That should have all the calls you need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I used a branch instead of a tag because this change: lightninglabs/lndclient@5bb2b55, which is needed for the PR has not been tagged yet. As soon as it get tagged I can reference it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah my mistake, thought that was included in the 13-09
tag! Pushed v0.13.0-10
to lndclient now, you can use that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, thanks!
collectors/wallet_collector.go
Outdated
// Nodes prior to version 0.13.0 don't implement ListAccounts and will | ||
// return a Unimplemented error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we bump to lndclient-13.0
it'll require that lnd is running at least lnd version 13.0
to start up (will fail for older clients).
We use this versioning to ensure that we're "safe" to use all new APIs and don't need to worry about unimplemented errors. Happy for this PR to just bump the required version to 13.0
and then we can assume that this API is supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when bumped to 0.13.0 lndmon still works against a lnd-0.12.x though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, we've specifically pinned minimum version to 0.11. If you just delete that CheckVersion
field, it'll enforce lndclient
's minimum version which aligns with the tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow, if I delete CheckVersion
we will drop versions older than 0.13? Is that something we want for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, generally when we update our projects to depend on a new API we bump the minimum version. Otherwise it can get awfully complex trying to figure out which endpoints we do/don't have access to. If you want to upgrade your lndmon to the version with this feature, you also need to bump you lnd node to at least 0.13.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, if we drop versions older than 0.13
then I can safely remove the status.Code(err) == codes.Unimplemented
check right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah exactly! Just makes life a lot easier :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
55a8065
to
254445a
Compare
how? is that dashboard open/public? |
Thanks, I added the metric to a new panel |
c0fd49a
to
7b4f4a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question about metric label + issue with grafana, nearly there!
collectors/wallet_collector.go
Outdated
errChan chan<- error) *WalletCollector { | ||
|
||
// these labels are specific for key_count metrics | ||
keyCountLabels := []string{"account_name", "address_type"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could internal
and external
be additional labels as well? Rather than needing to split out into two separate metrics? Since they seem functionally the same except for internal/external differentiation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense, will change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you call the label? I can think of visibility
or context
or external={true|false}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key_type
or key_branch
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key_type
it is
4800c9b
to
910de60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics look good! Just need a little work on the dashboard.
"refId": "A" | ||
} | ||
], | ||
"title": "Panel Title", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name for the panel rather than "panel title"?
I would suggest something like:
You'd need to update this json a bit (datasource, namespace, better titles etc), but should get you most of the way there. |
You are suggesting two different panels? or both graphs belong to the same panel? |
595f558
to
e0eca07
Compare
Sorry somehow completely missed this comment!
Was thinking 2x panels?
Nope, should be "$datasource", those are just my local deafults. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlaKC I just noticed that and it happened when I started using |
Ah interesting! Difficult to display succinctly. We could just change the existing chart to a graph and go with something like this:
Generally metrics are, but it's not a strict requirement. If you want to just drop the grafana change, we can just merge the addition of the metric to prometheus! |
I prefer to drop the changes to Grafana since it is not pretty to display, and different users might need different chart details/accounts. |
e0eca07
to
40111bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏅
@ellemouton: review reminder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good ⭐ Left a few optional nits and one comment about a comment that looks a bit out of place
float64(walletBal.Unconfirmed), | ||
) | ||
|
||
accounts, err := u.lnd.WalletKit.ListAccounts(context.Background(), "", 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: wrap at 80 chars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it already below 80? (vim shows :78)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mine shows 83. Is your tab size set to 8 spaces?
40111bc
to
b2c00ea
Compare
thanks for the quick update @qustavo 🚀 almost there, just need to also rebase master as your pr now includes some other commits |
Signed-off-by: Gustavo Chain <[email protected]>
Signed-off-by: Gustavo Chain <[email protected]>
b2c00ea
to
b81c950
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
This PR adds a new wallet metric: wallet_key_count which reports the current number of keys derived per account.
This metric is particularly useful when running a recovery with large gaps.
When recovering a node (see recovery.md) we need to specify a recovery window value:
To find an accurate recovery window we could rely on the wallet key count (see lightningnetwork/lnd#5767).
This PR also bumps lndclient to
:lnd-13-0
(https://github.com/lightninglabs/lndclient/tree/lnd-13-0) which introduces theListAccounts
call.