Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions collectors/channels_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (c *ChannelsCollector) Collect(ch chan<- prometheus.Metric) {

// Next, for each channel we'll export the total sum of our balances,
// as well as the number of pending HTLCs.
listChannelsResp, err := c.lnd.ListChannels(context.Background())
listChannelsResp, err := c.lnd.ListChannels(context.Background(), false, false)
if err != nil {
c.errChan <- fmt.Errorf("ChannelsCollector ListChannels "+
"failed with: %v", err)
Expand Down Expand Up @@ -557,7 +557,7 @@ func (c *ChannelsCollector) getRemotePolicies(pubkey route.Vertex) (
// Only record policies for peers that have this channel
// enabled.
if policy != nil && !policy.Disabled {
policies[i.ChannelId] = policy
policies[i.ChannelID] = policy
}
}

Expand Down
42 changes: 42 additions & 0 deletions collectors/wallet_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ type WalletCollector struct {
confirmedBalanceDesc *prometheus.Desc
unconfirmedBalanceDesc *prometheus.Desc

// We'll use one counter to keep track of both internal and external key
// count.
keyCountDesc *prometheus.Desc

// errChan is a channel that we send any errors that we encounter into.
// This channel should be buffered so that it does not block sends.
errChan chan<- error
Expand Down Expand Up @@ -71,6 +75,16 @@ func NewWalletCollector(lnd *lndclient.LndServices,
"unconfirmed wallet balance",
nil, nil,
),
keyCountDesc: prometheus.NewDesc(
"lnd_wallet_key_count", "wallet key count",
[]string{
"account_name",
"address_type",
"derivation_path",
"key_type",
}, nil,
),

errChan: errChan,
}
}
Expand All @@ -88,6 +102,7 @@ func (u *WalletCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- u.avgUtxoSizeDesc
ch <- u.confirmedBalanceDesc
ch <- u.unconfirmedBalanceDesc
ch <- u.keyCountDesc
}

// Collect is called by the Prometheus registry when collecting metrics.
Expand Down Expand Up @@ -169,4 +184,31 @@ func (u *WalletCollector) Collect(ch chan<- prometheus.Metric) {
u.unconfirmedBalanceDesc, prometheus.GaugeValue,
float64(walletBal.Unconfirmed),
)

accounts, err := u.lnd.WalletKit.ListAccounts(context.Background(), "", 0)
Copy link
Member

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

Copy link
Contributor Author

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)

Copy link
Member

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?

if err != nil {
u.errChan <- fmt.Errorf("WalletCollector ListAccounts"+
"failed with: %v", err)
return
}

for _, account := range accounts {
name := account.GetName()
addrType := account.GetAddressType().String()
path := account.GetDerivationPath()

// internal key count.
ch <- prometheus.MustNewConstMetric(
u.keyCountDesc, prometheus.CounterValue,
float64(account.InternalKeyCount),
name, addrType, path, "internal",
)

// external key count.
ch <- prometheus.MustNewConstMetric(
u.keyCountDesc, prometheus.CounterValue,
float64(account.ExternalKeyCount),
name, addrType, path, "external",
)
}
}
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ module github.com/lightninglabs/lndmon

require (
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
github.com/btcsuite/btcutil v1.0.2
github.com/google/go-cmp v0.3.1 // indirect
github.com/btcsuite/btcutil v1.0.3-0.20210527170813-e2ba6805a890
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/jessevdk/go-flags v1.4.0
github.com/jrick/logrotate v1.0.0
github.com/lightninglabs/lndclient v0.11.0-4.0.20201117105441-b9a8c8f4910a
github.com/lightningnetwork/lnd v0.11.1-beta
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 v0.13.0-10
github.com/lightningnetwork/lnd v0.13.0-beta.rc5.0.20210920062527-d9f0f07142ea
github.com/prometheus/client_golang v1.11.0
github.com/stretchr/testify v1.7.0
)

go 1.15
Loading