From 6b2e415ecbbd1a602969efb327d9452458129090 Mon Sep 17 00:00:00 2001 From: Goutam Verma <66783850+GoutamVerma@users.noreply.github.com> Date: Thu, 16 Jun 2022 21:22:57 +0530 Subject: [PATCH] Expose scraping endpoint for prometheus metrics (#2321) Allow eclair to expose a metrics scraping endpoint for Prometheus for users who don't want to rely on Kamon's hosted infrastructure. Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com> --- docs/Monitoring.md | 43 +++++++++++++++++-- eclair-core/pom.xml | 5 +++ .../src/main/resources/application.conf | 9 ++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/docs/Monitoring.md b/docs/Monitoring.md index b914a3c77..cb5623905 100644 --- a/docs/Monitoring.md +++ b/docs/Monitoring.md @@ -33,6 +33,7 @@ kamon { } ``` + When starting eclair, you should enable the Kanela agent: ```sh @@ -42,13 +43,48 @@ eclair.sh -with-kanela Your eclair node will start exporting monitoring data to Kamon. You can then start creating dashboards, graphs and alerts directly on Kamon's website. -## Enabling monitoring with a different backend +## Enabling monitoring with Prometheus Kamon supports many other monitoring [backends](https://kamon.io/docs/latest/reporters/). This can be useful for nodes that don't want to export any data to third-party servers. -No specific work has been done yet in eclair to support these backends. If you'd like to use them, -don't hesitate to ask around or send a PR. +Eclair currently supports exporting metrics to [Prometheus](https://kamon.io/docs/latest/reporters/prometheus/). +To enable monitoring with Prometheus, add the following to your `eclair.conf`: + +```config +eclair.enable-kamon=true + +// The Kamon APM reporter is enabled by default, but it won't work with Prometheus, so we disable it. +kamon.modules { + apm-reporter { + enabled = false + } +} + +kamon { + prometheus { + start-embedded-http-server = yes + embedded-server { + hostname = 0.0.0.0 + port = + } + } +} +``` + +You should then configure your Prometheus process to scrape metrics from the exposed http server. +* Download Prometheus [here](https://prometheus.io/download/). +* Add the following configuration to the `prometheus.yml` file (see the [Prometheus documentation](https://prometheus.io/docs/prometheus/latest/configuration/configuration/) for more details) + +```prometheus.yml +global: + scrape_interval: 15s # By default, scrape targets every 15 seconds. + +scrape_configs: + - job_name: 'eclair' + static_configs: + - targets: [''] + ``` ## Example metrics @@ -60,3 +96,4 @@ metrics are just a small sample of all the metrics we provide: * Number of connected peers * Bitcoin wallet balance * Various metrics about the public graph (nodes, channels, updates, etc) + diff --git a/eclair-core/pom.xml b/eclair-core/pom.xml index 86185396f..a511f4a6f 100644 --- a/eclair-core/pom.xml +++ b/eclair-core/pom.xml @@ -270,6 +270,11 @@ 1.5.0 + + io.kamon + kamon-prometheus_${scala.version.short} + 2.5.4 + io.kamon kamon-core_${scala.version.short} diff --git a/eclair-node/src/main/resources/application.conf b/eclair-node/src/main/resources/application.conf index 930d863bb..eaa336ffd 100644 --- a/eclair-node/src/main/resources/application.conf +++ b/eclair-node/src/main/resources/application.conf @@ -43,6 +43,15 @@ kamon.instrumentation.akka { } } } +// See documentation here: https://kamon.io/docs/latest/reporters/prometheus/ +kamon.prometheus { + // If you want to expose a scraping endpoint for Prometheus metrics, set this to true. + start-embedded-http-server = no + embedded-server { + hostname = 0.0.0.0 + port = 9095 + } +} kanela.modules { jdbc {