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 new flag + readme for starting p2p prometheus dashboards #5707

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

sstanculeanu
Copy link
Collaborator

@sstanculeanu sstanculeanu commented Nov 14, 2023

Reasoning behind the pull request

  • libp2p prometheus dashboards can be used for a useful overview over different metrics

Proposed changes

  • added new flag to start a new route /debug/metrics/prometheus
  • updated readme with steps to start the dashboards

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

Copy link

codecov bot commented Nov 14, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (a57c319) 80.32% compared to head (cabda0c) 80.31%.
Report is 1 commits behind head on rc/v1.7.0.

❗ Current head cabda0c differs from pull request most recent head be4f79c. Consider uploading reports for the commit be4f79c to get more accurate results

Files Patch % Lines
api/gin/webServer.go 0.00% 1 Missing and 1 partial ⚠️
facade/initial/initialNodeFacade.go 77.77% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           rc/v1.7.0    #5707      +/-   ##
=============================================
- Coverage      80.32%   80.31%   -0.01%     
=============================================
  Files            709      709              
  Lines          93901    93914      +13     
=============================================
+ Hits           75425    75431       +6     
- Misses         13185    13191       +6     
- Partials        5291     5292       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -36,7 +36,8 @@ import (
const DefaultRestInterface = "localhost:8080"

// DefaultRestPortOff is the default value that should be passed if it is desired
// to start the node without a REST endpoint available
//
// to start the node without a REST endpoint available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong formatting

@@ -163,7 +164,8 @@ func (nf *nodeFacade) RestAPIServerDebugMode() bool {

// RestApiInterface returns the interface on which the rest API should start on, based on the config file provided.
// The API will start on the DefaultRestInterface value unless a correct value is passed or
// the value is explicitly set to off, in which case it will not start at all
//
// the value is explicitly set to off, in which case it will not start at all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong formatting

@@ -17,14 +17,14 @@ func TestInitialNodeFacade(t *testing.T) {
t.Run("nil status metrics should error", func(t *testing.T) {
t.Parallel()

inf, err := NewInitialNodeFacade("127.0.0.1:8080", true, nil)
inf, err := NewInitialNodeFacade("127.0.0.1:8080", true, false, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move all arguments for the NewInitialNodeFacade into a single arg-struct

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@iulianpascalau iulianpascalau self-requested a review November 16, 2023 07:50
Copy link
Contributor

@iulianpascalau iulianpascalau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

started testing the readme...

README.md Outdated
1. Start the node with `--p2p-prometheus-metrics` flag. This exposes a metrics collection at http://localhost:5001/debug/metrics/prometheus.
2. Clone libp2p repository: `git clone https://github.com/libp2p/go-libp2p`
3. `cd go-libp2p/dasboards/swarm` and under the
```json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might remove the json tag because the code is not json compatible (missing ], } at the end)
Valid for L95. This will improve the readability in github

@@ -73,6 +73,7 @@ GLOBAL OPTIONS:
--logs-path directory This flag specifies the directory where the node will store logs.
--operation-mode operation mode String flag for specifying the desired operation mode(s) of the node, resulting in altering some configuration values accordingly. Possible values are: snapshotless-observer, full-archive, db-lookup-extension, historical-balances or `""` (empty). Multiple values can be separated via ,
--repopulate-tokens-supplies Boolean flag for repopulating the tokens supplies database. It will delete the current data, iterate over the entire trie and add he new obtained supplies
--p2p-prometheus-metrics Boolean option for enabling the /debug/metrics/prometheus route for p2p prometheus metrics
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@iulianpascalau iulianpascalau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Works on my machine"
Screenshot from 2023-11-16 11-01-37
Screenshot from 2023-11-16 11-01-26
Screenshot from 2023-11-16 11-01-09
Screenshot from 2023-11-16 11-01-00
Screenshot from 2023-11-16 11-00-50

README.md Outdated
@@ -83,6 +83,36 @@ sudo cp protoc-gen-gogoslick /usr/bin/

Done

## Running p2p Prometheus dashboards
1. Start the node with `--p2p-prometheus-metrics` flag. This exposes a metrics collection at http://localhost:5001/debug/metrics/prometheus.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the port is not 5001, is the one defined by the -rest-api-interface flag which defaults to localhost:8080

README.md Outdated
```
sudo docker compose -f docker-compose.base.yml -f docker-compose-linux.yml up --force-recreate
```
**Note:** this command is not compatible with compose v1, thus an update to v2 would be needed. More details about the migration [here](https://docs.docker.com/compose/migrate/).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add here: if you choose to install the new Docker version manually, please make sure that installation is done for all users of the system. Otherwise, the docker command will fail because it needs the super-user privileges.
... or something like this :)

@sstanculeanu sstanculeanu merged commit b8c3768 into rc/v1.7.0 Nov 22, 2023
4 checks passed
@sstanculeanu sstanculeanu deleted the prometheus_dashboards branch November 22, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants