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

Allow customization of the metrics path #354

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/promxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ type cliOpts struct {
WebCORSOriginRegex string `long:"web.cors.origin" description:"Regex for CORS origin. It is fully anchored." default:".*"`
WebReadTimeout time.Duration `long:"web.read-timeout" description:"Maximum duration before timing out read of the request, and closing idle connections." default:"5m"`

MetricsPath string `long:"metrics-path" description:"URL path for the prometheus metrics endpoint." default:"/metrics"`

ExternalURL string `long:"web.external-url" description:"The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically."`
EnableLifecycle bool `long:"web.enable-lifecycle" description:"Enable shutdown and reload via HTTP request."`

Expand Down Expand Up @@ -341,7 +343,7 @@ func main() {

webOptions.CORSOrigin, err = compileCORSRegexString(opts.WebCORSOriginRegex)
if err != nil {
logrus.Fatalf("Erorr parsing CORS regex: %v", err)
logrus.Fatalf("Error parsing CORS regex: %v", err)
}

if externalUrl != nil && externalUrl.Path != "" {
Expand All @@ -359,8 +361,7 @@ func main() {
// Create our router
r := httprouter.New()

// TODO: configurable metrics path
r.HandlerFunc("GET", "/metrics", promhttp.Handler().ServeHTTP)
r.HandlerFunc("GET", opts.MetricsPath, promhttp.Handler().ServeHTTP)

stopping := false
r.NotFound = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down