github.com/amazechain/amc@v0.1.3/docs/run/observability.md (about)

     1  # Observability with Prometheus & Grafana
     2  
     3  amc provides a variety of metrics, listed here. They can be served from an HTTP endpoint by adding the --metrics flag:
     4  
     5  ```bash
     6  amazechain --metrics --metrics.addr '0.0.0.0'  --metrics.port '6060'
     7  ```
     8  
     9  Now, while the node is running, you can use the curl command to access the endpoint you provided to the --metrics.port  flag to get a text dump of the metrics at that point:
    10  
    11  ```bash
    12  curl 127.0.0.1:6060/debug/metrics/prometheus
    13  ```
    14  
    15  The response is quite descriptive, but it might be verbose. Moreover, it's just a snapshot of the metrics at the time you curled the endpoint.
    16  
    17  You can run the following command in a separate terminal to periodically poll the endpoint, and print the values (without the header text) to the terminal:
    18  
    19  ```bash
    20  while true; do date; curl -s 127.0.0.1:6060/debug/metrics/prometheus | grep -Ev '^(#|$)' | sort; echo; sleep 10; done
    21  ```
    22  
    23  We're finally making progress! However, as a final step, wouldn't it be great to see how these metrics evolve over time (generally in a GUI)?
    24  
    25  ## Prometheus & Grafana
    26  
    27  We're going to use Prometheus to collect metrics from the endpoint we set up, and use Grafana to scrape the metrics from Prometheus and define a dashboard.
    28  
    29  Start by installing both Prometheus and Grafana, for instance via Homebrew:
    30  
    31  ```bash
    32  brew update
    33  brew install prometheus
    34  brew install grafana
    35  ```
    36  
    37  Then, kick off the Prometheus and Grafana services:
    38  
    39  ```bash
    40  brew services start prometheus
    41  brew services start grafana
    42  ```
    43  
    44  This will start a Prometheus service which [by default scrapes itself about the current instance](https://prometheus.io/docs/introduction/first_steps/#:~:text=The%20job%20contains%20a%20single,%3A%2F%2Flocalhost%3A9090%2Fmetrics.). So you'll need to change its config to hit your Reth nodes metrics endpoint at `localhost:9001` which you set using the `--metrics` flag.
    45  
    46  You can find an example config for the Prometheus service in the repo here: [`etc/prometheus/prometheus.yml`](https://github.com/paradigmxyz/reth/blob/main/etc/prometheus/prometheus.yml)
    47  
    48  Depending on your installation you may find the config for your Prometheus service at:
    49  
    50  - OSX: `/opt/homebrew/etc/prometheus.yml`
    51  - Linuxbrew: `/home/linuxbrew/.linuxbrew/etc/prometheus.yml`
    52  - Others: `/usr/local/etc/prometheus/prometheus.yml`
    53  
    54  Next, open up "localhost:3000" in your browser, which is the default URL for Grafana. Here, "admin" is the default for both the username and password.
    55  
    56  Once you've logged in, click on the gear icon in the lower left, and select "Data Sources". Click on "Add data source", and select "Prometheus" as the type. In the HTTP URL field, enter `http://localhost:9090`. Finally, click "Save & Test".
    57  
    58  As this might be a point of confusion, `localhost:9001`, which we supplied to `--metrics`, is the endpoint that Reth exposes, from which Prometheus collects metrics. Prometheus then exposes `localhost:9090` (by default) for other services (such as Grafana) to consume Prometheus metrics.
    59  
    60  To configure the dashboard in Grafana, click on the squares icon in the upper left, and click on "New", then "Import". From there, click on "Upload JSON file", and select the example file in [`reth/etc/grafana/dashboards/overview.json`](https://github.com/paradigmxyz/reth/blob/main/etc/grafana/dashboards/overview.json). Finally, select the Prometheus data source you just created, and click "Import".
    61  
    62  And voilá, you should see your dashboard! If you're not yet connected to any peers, the dashboard will look like it's in an empty state, but once you are, you should see it start populating with data.
    63  
    64  ## Conclusion
    65  
    66  In this runbook, we took you through starting the node, exposing different log levels, exporting metrics, and finally viewing those metrics in a Grafana dashboard.
    67  
    68  This will all be very useful to you, whether you're simply running a home node and want to keep an eye on its performance, or if you're a contributor and want to see the effect that your (or others') changes have on Reth's operations.
    69  
    70  [installation]: ../installation/installation.md