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

Add /metrics endpoint #51

Merged
merged 6 commits into from
Apr 12, 2022
Merged

Add /metrics endpoint #51

merged 6 commits into from
Apr 12, 2022

Conversation

leizor
Copy link
Contributor

@leizor leizor commented Apr 11, 2022

This PR adds an "internal" server that defaults to listening on port 8081 and provides two endpoints:

  • /metrics: Prometheus metrics endpoint
  • /healthz: A health check endpoint

@leizor leizor force-pushed the leizor/query-squad/issue-114 branch 2 times, most recently from 93be500 to 13e47af Compare April 11, 2022 16:07
@grafanabot

This comment has been minimized.

@leizor leizor force-pushed the leizor/query-squad/issue-114 branch from 13e47af to 93310de Compare April 11, 2022 17:02
@grafanabot

This comment has been minimized.

@leizor leizor marked this pull request as ready for review April 11, 2022 17:09
ywwg
ywwg previously approved these changes Apr 11, 2022
Copy link
Contributor

@ywwg ywwg left a comment

Choose a reason for hiding this comment

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

comment nit

pkg/influx/api.go Outdated Show resolved Hide resolved
@grafanabot

This comment has been minimized.

@leizor leizor force-pushed the leizor/query-squad/issue-114 branch from 8470ec6 to da8a887 Compare April 11, 2022 23:13
@grafanabot

This comment has been minimized.

cmd/influx2cortex/main.go Outdated Show resolved Hide resolved
cmd/influx2cortex/main.go Outdated Show resolved Hide resolved
pkg/internalserver/service.go Outdated Show resolved Hide resolved
pkg/internalserver/service.go Outdated Show resolved Hide resolved
@grafanabot

This comment has been minimized.

@grafanabot

This comment has been minimized.

Copy link
Contributor

@ywwg ywwg left a comment

Choose a reason for hiding this comment

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

this is shaping up nicely, just some questions and small bits

cmd/influx2cortex/main.go Outdated Show resolved Hide resolved
pkg/influx/proxy.go Show resolved Hide resolved
pkg/internalserver/service.go Outdated Show resolved Hide resolved
_, _ = w.Write([]byte("ok"))
}))

httpServer := &http.Server{
Copy link
Contributor

Choose a reason for hiding this comment

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

does this mean the binary has two http servers (the api and the internalserver)? That's a little weird but I can see why we might do it that way. Though that means we need to make sure the /metrics call is going to the correct port vs the write calls. (Not sure where promscrape is configured)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep! I figured out how to do it yesterday, so I'll have a follow-up PR to get that fixed once this gets merged.

pkg/internalserver/service.go Show resolved Hide resolved
@grafanabot

This comment has been minimized.

1 similar comment
@grafanabot

This comment has been minimized.

@leizor leizor force-pushed the leizor/query-squad/issue-114 branch from f444d7f to 21e2e88 Compare April 12, 2022 17:52
@grafanabot
Copy link

Go coverage report:

Click to expand.
File %
github.com/grafana/influx2cortex/pkg/errorx/errors.go 67.3%
github.com/grafana/influx2cortex/pkg/errorx/http_translator.go 100.0%
github.com/grafana/influx2cortex/pkg/influx/api.go 100.0%
github.com/grafana/influx2cortex/pkg/influx/errors.go 100.0%
github.com/grafana/influx2cortex/pkg/influx/parser.go 84.1%
github.com/grafana/influx2cortex/pkg/influx/proxy.go 63.4%
github.com/grafana/influx2cortex/pkg/influx/recorder.go 91.7%
github.com/grafana/influx2cortex/pkg/remotewrite/client.go 69.1%
github.com/grafana/influx2cortex/pkg/remotewrite/measured_client.go 88.9%
github.com/grafana/influx2cortex/pkg/remotewrite/recorder.go 100.0%
github.com/grafana/influx2cortex/pkg/route/registerer.go 100.0%
github.com/grafana/influx2cortex/pkg/server/middleware/http_auth.go 0.0%
github.com/grafana/influx2cortex/pkg/server/middleware/http_fake_auth.go 0.0%
github.com/grafana/influx2cortex/pkg/server/middleware/instrument.go 6.7%
github.com/grafana/influx2cortex/pkg/server/middleware/logging.go 69.7%
github.com/grafana/influx2cortex/pkg/server/middleware/middleware.go 0.0%
github.com/grafana/influx2cortex/pkg/server/middleware/request_limits.go 81.8%
github.com/grafana/influx2cortex/pkg/server/middleware/response.go 57.1%
github.com/grafana/influx2cortex/pkg/server/middleware/route_matcher.go 0.0%
github.com/grafana/influx2cortex/pkg/server/middleware/tracer.go 13.0%
github.com/grafana/influx2cortex/pkg/server/server.go 83.3%
github.com/grafana/influx2cortex/pkg/tenant/resolver.go 75.6%
github.com/grafana/influx2cortex/pkg/tenant/tenant.go 91.7%
github.com/grafana/influx2cortex/pkg/util/bytereplacer/byte_replacer.go 100.0%
github.com/grafana/influx2cortex/pkg/util/extract_forwarded.go 66.7%
github.com/grafana/influx2cortex/pkg/util/http.go 68.3%
github.com/grafana/influx2cortex/pkg/util/log/experimental.go 0.0%
github.com/grafana/influx2cortex/pkg/util/log/log.go 0.0%
github.com/grafana/influx2cortex/pkg/util/log/rate_limit.go 90.0%
github.com/grafana/influx2cortex/pkg/util/log/wrappers.go 0.0%
github.com/grafana/influx2cortex/pkg/util/push/push.go 60.0%
total 65.3%

Go lint report:

No issues found. 😎

flags.Int64Var(&cfg.HTTPMaxRequestSizeLimit, prefix+"server.http-max-req-size-limit", defaultHTTPRequestSizeLimit, "HTTP max request body size limit. Defaults to 10 mb.")
flags.StringVar(&cfg.HTTPListenAddress, prefix+"server.http-listen-address", "0.0.0.0", "Sets listen address for the http server")
flags.IntVar(&cfg.HTTPListenPort, prefix+"server.http-listen-port", defaultListenPort, "Sets listen address port for the http server")
flags.IntVar(&cfg.HTTPConnLimit, prefix+"server.http-listen-conn-limit", 0, "Sets a limit to the amount of http connections, 0 means no limit")
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, thanks for these updates

Copy link
Contributor

@ywwg ywwg left a comment

Choose a reason for hiding this comment

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

thanks!

Copy link
Contributor

@ywwg ywwg left a comment

Choose a reason for hiding this comment

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

thanks!

@leizor leizor merged commit 5ec54e2 into main Apr 12, 2022
@leizor leizor deleted the leizor/query-squad/issue-114 branch April 12, 2022 18:25
@ywwg ywwg mentioned this pull request Apr 14, 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