mirror of
https://github.com/prometheus/prometheus
synced 2024-12-27 17:13:22 +00:00
Merge branch 'master' of github.com:prometheus/prometheus
This commit is contained in:
commit
fd26b5b0b3
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/prometheus/prometheus/promql"
|
"github.com/prometheus/prometheus/promql"
|
||||||
"github.com/prometheus/prometheus/storage/local"
|
"github.com/prometheus/prometheus/storage/local"
|
||||||
"github.com/prometheus/prometheus/storage/metric"
|
"github.com/prometheus/prometheus/storage/metric"
|
||||||
|
"github.com/prometheus/prometheus/util/httputil"
|
||||||
"github.com/prometheus/prometheus/util/route"
|
"github.com/prometheus/prometheus/util/route"
|
||||||
"github.com/prometheus/prometheus/util/strutil"
|
"github.com/prometheus/prometheus/util/strutil"
|
||||||
)
|
)
|
||||||
@ -79,7 +80,7 @@ func (api *API) Register(r *route.Router) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
instr := func(name string, f apiFunc) http.HandlerFunc {
|
instr := func(name string, f apiFunc) http.HandlerFunc {
|
||||||
return prometheus.InstrumentHandlerFunc(name, func(w http.ResponseWriter, r *http.Request) {
|
hf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
setCORS(w)
|
setCORS(w)
|
||||||
if data, err := f(r); err != nil {
|
if data, err := f(r); err != nil {
|
||||||
respondError(w, err, data)
|
respondError(w, err, data)
|
||||||
@ -87,6 +88,7 @@ func (api *API) Register(r *route.Router) {
|
|||||||
respond(w, data)
|
respond(w, data)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
return prometheus.InstrumentHandler(name, httputil.CompressionHandler{hf})
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Get("/query", instr("query", api.query))
|
r.Get("/query", instr("query", api.query))
|
||||||
|
@ -41,6 +41,7 @@ import (
|
|||||||
"github.com/prometheus/prometheus/rules"
|
"github.com/prometheus/prometheus/rules"
|
||||||
"github.com/prometheus/prometheus/storage/local"
|
"github.com/prometheus/prometheus/storage/local"
|
||||||
"github.com/prometheus/prometheus/template"
|
"github.com/prometheus/prometheus/template"
|
||||||
|
"github.com/prometheus/prometheus/util/httputil"
|
||||||
"github.com/prometheus/prometheus/util/route"
|
"github.com/prometheus/prometheus/util/route"
|
||||||
"github.com/prometheus/prometheus/version"
|
"github.com/prometheus/prometheus/version"
|
||||||
"github.com/prometheus/prometheus/web/api/legacy"
|
"github.com/prometheus/prometheus/web/api/legacy"
|
||||||
@ -155,8 +156,12 @@ func New(st local.Storage, qe *promql.Engine, rm *rules.Manager, status *Prometh
|
|||||||
router = router.WithPrefix(o.ExternalURL.Path)
|
router = router.WithPrefix(o.ExternalURL.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
instrf := prometheus.InstrumentHandlerFunc
|
instrh := func(name string, h http.Handler) http.HandlerFunc {
|
||||||
instrh := prometheus.InstrumentHandler
|
return prometheus.InstrumentHandler(name, httputil.CompressionHandler{h})
|
||||||
|
}
|
||||||
|
instrf := func(name string, f http.HandlerFunc) http.HandlerFunc {
|
||||||
|
return instrh(name, f)
|
||||||
|
}
|
||||||
|
|
||||||
router.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
router.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Redirect(w, r, "/graph", http.StatusFound)
|
http.Redirect(w, r, "/graph", http.StatusFound)
|
||||||
|
Loading…
Reference in New Issue
Block a user