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

metrics: support HTTP metrics server #298

Merged
merged 1 commit into from
Dec 30, 2022

Conversation

sctb512
Copy link
Member

@sctb512 sctb512 commented Dec 29, 2022

The common way to display prometheus format data is through the HTTP server. For instance, Grafana does not support collecting metrics from unix domain socket. Therefore, we should change the unix domain socket server to a HTTP server.

Here is an example:

containerd-nydus-grpc --config-path /etc/nydus/config.json -metrics-address :9010 --log-to-stdout
curl http://localhost:9010/metrics

Then, you will see the prometheus metrics.

Signed-off-by: Bin Tang tangbin.bin@bytedance.com

@sctb512 sctb512 force-pushed the support-http-metrics-server branch 2 times, most recently from c033bea to b9ef140 Compare December 29, 2022 10:00
@changweige
Copy link
Member

Please fix linting warnings.


log.L.Infof("Start metrics HTTP server on %s", addr)

listener, err := net.Listen("tcp4", addr)
Copy link
Member

Choose a reason for hiding this comment

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

No need to restrict it to "tcp4"

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, fixed.

&cli.StringFlag{
Name: "metrics-address",
Value: "",
Usage: "metrics `ENDPOINT` does not listen by default",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe Enable metrics server by setting to an address such as "localhost:8080", ":8080".

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, It is more reasonable. Fixed.

@codecov-commenter
Copy link

codecov-commenter commented Dec 30, 2022

Codecov Report

Base: 31.68% // Head: 31.81% // Increases project coverage by +0.13% 🎉

Coverage data is based on head (b2c5b61) compared to base (053440c).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #298      +/-   ##
==========================================
+ Coverage   31.68%   31.81%   +0.13%     
==========================================
  Files          34       34              
  Lines        3576     3564      -12     
==========================================
+ Hits         1133     1134       +1     
+ Misses       2327     2314      -13     
  Partials      116      116              
Impacted Files Coverage Δ
pkg/system/system.go 6.34% <ø> (+0.37%) ⬆️
cmd/containerd-nydus-grpc/pkg/command/flags.go 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

// listener.
var DefaultBindAddress = ":8080"
// Endpoint for prometheus metrics
var endpointPromMetrics = "/metrics"
Copy link
Member

Choose a reason for hiding this comment

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

Should we change it to "/v1/metrics" like containerd ?

### Metrics API

The metrics API that outputs prometheus style metrics will be versioned independently,
prefixed with the API version. i.e. `/v1/metrics`, `/v2/metrics`.

The metrics API version will be incremented when breaking changes are made to the prometheus
output. New metrics can be added to the output in a backwards compatible manner without
bumping the API version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, fixed it.

@changweige
Copy link
Member

Otherwise, LGTM

Signed-off-by: Bin Tang <tangbin.bin@bytedance.com>
Copy link
Member

@changweige changweige left a comment

Choose a reason for hiding this comment

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

LGTM

@changweige changweige merged commit 2f2922d into containerd:main Dec 30, 2022
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