-
Notifications
You must be signed in to change notification settings - Fork 30
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 unix socket support for prometheus #128
base: main
Are you sure you want to change the base?
Conversation
cc @shizunge do you mind taking a look? |
cc @Bananz0 @JeDaYoshi do you mind taking a look? |
I'm not part of the project, so I can't act on it. |
gotcha! appreciate the fast response. i see you have contributed here before though - do you have any suggestions or criticisms for this change? |
cc @olofvndrhr do you mind taking a look? |
I will take a look at this at Sept 19 or 20. |
@@ -87,7 +89,24 @@ func InitPrometheus(prometheusHost, prometheusPort, prometheusEntry string) { | |||
handler := promhttp.HandlerFor(promReg, promhttp.HandlerOpts{EnableOpenMetrics: true}) | |||
http.Handle("/"+prometheusEntry, handler) | |||
go func() { | |||
glog.Infof("Starting Prometheus on %v:%v, entry point is /%v", prometheusHost, prometheusPort, prometheusEntry) | |||
|
|||
if strings.HasPrefix(prometheusHost, "unix:") { |
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.
Can you move this to a new function?
if strings.HasPrefix(prometheusHost, "unix:") { | ||
socketPath := prometheusHost[5:] | ||
glog.Infof("Starting Prometheus on Unix socket %v, entry point is /%v", socketPath, prometheusEntry) | ||
os.Remove(socketPath) // allow failure |
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.
_ := os.Remove(socketPath)
this PR allows for listening on a Unix domain socket for prometheus metrics by prefixing the path with
unix:
also open to alternative prefixes like
unix/
(which is what caddy uses)some of this approach can probably be reused for #112
example usage:
starting endlessh-go
getting metrics