-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 Prometheus metrics #1155
Add Prometheus metrics #1155
Conversation
glide.yaml
Outdated
@@ -1,36 +1,20 @@ | |||
# For detailed docs on how to add new dependencies or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were these comments deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I ran glide I'm assuming
server/server.go
Outdated
@@ -258,6 +260,7 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy) | |||
handleFunc("/callback/{connector}", s.handleConnectorCallback) | |||
handleFunc("/approval", s.handleApproval) | |||
handleFunc("/healthz", s.handleHealth) | |||
r.Handle("/metrics", promhttp.HandlerFor(prometheusRegistry, promhttp.HandlerOpts{})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to use handleFunc
, which uses the correct relative paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, there are actually some low hanging fruit here, I'll also instrument the http handlers
server/server.go
Outdated
@@ -137,14 +139,14 @@ type Server struct { | |||
} | |||
|
|||
// NewServer constructs a server from the provided config. | |||
func NewServer(ctx context.Context, c Config) (*Server, error) { | |||
func NewServer(ctx context.Context, c Config, prometheusRegistry prometheus.Gatherer) (*Server, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: prometheusRegistry should be part of Config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about this one, and didn't look into config too much, I felt it was just the unmarshaled config, but I'll gladly add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
cmd/dex/serve.go
Outdated
@@ -14,6 +14,8 @@ import ( | |||
"time" | |||
|
|||
"github.com/ghodss/yaml" | |||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no _
in go package alias
When renaming an imported package, the local name should follow the same guidelines as package names (lower case, no under_scores or mixedCaps).
eb46d84
to
042aecb
Compare
lgtm |
cmd/dex/serve.go
Outdated
grpcMetrics := grpcprometheus.NewServerMetrics() | ||
err = prometheusRegistry.Register(grpcMetrics) | ||
if err != nil { | ||
return fmt.Errorf("failed to register process metrics: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: failed to register gRPC server metrics
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed :) thanks for noticing
Yay, I see metrics
|
server/server.go
Outdated
@@ -258,6 +281,7 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy) | |||
handleFunc("/callback/{connector}", s.handleConnectorCallback) | |||
handleFunc("/approval", s.handleApproval) | |||
handleFunc("/healthz", s.handleHealth) | |||
handleFunc("/metrics", promhttp.HandlerFor(c.PrometheusRegistry, promhttp.HandlerOpts{}).ServeHTTP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay that we're serving these at a public endpoint? Request to dex are unauthenticated. Should it be a separate listener?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. These metrics may be security sensitive, I'd say we at least put them on a separate listener, then we can segment by network, which should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. thanks!
Add Prometheus metrics
This adds the Prometheus part of #778.
@ericchiang @rithujohn191 @diegs