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"
|
# Must be either "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "NONE"
|
||||||
# Default: "INFO"
|
# Default: "INFO"
|
||||||
LogLevel = "INFO"
|
LogLevel = "INFO"
|
||||||
|
# Enable metrics endpoint
|
||||||
|
# Default: false
|
||||||
|
MetricsEnable = false
|
||||||
# Enable access logging
|
# Enable access logging
|
||||||
# Default: true
|
# Default: true
|
||||||
AccessLogEnable = true
|
AccessLogEnable = true
|
||||||
|
@ -34,6 +34,7 @@ type HoneypotConfig struct {
|
|||||||
type FrontendConfig struct {
|
type FrontendConfig struct {
|
||||||
ListenAddr string `toml:"ListenAddr"`
|
ListenAddr string `toml:"ListenAddr"`
|
||||||
LogLevel string `toml:"LogLevel"`
|
LogLevel string `toml:"LogLevel"`
|
||||||
|
MetricsEnable bool `toml:"MetricsEnable"`
|
||||||
AccessLogEnable bool `toml:"AccessLogEnable"`
|
AccessLogEnable bool `toml:"AccessLogEnable"`
|
||||||
AccessLogIgnoreMetrics bool `toml:"AccessLogIgnoreMetrics"`
|
AccessLogIgnoreMetrics bool `toml:"AccessLogIgnoreMetrics"`
|
||||||
Autocert FrontendAutocertConfig `toml:"Autocert"`
|
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.RealIP)
|
||||||
r.Use(middleware.RequestID)
|
r.Use(middleware.RequestID)
|
||||||
r.Use(s.LoggingMiddleware)
|
r.Use(s.LoggingMiddleware)
|
||||||
r.Use(NewMetricsMiddleware())
|
|
||||||
r.Use(middleware.SetHeader("Server", fmt.Sprintf("apiary/%s", apiary.FullVersion())))
|
r.Use(middleware.SetHeader("Server", fmt.Sprintf("apiary/%s", apiary.FullVersion())))
|
||||||
|
|
||||||
|
if cfg.MetricsEnable {
|
||||||
|
r.Use(NewMetricsMiddleware())
|
||||||
r.Handle("/metrics", promhttp.Handler())
|
r.Handle("/metrics", promhttp.Handler())
|
||||||
|
}
|
||||||
r.Route("/", func(r chi.Router) {
|
r.Route("/", func(r chi.Router) {
|
||||||
r.Get("/*", s.IndexHandler("web/vue-frontend/dist"))
|
r.Get("/*", s.IndexHandler("web/vue-frontend/dist"))
|
||||||
r.Get("/stream", s.HandlerAttemptStream)
|
r.Get("/stream", s.HandlerAttemptStream)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user