From a3d3388d6a62d4fabfa449de1dedfea60b8ea376 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 22 May 2023 18:27:44 +0200 Subject: [PATCH] prom: Fix breakage due to msat purge Closes #450 --- prometheus/prometheus.py | 6 +++++- prometheus/test_prometheus.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/prometheus/prometheus.py b/prometheus/prometheus.py index 5c28b48..bb712bb 100755 --- a/prometheus/prometheus.py +++ b/prometheus/prometheus.py @@ -32,7 +32,11 @@ class NodeCollector(BaseLnCollector): value=blockheight, ) - fees_msat = info["msatoshi_fees_collected"] + print(info) + fees_msat = int(info.get( + "fees_collected_msat", + info.get("msatoshi_fees_collected", None) + )) yield GaugeMetricFamily( 'lightning_fees_collected_msat', 'How much have we been paid to route payments?', diff --git a/prometheus/test_prometheus.py b/prometheus/test_prometheus.py index 21d960d..6a9f2ed 100644 --- a/prometheus/test_prometheus.py +++ b/prometheus/test_prometheus.py @@ -1,5 +1,6 @@ import os from pyln.testing.fixtures import * # noqa: F401,F403 +import urllib plugin_path = os.path.join(os.path.dirname(__file__), "prometheus.py") @@ -14,3 +15,13 @@ def test_prometheus_starts(node_factory): # Then statically l1.daemon.opts["plugin"] = plugin_path l1.start() + + +def test_prometheus_scrape(node_factory): + """Test that we can scrape correctly. + """ + l1 = node_factory.get_node(options={'plugin': plugin_path}) + scrape = urllib.request.urlopen("http://localhost:9750") + + +