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

feat(metrics): Monitor and publish metrics to Prometheus. #1437

Merged
merged 11 commits into from
Mar 10, 2021

Conversation

arijitAD
Copy link
Contributor

@arijitAD arijitAD commented Mar 5, 2021

Changes

  • Monitor and publish metrics to Prometheus.

Tests

make gossamer
 ./bin/gossamer init --config chain/gssmr/config.toml --basepath ~/.gossamer_alice --genesis-raw genesis-raw.json --force
 ./bin/gossamer --port 7000 --config chain/gssmr/config.toml --key alice --basepath ~/.gossamer_alice --rpcport 8540 --rpc --publish-metrics --metrics-port 9871
curl http://127.0.0.1:9871/metrics

Checklist

  • I have read CODE_OF_CONDUCT and CONTRIBUTING
  • I have provided as much information as possible and necessary
  • I have reviewed my own pull request before requesting a review
  • All integration tests and required coverage checks are passing

Issues

@RyRy79261
Copy link
Contributor

When running the Init command I receive this error
image

@noot
Copy link
Contributor

noot commented Mar 5, 2021

@RyRy79261 you can omit the --genesis-raw gen-raw.json, it should automatically find the genesis file

Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

great work, it works for me!

INFO[03-05|09:49:28] Enabling stand-alone metrics HTTP endpoint address=127.0.0.1:7012 caller=node.go:297
INFO[03-05|09:49:28] Starting metrics server                  addr=http://127.0.0.1:7012/metrics caller=node.go:308
$ curl http://127.0.0.1:7012/metrics
# TYPE network_node_latency gauge
network_node_latency 0

# TYPE network_node_peerCount gauge
network_node_peerCount 0

# TYPE network_node_totalConnection gauge
network_node_totalConnection 0

# TYPE service_blocks_sync gauge
service_blocks_sync 0

# TYPE system_cpu_goroutines gauge
system_cpu_goroutines 82

# TYPE system_cpu_procload gauge
system_cpu_procload 125

# TYPE system_cpu_sysload gauge
system_cpu_sysload 201

# TYPE system_cpu_syswait gauge
system_cpu_syswait 0

# TYPE system_memory_allocs gauge
system_memory_allocs 241501003

# TYPE system_memory_frees gauge
system_memory_frees 238847505

# TYPE system_memory_held gauge
system_memory_held 467861504

# TYPE system_memory_pauses gauge
system_memory_pauses 8204387

# TYPE system_memory_used gauge
system_memory_used 371083400

could you add a --metrics-port flag that specifies what port the prometheus server should run on?

@arijitAD
Copy link
Contributor Author

arijitAD commented Mar 6, 2021

great work, it works for me!

INFO[03-05|09:49:28] Enabling stand-alone metrics HTTP endpoint address=127.0.0.1:7012 caller=node.go:297
INFO[03-05|09:49:28] Starting metrics server                  addr=http://127.0.0.1:7012/metrics caller=node.go:308
$ curl http://127.0.0.1:7012/metrics
# TYPE network_node_latency gauge
network_node_latency 0

# TYPE network_node_peerCount gauge
network_node_peerCount 0

# TYPE network_node_totalConnection gauge
network_node_totalConnection 0

# TYPE service_blocks_sync gauge
service_blocks_sync 0

# TYPE system_cpu_goroutines gauge
system_cpu_goroutines 82

# TYPE system_cpu_procload gauge
system_cpu_procload 125

# TYPE system_cpu_sysload gauge
system_cpu_sysload 201

# TYPE system_cpu_syswait gauge
system_cpu_syswait 0

# TYPE system_memory_allocs gauge
system_memory_allocs 241501003

# TYPE system_memory_frees gauge
system_memory_frees 238847505

# TYPE system_memory_held gauge
system_memory_held 467861504

# TYPE system_memory_pauses gauge
system_memory_pauses 8204387

# TYPE system_memory_used gauge
system_memory_used 371083400

could you add a --metrics-port flag that specifies what port the prometheus server should run on?

Updated with metrics port flag.

dot/network/metrics.go Outdated Show resolved Hide resolved
dot/config.go Outdated Show resolved Hide resolved
@dutterbutter dutterbutter requested a review from noot March 8, 2021 16:37
@@ -238,10 +240,37 @@ func (s *Service) Start() error {

logger.Info("started network service", "supported protocols", s.host.protocols())

if s.cfg.PublishMetrics {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe I missed it but I don't see this being set anywhere? eg in dot/services.go createNetworkService?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing it. I missed it while refactoring the metrics package.

Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good! please double check that network config PublishMetrics is being set

@arijitAD arijitAD changed the title Monitor and publish metrics to Prometheus. feat(metrics): Monitor and publish metrics to Prometheus. Mar 10, 2021
@arijitAD arijitAD merged commit c18c8e9 into development Mar 10, 2021
@arijitAD arijitAD deleted the publish-metrics branch March 10, 2021 16:53
github-actions bot pushed a commit that referenced this pull request Mar 10, 2021
Arijit Das: feat(metrics): Monitor and publish metrics to Prometheus. (#1437)

* Monitor and publish metrics to prometheus.

* Add flags for metrics server port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants