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

chore: Telemetry updates, add prometheus listener #2413

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

albttx
Copy link
Member

@albttx albttx commented Jun 21, 2024

This PR continue the works on #2408

Adding multiple features:

  • Add prefixes to all exported names, since they're all catched up in prometheus, it's a monitoring norm to have them all prefixed. It's simpler to created dashboards and check what's exposed.
    I used tm2 and gno as prefixes depending on what i believed it was linked, if i made a mistake, don't hesitate to tell me :)

  • The service instance was forced to gno-node-1, since we have multiple instance nodes now, it's better to have the possiblity to set it.

  • It's bringing back exposing a prometheus endpoint on /metrics on port ":26660".

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@albttx albttx self-assigned this Jun 21, 2024
@albttx albttx requested review from a team, jaekwon, moul, piux2 and zivkovicmilos as code owners June 21, 2024 09:09
@github-actions github-actions bot added the 📦 🌐 tendermint v2 Issues or PRs tm2 related label Jun 21, 2024
Copy link

codecov bot commented Jun 21, 2024

Codecov Report

Attention: Patch coverage is 12.50000% with 28 lines in your changes missing coverage. Please review.

Project coverage is 54.71%. Comparing base (608ca30) to head (fd27778).
Report is 260 commits behind head on master.

Files with missing lines Patch % Lines
tm2/pkg/telemetry/metrics/metrics.go 0.00% 26 Missing ⚠️
tm2/pkg/telemetry/config/config.go 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2413      +/-   ##
==========================================
- Coverage   54.72%   54.71%   -0.01%     
==========================================
  Files         584      584              
  Lines       78531    78550      +19     
==========================================
+ Hits        42974    42982       +8     
- Misses      32348    32361      +13     
+ Partials     3209     3207       -2     
Flag Coverage Δ
contribs/gnodev 23.81% <ø> (ø)
contribs/gnofaucet 15.31% <ø> (ø)
contribs/gnokeykc 0.00% <ø> (ø)
contribs/gnomd 0.00% <ø> (ø)
gno.land 62.68% <ø> (ø)
gnovm 59.97% <ø> (ø)
misc/autocounterd 0.00% <ø> (ø)
misc/genproto 0.00% <ø> (ø)
misc/genstd 73.90% <ø> (ø)
misc/goscan 0.00% <ø> (ø)
misc/logos 17.68% <ø> (+0.30%) ⬆️
misc/loop 0.00% <ø> (ø)
tm2 54.43% <12.50%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

I've left a few minor comments regarding the prometheus init, otherwise good to go 🙏

If you've cleared this with the standards warden @ajnavarro, I'm good with adding this feature 💯

tm2/pkg/telemetry/metrics/metrics.go Outdated Show resolved Hide resolved
tm2/pkg/telemetry/metrics/metrics.go Show resolved Hide resolved
tm2/pkg/telemetry/config/config.go Outdated Show resolved Hide resolved
tm2/pkg/telemetry/metrics/metrics.go Outdated Show resolved Hide resolved
Comment on lines 155 to 161
server := &http.Server{
Addr: config.PrometheusAddr,
ReadHeaderTimeout: 5 * time.Second,
}
http.Handle("/metrics", promhttp.Handler())
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we should be creating a new server and exposing the /metrics here

A better place would be the central one we actually use for all endpoints in tm2/pkg/bft/node -- you can just expose a func in telemetry to register the handle with the mux (node's mux)

Copy link
Member Author

Choose a reason for hiding this comment

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

FYI: This is what tendermint what doing

Copy link
Member Author

Choose a reason for hiding this comment

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

At first i liked the idea, but i just changed my mind.

Because you want to have the possibility to expose your RPC port to public without publicly expose your metrics

Copy link
Member

@moul moul Jun 24, 2024

Choose a reason for hiding this comment

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

It makes sense to have two listeners: one on 0.0.0.0 and another on 127.0.0.1.

The alternative is to have a single listener, then either configure flags to disable certain endpoints, such as /metrics, or document how to use a firewall or an HTTP proxy for advanced usage patterns.

Need feedback: Do you know if it's common for validators to have a hybrid approach with metrics enabled, but only for localhost? I suspect they usually choose between one of two extremes: "minimal runtime with metrics disabled completely" or a "fully tooled setup with metrics enabled and verbose mode."

Copy link
Member Author

@albttx albttx Jun 24, 2024

Choose a reason for hiding this comment

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

Yes it's make total sense, to give you an example, i could run the RPC on 0.0.0.0 for public access and prometheus endpoint on the VPN ip address.
Or they have their small prometheus in send mode on the server, and read from it on localhost.

@albttx
Copy link
Member Author

albttx commented Jul 2, 2024

@zivkovicmilos rebased :)

please @ajnavarro review

@ajnavarro
Copy link
Contributor

Could you add some tests please? thanks.

Copy link

This PR is stale because it has been open 3 months with no activity. Remove stale label or comment or this will be closed in 3 months.

@github-actions github-actions bot added Stale and removed Stale labels Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related
Projects
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants