diff --git a/collectors/prometheus.go b/collectors/prometheus.go index 2f87472..c5368cc 100644 --- a/collectors/prometheus.go +++ b/collectors/prometheus.go @@ -67,6 +67,9 @@ type MonitoringConfig struct { // DisableGraph disables collection of graph metrics DisableGraph bool + + // DisableHtlc disables collection of HTLCs metrics + DisableHtlc bool } func DefaultConfig() *PrometheusConfig { @@ -91,18 +94,19 @@ func NewPrometheusExporter(cfg *PrometheusConfig, lnd *lndclient.LndServices, htlcMonitor := newHtlcMonitor(lnd.Router, errChan) - collectors := append( - []prometheus.Collector{ - NewChainCollector(lnd.Client, errChan), - NewChannelsCollector( - lnd.Client, errChan, monitoringCfg, - ), - NewWalletCollector(lnd, errChan), - NewPeerCollector(lnd.Client, errChan), - NewInfoCollector(lnd.Client, errChan), - }, - htlcMonitor.collectors()..., - ) + collectors := []prometheus.Collector{ + NewChainCollector(lnd.Client, errChan), + NewChannelsCollector( + lnd.Client, errChan, monitoringCfg, + ), + NewWalletCollector(lnd, errChan), + NewPeerCollector(lnd.Client, errChan), + NewInfoCollector(lnd.Client, errChan), + } + + if !monitoringCfg.DisableHtlc { + collectors = append(collectors, htlcMonitor.collectors()...) + } if !monitoringCfg.DisableGraph { collectors = append(collectors, NewGraphCollector(lnd.Client, errChan)) diff --git a/config.go b/config.go index 774ca9d..d568e21 100755 --- a/config.go +++ b/config.go @@ -49,8 +49,11 @@ type config struct { // PrimaryNode is the pubkey of the primary node in primary-gateway setups. PrimaryNode string `long:"primarynode" description:"Public key of the primary node in a primary-gateway setup"` - // DisableGraph disables collection of graph metrics + // DisableGraph disables collection of graph metrics. DisableGraph bool `long:"disablegraph" description:"Do not collect graph metrics"` + + // DisableHtlc disables the collection of HTLCs metrics. + DisableHtlc bool `long:"disablehtlc" description:"Do not collect HTLCs metrics"` } var defaultConfig = config{ diff --git a/lndmon.go b/lndmon.go index 85af1a4..bcf062b 100755 --- a/lndmon.go +++ b/lndmon.go @@ -59,6 +59,7 @@ func start() error { monitoringCfg := collectors.MonitoringConfig{ DisableGraph: cfg.DisableGraph, + DisableHtlc: cfg.DisableHtlc, } if cfg.PrimaryNode != "" { primaryNode, err := route.NewVertexFromStr(cfg.PrimaryNode)