Make metrics endpoint configurable
This commit is contained in:
parent
9b54cec29c
commit
ed4d970723
@ -35,6 +35,9 @@ ThrottleSpeed = 10240.0
|
||||
# Must be either "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "NONE"
|
||||
# Default: "INFO"
|
||||
LogLevel = "INFO"
|
||||
# Enable metrics endpoint
|
||||
# Default: false
|
||||
MetricsEnable = false
|
||||
# Enable access logging
|
||||
# Default: true
|
||||
AccessLogEnable = true
|
||||
|
@ -34,6 +34,7 @@ type HoneypotConfig struct {
|
||||
type FrontendConfig struct {
|
||||
ListenAddr string `toml:"ListenAddr"`
|
||||
LogLevel string `toml:"LogLevel"`
|
||||
MetricsEnable bool `toml:"MetricsEnable"`
|
||||
AccessLogEnable bool `toml:"AccessLogEnable"`
|
||||
AccessLogIgnoreMetrics bool `toml:"AccessLogIgnoreMetrics"`
|
||||
Autocert FrontendAutocertConfig `toml:"Autocert"`
|
||||
|
@ -86,10 +86,12 @@ func NewServer(cfg config.FrontendConfig, hs *ssh.HoneypotServer, store store.Lo
|
||||
r.Use(middleware.RealIP)
|
||||
r.Use(middleware.RequestID)
|
||||
r.Use(s.LoggingMiddleware)
|
||||
r.Use(NewMetricsMiddleware())
|
||||
r.Use(middleware.SetHeader("Server", fmt.Sprintf("apiary/%s", apiary.FullVersion())))
|
||||
|
||||
r.Handle("/metrics", promhttp.Handler())
|
||||
if cfg.MetricsEnable {
|
||||
r.Use(NewMetricsMiddleware())
|
||||
r.Handle("/metrics", promhttp.Handler())
|
||||
}
|
||||
r.Route("/", func(r chi.Router) {
|
||||
r.Get("/*", s.IndexHandler("web/vue-frontend/dist"))
|
||||
r.Get("/stream", s.HandlerAttemptStream)
|
||||
|
Loading…
x
Reference in New Issue
Block a user