From 069c742efb51e5f01e9c9e35e5025668ddda1071 Mon Sep 17 00:00:00 2001 From: bartmacbartek Date: Tue, 27 Apr 2021 14:51:43 +0200 Subject: [PATCH 01/10] Install prom-client dependency --- package.json | 1 + yarn.lock | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/package.json b/package.json index 21bcb61c..4efc4bf6 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "fast-safe-stringify": "2.0.4", "js-yaml": "4.0.0", "lodash": "4.17.21", + "prom-client": "13.1.0", "protobufjs": "6.10.2", "table": "6.0.7", "triple-beam": "1.3.0", diff --git a/yarn.lock b/yarn.lock index f0c38a01..4e7d5030 100644 --- a/yarn.lock +++ b/yarn.lock @@ -958,6 +958,11 @@ binary-extensions@^2.0.0: resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== +bintrees@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.1.tgz#0e655c9b9c2435eaab68bf4027226d2b55a34524" + integrity sha1-DmVcm5wkNeqraL9AJyJtK1WjRSQ= + bip39@^3.0.2: version "3.0.3" resolved "https://registry.npmjs.org/bip39/-/bip39-3.0.3.tgz" @@ -3513,6 +3518,13 @@ progress@^2.0.0: resolved "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== +prom-client@13.1.0: + version "13.1.0" + resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-13.1.0.tgz#1185caffd8691e28d32e373972e662964e3dba45" + integrity sha512-jT9VccZCWrJWXdyEtQddCDszYsiuWj5T0ekrPszi/WEegj3IZy6Mm09iOOVM86A4IKMWq8hZkT2dD9MaSe+sng== + dependencies: + tdigest "^0.1.1" + protobufjs@6.10.2, protobufjs@^6.8.8, protobufjs@~6.10.2: version "6.10.2" resolved "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz" @@ -4141,6 +4153,13 @@ table@6.0.7, table@^6.0.4: slice-ansi "^4.0.0" string-width "^4.2.0" +tdigest@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/tdigest/-/tdigest-0.1.1.tgz#2e3cb2c39ea449e55d1e6cd91117accca4588021" + integrity sha1-Ljyyw56kSeVdHmzZEReszKRYgCE= + dependencies: + bintrees "1.0.1" + teeny-request@6.0.1: version "6.0.1" resolved "https://registry.npmjs.org/teeny-request/-/teeny-request-6.0.1.tgz" From 417706f2123a4b51cb4a93070f20a1105b50fdff Mon Sep 17 00:00:00 2001 From: bartmacbartek Date: Wed, 28 Apr 2021 00:03:21 +0200 Subject: [PATCH 02/10] Expose /metrics and add custom counter --- prometheus.yaml | 10 ++++ src/binary/ibc-relayer/commands/start.ts | 40 ++++++++++++- src/binary/ibc-relayer/index.ts | 7 +++ src/binary/ibc-relayer/setup-prometheus.ts | 65 ++++++++++++++++++++++ src/binary/types.ts | 2 + src/binary/utils/load-and-validate-app.ts | 2 + 6 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 prometheus.yaml create mode 100644 src/binary/ibc-relayer/setup-prometheus.ts diff --git a/prometheus.yaml b/prometheus.yaml new file mode 100644 index 00000000..ada4052f --- /dev/null +++ b/prometheus.yaml @@ -0,0 +1,10 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: confio_relayer + + scrape_interval: 5s + static_configs: + - targets: ['host.docker.internal:26660'] diff --git a/src/binary/ibc-relayer/commands/start.ts b/src/binary/ibc-relayer/commands/start.ts index 8e1d7770..ea1fc5aa 100644 --- a/src/binary/ibc-relayer/commands/start.ts +++ b/src/binary/ibc-relayer/commands/start.ts @@ -16,6 +16,7 @@ import { resolveHomeOption } from '../../utils/options/shared/resolve-home-optio import { resolveKeyFileOption } from '../../utils/options/shared/resolve-key-file-option'; import { resolveMnemonicOption } from '../../utils/options/shared/resolve-mnemonic-option'; import { signingClient } from '../../utils/signing-client'; +import { Metrics, setupPrometheus } from '../setup-prometheus'; type ResolveHeightsParams = { scanFromSrc: number | null; @@ -94,6 +95,8 @@ type Flags = { destConnection?: string; scanFromSrc?: string; scanFromDest?: string; + enableMetrics: boolean; + metricsPort?: string; } & LoggerFlags & LoopFlags; @@ -105,15 +108,17 @@ type Options = { srcConnection: string; destConnection: string; heights: RelayedHeights | null; + enableMetrics: boolean; + metricsPort: number; } & LoopOptions; -// some defaults for looping export const defaults = { // check once per minute poll: 60, // once per day: 86400s maxAgeSrc: 86400, maxAgeDest: 86400, + metricsPort: 26660, }; export async function start(flags: Flags, logger: Logger) { @@ -171,6 +176,20 @@ export async function start(flags: Flags, logger: Logger) { flags.scanFromDest, process.env.RELAYER_SCAN_FROM_DEST ); + const enableMetrics = + flags.enableMetrics || + Boolean(process.env.RELAYER_ENABLE_METRICS) || + app?.enableMetrics || + false; + const metricsPort = resolveOption('metricsPort', { + integer: true, + required: true, + })( + flags.metricsPort, + process.env.RELAYER_METRICS_PORT, + app?.metricsPort, + defaults.metricsPort + ); const heights = resolveHeights({ scanFromSrc, scanFromDest, home }, logger); @@ -189,12 +208,20 @@ export async function start(flags: Flags, logger: Logger) { maxAgeDest, once, heights, + enableMetrics, + metricsPort, }; await run(options, logger); } async function run(options: Options, logger: Logger) { + const metrics = setupPrometheus({ + enabled: options.enableMetrics, + port: options.metricsPort, + logger, + }); + const registryFilePath = path.join(options.home, registryFile); const { chains } = loadAndValidateRegistry(registryFilePath); const srcChain = chains[options.src]; @@ -224,10 +251,15 @@ async function run(options: Options, logger: Logger) { logger ); - await relayerLoop(link, options, logger); + await relayerLoop(link, options, logger, metrics); } -async function relayerLoop(link: Link, options: Options, logger: Logger) { +async function relayerLoop( + link: Link, + options: Options, + logger: Logger, + metrics: Metrics +) { let nextRelay = options.heights ?? {}; const lastQueriedHeightsFilePath = path.join( options.home, @@ -262,5 +294,7 @@ async function relayerLoop(link: Link, options: Options, logger: Logger) { logger.info(`Sleeping ${options.poll} seconds...`); await sleep(options.poll * 1000); logger.info('... waking up and checking for packets!'); + + metrics.pollCounter?.inc(); } } diff --git a/src/binary/ibc-relayer/index.ts b/src/binary/ibc-relayer/index.ts index 978a1200..5e1e9af6 100644 --- a/src/binary/ibc-relayer/index.ts +++ b/src/binary/ibc-relayer/index.ts @@ -38,6 +38,13 @@ const startCommand = program .addOption(mnemonicOption) .addOption(srcConnection) .addOption(destConnection) + .option( + '--enable-metrics', + 'Enable Prometheus metrics collection and GET /metrics endpoint' + ) + .option( + `--metrics-port ', 'Specify port for GET /metrics http server (default: ${startDefaults.metricsPort})` + ) //TODO default port .option( '--poll ', `How many seconds we sleep between checking for packets (default: ${startDefaults.poll})` diff --git a/src/binary/ibc-relayer/setup-prometheus.ts b/src/binary/ibc-relayer/setup-prometheus.ts new file mode 100644 index 00000000..976b55e0 --- /dev/null +++ b/src/binary/ibc-relayer/setup-prometheus.ts @@ -0,0 +1,65 @@ +import http from 'http'; + +import client from 'prom-client'; + +import { Logger } from '../create-logger'; + +let initialized = false; + +function getMetrics() { + return { + pollCounter: new client.Counter({ + name: 'poll_counter', + help: 'Poll counter', + }), + }; +} + +type StubbedMetrics = Record, null>; +function getStubbedMetrics(): StubbedMetrics { + return { + pollCounter: null, + }; +} + +export type Metrics = ReturnType | StubbedMetrics; +export function setupPrometheus({ + enabled, + port, + logger, +}: { + enabled: boolean; + port: number; + logger: Logger; +}) { + if (initialized) { + throw new Error( + `"setupPrometheus" func shouldn't be initialized more than once.` + ); + } + initialized = true; + + if (!enabled) { + return getStubbedMetrics(); + } + + client.collectDefaultMetrics({ prefix: 'confio_relayer_' }); + const server = http.createServer(async (request, response) => { + if (request.method === 'GET' && request.url === '/metrics') { + const metrics = await client.register.metrics(); + response.writeHead(200, { + 'Content-Type': client.register.contentType, + }); + response.end(metrics); + + return; + } + + response.writeHead(404); + response.end('404'); + }); + server.listen(port); + logger.info(`Prometheus GET /metrics exposed on port ${port}.`); + + return getMetrics(); +} diff --git a/src/binary/types.ts b/src/binary/types.ts index cb1232bb..3d34aa4c 100644 --- a/src/binary/types.ts +++ b/src/binary/types.ts @@ -22,6 +22,8 @@ export type AppConfig = { destConnection?: string; mnemonic?: string; keyFile?: string; + enableMetrics?: boolean; + metricsPort?: number; }; export type LoggerFlags = { diff --git a/src/binary/utils/load-and-validate-app.ts b/src/binary/utils/load-and-validate-app.ts index 51776309..1c4abb58 100644 --- a/src/binary/utils/load-and-validate-app.ts +++ b/src/binary/utils/load-and-validate-app.ts @@ -41,6 +41,8 @@ export function loadAndValidateApp(home: string) { destConnection: { type: 'string', nullable: true }, mnemonic: { type: 'string', nullable: true }, keyFile: { type: 'string', nullable: true }, + enableMetrics: { type: 'boolean', nullable: true }, + metricsPort: { type: 'number', nullable: true }, }, }; const validate = ajv.compile(schema); From f997a1b266cea69eee216f17247d00ffb6e42edd Mon Sep 17 00:00:00 2001 From: bartmacbartek Date: Wed, 28 Apr 2021 00:40:57 +0200 Subject: [PATCH 03/10] Add 'Monitoring' section to README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 53ed9fe8..8abe67a0 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,25 @@ There are 3 files that live in the relayer's home. [Learn more about configuration.](spec/config.md) +## Monitoring +The relayer collects various metrics that [Prometheus](https://prometheus.io/docs/introduction/overview/) instance can consume. + +To enable metrics collection, pass `--enable-metrics` flag when starting the relayer: +```sh +ibc-relayer start --enable-metrics +``` +> **NOTE:** Metrics can be also enabled via an environment variable `RELAYER_ENABLE_METRICS=true`, or with a `enableMetrics: true` entry in the `app.yaml` file, as explained in the [config specifiation](./spec/config.md#configuration). + +The `GET /metrics` endpoint is exposed on a default port `26660`, which you can modify with `--metrics-port` flag/env variable/entry in app.yaml. + +### Local setup +1. Start the relayer with metrics enabled +2. Spin up the Prometheus instance: + ```sh + docker run -it -v $(pwd):/prometheus -p9090:9090 prom/prometheus --config.file=prometheus.yaml + ``` + > **NOTE:** Ensure that `--config.file=` flag points at the existing configuration file, you can find an example here: [prometheus.yaml](prometheus.yaml). +3. Open Prometheus dashboard in the browser at [http://localhost:9090](http://localhost:9090) ## Development [Refer to the development page.](DEVELOPMENT.md) From af01aad9bb907e8f2e99f1dd9872f4e06f4f2452 Mon Sep 17 00:00:00 2001 From: bartmacbartek Date: Wed, 28 Apr 2021 00:43:17 +0200 Subject: [PATCH 04/10] Remove redundant TODO comment --- src/binary/ibc-relayer/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binary/ibc-relayer/index.ts b/src/binary/ibc-relayer/index.ts index 5e1e9af6..2bea04a0 100644 --- a/src/binary/ibc-relayer/index.ts +++ b/src/binary/ibc-relayer/index.ts @@ -44,7 +44,7 @@ const startCommand = program ) .option( `--metrics-port ', 'Specify port for GET /metrics http server (default: ${startDefaults.metricsPort})` - ) //TODO default port + ) .option( '--poll ', `How many seconds we sleep between checking for packets (default: ${startDefaults.poll})` From 6eabfcbca1b2bab1930e4849db2d1c4b325998cb Mon Sep 17 00:00:00 2001 From: bartmacbartek Date: Wed, 28 Apr 2021 00:48:53 +0200 Subject: [PATCH 05/10] Remove stubbed metrics overkill --- src/binary/ibc-relayer/commands/start.ts | 2 +- src/binary/ibc-relayer/setup-prometheus.ts | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/binary/ibc-relayer/commands/start.ts b/src/binary/ibc-relayer/commands/start.ts index ea1fc5aa..5cb48dbe 100644 --- a/src/binary/ibc-relayer/commands/start.ts +++ b/src/binary/ibc-relayer/commands/start.ts @@ -295,6 +295,6 @@ async function relayerLoop( await sleep(options.poll * 1000); logger.info('... waking up and checking for packets!'); - metrics.pollCounter?.inc(); + metrics?.pollCounter?.inc(); } } diff --git a/src/binary/ibc-relayer/setup-prometheus.ts b/src/binary/ibc-relayer/setup-prometheus.ts index 976b55e0..03c3a6f7 100644 --- a/src/binary/ibc-relayer/setup-prometheus.ts +++ b/src/binary/ibc-relayer/setup-prometheus.ts @@ -15,14 +15,7 @@ function getMetrics() { }; } -type StubbedMetrics = Record, null>; -function getStubbedMetrics(): StubbedMetrics { - return { - pollCounter: null, - }; -} - -export type Metrics = ReturnType | StubbedMetrics; +export type Metrics = ReturnType; export function setupPrometheus({ enabled, port, @@ -40,7 +33,7 @@ export function setupPrometheus({ initialized = true; if (!enabled) { - return getStubbedMetrics(); + return null; } client.collectDefaultMetrics({ prefix: 'confio_relayer_' }); From 2d0d3319b3b096e75de7642e7e5d3f35c79aa8d9 Mon Sep 17 00:00:00 2001 From: willclarktech Date: Wed, 28 Apr 2021 11:01:32 +0200 Subject: [PATCH 06/10] Tidy English in Monitoring section of README Also formats with prettier --- README.md | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8abe67a0..49f38a22 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ the relayer works, but the Quick Start probably gives a better intro. - RPC addresses of 2 full nodes on compatible, IBC-enabled chains - See [Chain Requirements below](#Chain-Requirements) for details of what chains are supported - ## Installation ### NPM @@ -66,7 +65,7 @@ Reads the configuration and starts relaying packets. - pulls default `registry.yaml` to relayer's home - funds addresses on both sides so relayer can pay the fee while relaying packets - > **NOTE:** Test blockchains `relayer_test_1` and `relayer_test_2` are running in the public. You do not need to start any blockchain locally to complete the quick start guide. + > **NOTE:** Test blockchains `relayer_test_1` and `relayer_test_2` are running in the public. You do not need to start any blockchain locally to complete the quick start guide. > **NOTE:** Run `ibc-setup balances` to see the amount of tokens on each address. @@ -88,15 +87,16 @@ Reads the configuration and starts relaying packets. ### Send tokens between chains 1. Make sure `wasmd` binary is installed on your system + - you must be running Linux or OSX on amd64 (not arm64/Mac M1) - [install Go 1.15+](https://golang.org/doc/install) and ensure that `$PATH` includes Go binaries (you may need to restart your terminal session) - - clone and install `wasmd`: - ```sh - git clone https://github.com/CosmWasm/wasmd.git - cd wasmd - git checkout v0.15.1 - make install - ``` + - clone and install `wasmd`: + ```sh + git clone https://github.com/CosmWasm/wasmd.git + cd wasmd + git checkout v0.15.1 + make install + ``` 2. Create a new account and fund it @@ -125,6 +125,7 @@ Reads the configuration and starts relaying packets. ## Configuration overview The relayer configuration is stored under relayer's home directory. By default, it's located at `$HOME/.ibc-setup`, however, can be customized with `home` option, e.g.: + ```sh # initialize the configuration at /home/user/relayer_custom_home ibc-setup init --home /home/user/relayer_custom_home @@ -136,38 +137,45 @@ ibc-relayer start --home /home/user/relayer_custom_home There are 3 files that live in the relayer's home. - **registry.yaml** (required) - - Contains a list of available chains with corresponding information. The chains from the registry can be referenced by `ibc-setup` binary or within the `app.yaml` file. [View an example of registry.yaml file.](demo/registry.yaml) + + Contains a list of available chains with corresponding information. The chains from the registry can be referenced by `ibc-setup` binary or within the `app.yaml` file. [View an example of registry.yaml file.](demo/registry.yaml) - **app.yaml** (optional) - - Holds the relayer-specific options such as source or destination chains. These options can be overridden with CLI flags or environment variables. + + Holds the relayer-specific options such as source or destination chains. These options can be overridden with CLI flags or environment variables. + - **last-queried-heights.json** (optional) - + Stores last queried heights for better performance on relayer startup. It's constantly overwritten with new heights when relayer is running. Simply delete this file to scan the events since forever. [Learn more about configuration.](spec/config.md) ## Monitoring -The relayer collects various metrics that [Prometheus](https://prometheus.io/docs/introduction/overview/) instance can consume. -To enable metrics collection, pass `--enable-metrics` flag when starting the relayer: +The relayer collects various metrics that a [Prometheus](https://prometheus.io/docs/introduction/overview/) instance can consume. + +To enable metrics collection, pass the `--enable-metrics` flag when starting the relayer: + ```sh ibc-relayer start --enable-metrics ``` -> **NOTE:** Metrics can be also enabled via an environment variable `RELAYER_ENABLE_METRICS=true`, or with a `enableMetrics: true` entry in the `app.yaml` file, as explained in the [config specifiation](./spec/config.md#configuration). -The `GET /metrics` endpoint is exposed on a default port `26660`, which you can modify with `--metrics-port` flag/env variable/entry in app.yaml. +> **NOTE:** Metrics can also be enabled via an environment variable `RELAYER_ENABLE_METRICS=true`, or with an `enableMetrics: true` entry in the `app.yaml` file, as explained in the [config specification](./spec/config.md#configuration). + +The `GET /metrics` endpoint will be exposed by default on port `26660`, which you can override with `--metrics-port` flag, `RELAYER_METRICS_PORT` env variable, or `metricsPort` entry in `app.yaml`. ### Local setup + 1. Start the relayer with metrics enabled 2. Spin up the Prometheus instance: ```sh - docker run -it -v $(pwd):/prometheus -p9090:9090 prom/prometheus --config.file=prometheus.yaml + docker run -it -v $(pwd):/prometheus -p9090:9090 prom/prometheus --config.file=prometheus.yaml ``` - > **NOTE:** Ensure that `--config.file=` flag points at the existing configuration file, you can find an example here: [prometheus.yaml](prometheus.yaml). -3. Open Prometheus dashboard in the browser at [http://localhost:9090](http://localhost:9090) + > **NOTE:** Ensure that `the --config.file=` flag points at the existing configuration file. You can find an example here: [prometheus.yaml](prometheus.yaml). +3. Open the Prometheus dashboard in a browser at [http://localhost:9090](http://localhost:9090) + ## Development + [Refer to the development page.](DEVELOPMENT.md) ## Chain Requirements From 4d93ebd3763aaa1a88cc6c920ff94a51bd936ef1 Mon Sep 17 00:00:00 2001 From: bartmacbartek Date: Wed, 28 Apr 2021 14:16:50 +0200 Subject: [PATCH 07/10] Mark flags and options as readonly --- src/binary/ibc-relayer/commands/start.ts | 58 ++++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/binary/ibc-relayer/commands/start.ts b/src/binary/ibc-relayer/commands/start.ts index 5cb48dbe..c0d5b14b 100644 --- a/src/binary/ibc-relayer/commands/start.ts +++ b/src/binary/ibc-relayer/commands/start.ts @@ -68,48 +68,48 @@ function resolveHeights( } type LoopFlags = { - poll?: string; - maxAgeSrc?: string; - maxAgeDest?: string; - once: boolean; + readonly poll?: string; + readonly maxAgeSrc?: string; + readonly maxAgeDest?: string; + readonly once: boolean; }; type LoopOptions = { // how many seconds we sleep between relaying batches - poll: number; + readonly poll: number; // number of seconds old the client on chain A can be - maxAgeSrc: number; + readonly maxAgeSrc: number; // number of seconds old the client on chain B can be - maxAgeDest: number; + readonly maxAgeDest: number; // if set to 'true' quit after one pass - once: boolean; + readonly once: boolean; }; type Flags = { - interactive: boolean; - home?: string; - src?: string; - dest?: string; - keyFile?: string; - mnemonic?: string; - srcConnection?: string; - destConnection?: string; - scanFromSrc?: string; - scanFromDest?: string; - enableMetrics: boolean; - metricsPort?: string; + readonly interactive: boolean; + readonly home?: string; + readonly src?: string; + readonly dest?: string; + readonly keyFile?: string; + readonly mnemonic?: string; + readonly srcConnection?: string; + readonly destConnection?: string; + readonly scanFromSrc?: string; + readonly scanFromDest?: string; + readonly enableMetrics: boolean; + readonly metricsPort?: string; } & LoggerFlags & LoopFlags; type Options = { - home: string; - src: string; - dest: string; - mnemonic: string; - srcConnection: string; - destConnection: string; - heights: RelayedHeights | null; - enableMetrics: boolean; - metricsPort: number; + readonly home: string; + readonly src: string; + readonly dest: string; + readonly mnemonic: string; + readonly srcConnection: string; + readonly destConnection: string; + readonly heights: RelayedHeights | null; + readonly enableMetrics: boolean; + readonly metricsPort: number; } & LoopOptions; export const defaults = { From af3e18ccdaeb5e9f817c1d0372c0ffba6d12993c Mon Sep 17 00:00:00 2001 From: bartmacbartek Date: Wed, 28 Apr 2021 14:25:27 +0200 Subject: [PATCH 08/10] Define 'setupPrometheus' func return type --- src/binary/ibc-relayer/setup-prometheus.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/binary/ibc-relayer/setup-prometheus.ts b/src/binary/ibc-relayer/setup-prometheus.ts index 03c3a6f7..2f3c45f9 100644 --- a/src/binary/ibc-relayer/setup-prometheus.ts +++ b/src/binary/ibc-relayer/setup-prometheus.ts @@ -15,7 +15,9 @@ function getMetrics() { }; } -export type Metrics = ReturnType; +export type Metrics = { + pollCounter: client.Counter; +} | null; export function setupPrometheus({ enabled, port, @@ -24,7 +26,7 @@ export function setupPrometheus({ enabled: boolean; port: number; logger: Logger; -}) { +}): Metrics { if (initialized) { throw new Error( `"setupPrometheus" func shouldn't be initialized more than once.` From 92287b8be249a8cc99d8ec5d70fdb0d961d89409 Mon Sep 17 00:00:00 2001 From: bartmacbartek Date: Wed, 28 Apr 2021 22:19:18 +0200 Subject: [PATCH 09/10] Move prometheus.yaml example config under demo dir --- README.md | 4 ++-- prometheus.yaml => demo/prometheus.yaml | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename prometheus.yaml => demo/prometheus.yaml (100%) diff --git a/README.md b/README.md index 49f38a22..bdda3f1a 100644 --- a/README.md +++ b/README.md @@ -169,9 +169,9 @@ The `GET /metrics` endpoint will be exposed by default on port `26660`, which yo 1. Start the relayer with metrics enabled 2. Spin up the Prometheus instance: ```sh - docker run -it -v $(pwd):/prometheus -p9090:9090 prom/prometheus --config.file=prometheus.yaml + docker run -it -v $(pwd):/prometheus -p9090:9090 prom/prometheus --config.file=demo/prometheus.yaml ``` - > **NOTE:** Ensure that `the --config.file=` flag points at the existing configuration file. You can find an example here: [prometheus.yaml](prometheus.yaml). + > **NOTE:** Ensure that `the --config.file=` flag points at the existing configuration file. You can find an example here: [prometheus.yaml](demo/prometheus.yaml). 3. Open the Prometheus dashboard in a browser at [http://localhost:9090](http://localhost:9090) ## Development diff --git a/prometheus.yaml b/demo/prometheus.yaml similarity index 100% rename from prometheus.yaml rename to demo/prometheus.yaml From 19664fdc49555ed1c80c534f136483fcc9caadb1 Mon Sep 17 00:00:00 2001 From: bartmacbartek <79154001+bartmacbartek@users.noreply.github.com> Date: Wed, 28 Apr 2021 22:52:37 +0200 Subject: [PATCH 10/10] Create gorgeous-houses-listen.md --- .changeset/gorgeous-houses-listen.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/gorgeous-houses-listen.md diff --git a/.changeset/gorgeous-houses-listen.md b/.changeset/gorgeous-houses-listen.md new file mode 100644 index 00000000..ab113660 --- /dev/null +++ b/.changeset/gorgeous-houses-listen.md @@ -0,0 +1,6 @@ +--- +"@confio/relayer": patch +--- + +Add support for Prometheus monitoring. +Read more: https://github.com/confio/ts-relayer#monitoring