prysm-pulse/monitoring/prometheus
Preston Van Loon 9d375969d1
Enforce log.WithError(err) static analysis and fix all violations (#11163)
* Use log.WithError static analysis from #11143 and fix all violations

* Fix another log violation after pulling from develop

* Update beacon-chain/sync/pending_blocks_queue.go

Co-authored-by: Potuz <potuz@prysmaticlabs.com>

* @potuz feedback

* Copy paste fail

* fix tests

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Potuz <potuz@prysmaticlabs.com>
2022-08-05 10:52:02 +00:00
..
BUILD.bazel Move Shared/Testutil into Testing (#9659) 2021-09-23 18:53:46 +00:00
content_negotiation.go Move Shared/ Subpackages Into Monitoring/ Folder (#9591) 2021-09-14 20:59:51 +00:00
logrus_collector_test.go Replace ioutil with io and os (#10541) 2022-04-18 20:42:07 +00:00
logrus_collector.go Code cleanup (#9992) 2021-12-07 17:52:39 +00:00
README.md Move Shared/ Subpackages Into Monitoring/ Folder (#9591) 2021-09-14 20:59:51 +00:00
service_test.go Replace ioutil with io and os (#10541) 2022-04-18 20:42:07 +00:00
service.go Enforce log.WithError(err) static analysis and fix all violations (#11163) 2022-08-05 10:52:02 +00:00
simple_server.go Fix gosec scan: G112 (CWE-400) Potential Slowloris Attack (#10872) 2022-06-13 22:29:26 +00:00

How to monitor with prometheus

Prerequisites:

Start scrapping services

To start scrapping with prometheus you must create or edit the prometheus config file and add all the services you want to scrap, like these:

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'codelab-monitor'

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9090']
+  - job_name: 'beacon-chain'
+    static_configs:
+      - targets: ['localhost:8080']

After creating/updating the prometheus file run it:

$ prometheus --config.file=your-prometheus-file.yml

Now, you can add the prometheus server as a data source on grafana and start building your dashboards.

How to add additional metrics

The prometheus service export the metrics from the DefaultRegisterer so just need to register your metrics with the prometheus or promauto libraries. To know more Go application guide