Skip to content

Commit

Permalink
Make prometheus port configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Smith <nathan@chainguard.dev>
  • Loading branch information
Nathan Smith committed May 31, 2022
1 parent f0642f0 commit 27e050b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/app/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func newServeCmd() *cobra.Command {
cmd.Flags().String("port", "8080", "The port on which to serve requests for HTTP; --http-port is alias")
cmd.Flags().String("grpc-host", "0.0.0.0", "The host on which to serve requests for GRPC")
cmd.Flags().String("grpc-port", "8081", "The port on which to serve requests for GRPC")
cmd.Flags().String("metrics-port", "2112", "The port on which to serve prometheus metrics endpoint")

// convert "http-host" flag to "host" and "http-port" flag to be "port"
cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
Expand Down Expand Up @@ -242,7 +243,7 @@ func runServeCmd(cmd *cobra.Command, args []string) {
httpServer.startListener()

prom := http.Server{
Addr: ":2112",
Addr: fmt.Sprintf(":%v", viper.GetString("metrics-port")),
Handler: promhttp.Handler(),
}
log.Logger.Error(prom.ListenAndServe())
Expand Down

0 comments on commit 27e050b

Please sign in to comment.