Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added metrics push mode #230

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions docs/how-to/monitor/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,43 @@ To configure Prometheus and run with Web3Signer:

5. View the [Prometheus graphical interface](#view-prometheus-graphical-interface).

## Run Prometheus with Web3Signer in push mode

The [`--metrics-enabled`](../../reference/cli/options.md#metrics-enabled) option enables Prometheus polling of Besu, but sometimes metrics are hard to poll (for example, when running inside Docker containers with varying IP addresses). To enable Besu to push metrics to a [Prometheus push gateway](https://github.com/prometheus/pushgateway), use the [`--metrics-push-enabled`](../../reference/cli/options.md#metrics-push-enabled) option.

To configure Prometheus and run with Web3Signer pushing to a push gateway:

1. Configure Prometheus to read from a push gateway. For example, add the following YAML fragment to the `scrape_configs` block of the `prometheus.yml` file:

```yml
- job_name: push-gateway
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- localhost:9091
```

1. Start the push gateway. You can deploy the push gateway using the Docker image:

```bash
docker pull prom/pushgateway
docker run -d -p 9091:9091 prom/pushgateway
```

1. Start Web3Signer specifying options:
* [`--metrics-push-enabled`](../../reference/cli/options.md#metrics-push-enabled)
* [`--metrics-push-port`](../../reference/cli/options.md#metrics-push-enabled)
* [`--metrics-push-host`](../../reference/cli/options.md#metrics-push-host)

1. In another terminal, run Prometheus specifying the `prometheus.yml` file:

```bash
prometheus --config.file=prometheus.yml
```

1. View the [Prometheus graphical interface](#view-prometheus-graphical-interface).

## View Prometheus graphical interface

1. Open a web browser to `http://localhost:9090` to view the Prometheus graphical interface.
Expand Down
169 changes: 169 additions & 0 deletions docs/reference/cli/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,175 @@ To allow all hostnames, use `"*"`.
We don't recommend allowing all hostnames for production environments.
:::

### `metrics-push-enabled`

<!--tabs-->

# Syntax

```bash
--metrics-push-enabled[=<true|false>]
```

# Example

```bash
--metrics-push-enabled=true
```

# Environment variable

```bash
WEB3SIGNER_METRICS_PUSH_ENABLED=true
```

# Configuration file

```bash
metrics-push-enabled=true
```

<!--/tabs-->

Enables or disables [push gateway integration](../../how-to/monitor/metrics.md#run-prometheus-with-web3signer-in-push-mode).

You can't specify `--metrics-push-enabled` with [`--metrics-enabled`](#metrics-enabled). That is, you can enable either Prometheus polling or Prometheus push gateway support, but not both at once.

### `metrics-push-host`

<!--tabs-->

# Syntax

```bash
--metrics-push-host=<HOST>
```

# Example

```bash
--metrics-push-host=127.0.0.1
```

# Environment variable

```bash
WEB3SIGNER_METRICS_PUSH_HOST=127.0.0.1
```

# Configuration file

```bash
metrics-push-host="127.0.0.1"
```

<!--/tabs-->

The host of the [Prometheus Push Gateway](https://github.com/prometheus/pushgateway). The default is `127.0.0.1`. The metrics server respects the [`--metrics-host-allowlist` option](#metrics-host-allowlist).

:::note

When pushing metrics, ensure you set `--metrics-push-host` to the machine on which the push gateway is. Generally, this is a different machine to the machine on which Web3Signer is running.

:::

### `metrics-push-interval`

<!--tabs-->

# Syntax

```bash
--metrics-push-interval=<INTEGER>
```

# Example

```bash
--metrics-push-interval=30
```

# Environment variable

```bash
WEB3SIGNER_METRICS_PUSH_INTERVAL=30
```

# Configuration file

```bash
metrics-push-interval=30
```

<!--/tabs-->

The interval, in seconds, to push metrics when in `push` mode. The default is 15.

### `metrics-push-port`

<!--tabs-->

# Syntax

```bash
--metrics-push-port=<PORT>
```

# Example

```bash
--metrics-push-port=6174
```

# Environment variable

```bash
WEB3SIGNER_METRICS_PUSH_PORT=6174
```

# Configuration file

```bash
metrics-push-port="6174"
```

<!--/tabs-->

The port (TCP) of the [Prometheus Push Gateway](https://github.com/prometheus/pushgateway). The default is `9001`.

### `metrics-push-prometheus-job`

<!--tabs-->

# Syntax

```bash
--metrics-push-prometheus-job=<metricsPrometheusJob>
```

# Example

```bash
--metrics-push-prometheus-job="my-custom-job"
```

# Environment variable

```bash
WEB3SIGNER_METRICS_PUSH_PROMETHEUS_JOB="my-custom-job"
```

# Configuration file

```bash
metrics-push-prometheus-job="my-custom-job"
```

<!--/tabs-->

The job name when in `push` mode. The default is `web3signer-job`.


### `swagger-ui-enabled`

<!--tabs-->
Expand Down
Loading