mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Remove -web.use-local-assets
This commit is contained in:
parent
57ca7108aa
commit
a542cc8609
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -21,11 +21,8 @@
|
|||
.idea
|
||||
|
||||
.DS_Store
|
||||
._*
|
||||
.nfs.*
|
||||
/.git
|
||||
[568a].out
|
||||
_cgo_*
|
||||
core
|
||||
|
||||
*-stamp
|
||||
|
@ -38,6 +35,5 @@ benchmark.txt
|
|||
.#*
|
||||
command-line-arguments.test
|
||||
*BACKUP*
|
||||
*BASE*
|
||||
*LOCAL*
|
||||
*REMOTE*
|
||||
|
|
2
Makefile
2
Makefile
|
@ -33,7 +33,7 @@ vet:
|
|||
@echo ">> vetting code"
|
||||
@$(GO) vet $(pkgs)
|
||||
|
||||
build: assets
|
||||
build:
|
||||
@echo ">> building binaries"
|
||||
@./scripts/build.sh
|
||||
|
||||
|
|
|
@ -82,10 +82,6 @@ func init() {
|
|||
&cfg.web.MetricsPath, "web.telemetry-path", "/metrics",
|
||||
"Path under which to expose metrics.",
|
||||
)
|
||||
cfg.fs.BoolVar(
|
||||
&cfg.web.UseLocalAssets, "web.use-local-assets", false,
|
||||
"Read assets/templates from file instead of binary.",
|
||||
)
|
||||
cfg.fs.StringVar(
|
||||
&cfg.web.UserAssetsPath, "web.user-assets", "",
|
||||
"Path to static asset directory, available at /user.",
|
||||
|
|
|
@ -114,7 +114,7 @@ func webUiTemplates_baseHtml() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "web/ui/templates/_base.html", size: 2017, mode: os.FileMode(420), modTime: time.Unix(1446678753, 0)}
|
||||
info := bindataFileInfo{name: "web/ui/templates/_base.html", size: 2017, mode: os.FileMode(420), modTime: time.Unix(1447256084, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
@ -791,38 +791,38 @@ func AssetNames() []string {
|
|||
|
||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||
var _bindata = map[string]func() (*asset, error){
|
||||
"web/ui/templates/_base.html": webUiTemplates_baseHtml,
|
||||
"web/ui/templates/alerts.html": webUiTemplatesAlertsHtml,
|
||||
"web/ui/templates/graph.html": webUiTemplatesGraphHtml,
|
||||
"web/ui/templates/status.html": webUiTemplatesStatusHtml,
|
||||
"web/ui/static/css/alerts.css": webUiStaticCssAlertsCss,
|
||||
"web/ui/static/css/graph.css": webUiStaticCssGraphCss,
|
||||
"web/ui/static/css/prom_console.css": webUiStaticCssProm_consoleCss,
|
||||
"web/ui/static/css/prometheus.css": webUiStaticCssPrometheusCss,
|
||||
"web/ui/static/img/ajax-loader.gif": webUiStaticImgAjaxLoaderGif,
|
||||
"web/ui/static/js/alerts.js": webUiStaticJsAlertsJs,
|
||||
"web/ui/static/js/graph.js": webUiStaticJsGraphJs,
|
||||
"web/ui/static/js/graph_template.handlebar": webUiStaticJsGraph_templateHandlebar,
|
||||
"web/ui/static/js/prom_console.js": webUiStaticJsProm_consoleJs,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/css/bootstrap-theme.min.css": webUiStaticVendorBootstrap331CssBootstrapThemeMinCss,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css": webUiStaticVendorBootstrap331CssBootstrapMinCss,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.eot": webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularEot,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.svg": webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularSvg,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.ttf": webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularTtf,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.woff": webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularWoff,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js": webUiStaticVendorBootstrap331JsBootstrapMinJs,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/js/npm.js": webUiStaticVendorBootstrap331JsNpmJs,
|
||||
"web/ui/static/vendor/bootstrap-datetimepicker/bootstrap-datetimepicker.js": webUiStaticVendorBootstrapDatetimepickerBootstrapDatetimepickerJs,
|
||||
"web/ui/templates/_base.html": webUiTemplates_baseHtml,
|
||||
"web/ui/templates/alerts.html": webUiTemplatesAlertsHtml,
|
||||
"web/ui/templates/graph.html": webUiTemplatesGraphHtml,
|
||||
"web/ui/templates/status.html": webUiTemplatesStatusHtml,
|
||||
"web/ui/static/css/alerts.css": webUiStaticCssAlertsCss,
|
||||
"web/ui/static/css/graph.css": webUiStaticCssGraphCss,
|
||||
"web/ui/static/css/prom_console.css": webUiStaticCssProm_consoleCss,
|
||||
"web/ui/static/css/prometheus.css": webUiStaticCssPrometheusCss,
|
||||
"web/ui/static/img/ajax-loader.gif": webUiStaticImgAjaxLoaderGif,
|
||||
"web/ui/static/js/alerts.js": webUiStaticJsAlertsJs,
|
||||
"web/ui/static/js/graph.js": webUiStaticJsGraphJs,
|
||||
"web/ui/static/js/graph_template.handlebar": webUiStaticJsGraph_templateHandlebar,
|
||||
"web/ui/static/js/prom_console.js": webUiStaticJsProm_consoleJs,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/css/bootstrap-theme.min.css": webUiStaticVendorBootstrap331CssBootstrapThemeMinCss,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css": webUiStaticVendorBootstrap331CssBootstrapMinCss,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.eot": webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularEot,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.svg": webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularSvg,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.ttf": webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularTtf,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.woff": webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularWoff,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js": webUiStaticVendorBootstrap331JsBootstrapMinJs,
|
||||
"web/ui/static/vendor/bootstrap-3.3.1/js/npm.js": webUiStaticVendorBootstrap331JsNpmJs,
|
||||
"web/ui/static/vendor/bootstrap-datetimepicker/bootstrap-datetimepicker.js": webUiStaticVendorBootstrapDatetimepickerBootstrapDatetimepickerJs,
|
||||
"web/ui/static/vendor/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css": webUiStaticVendorBootstrapDatetimepickerBootstrapDatetimepickerMinCss,
|
||||
"web/ui/static/vendor/bootstrap3-typeahead/bootstrap3-typeahead.min.js": webUiStaticVendorBootstrap3TypeaheadBootstrap3TypeaheadMinJs,
|
||||
"web/ui/static/vendor/js/handlebars.js": webUiStaticVendorJsHandlebarsJs,
|
||||
"web/ui/static/vendor/js/jquery.hotkeys.js": webUiStaticVendorJsJqueryHotkeysJs,
|
||||
"web/ui/static/vendor/js/jquery.min.js": webUiStaticVendorJsJqueryMinJs,
|
||||
"web/ui/static/vendor/js/jquery.selection.js": webUiStaticVendorJsJquerySelectionJs,
|
||||
"web/ui/static/vendor/rickshaw/rickshaw.min.css": webUiStaticVendorRickshawRickshawMinCss,
|
||||
"web/ui/static/vendor/rickshaw/rickshaw.min.js": webUiStaticVendorRickshawRickshawMinJs,
|
||||
"web/ui/static/vendor/rickshaw/vendor/d3.layout.min.js": webUiStaticVendorRickshawVendorD3LayoutMinJs,
|
||||
"web/ui/static/vendor/rickshaw/vendor/d3.v3.js": webUiStaticVendorRickshawVendorD3V3Js,
|
||||
"web/ui/static/vendor/bootstrap3-typeahead/bootstrap3-typeahead.min.js": webUiStaticVendorBootstrap3TypeaheadBootstrap3TypeaheadMinJs,
|
||||
"web/ui/static/vendor/js/handlebars.js": webUiStaticVendorJsHandlebarsJs,
|
||||
"web/ui/static/vendor/js/jquery.hotkeys.js": webUiStaticVendorJsJqueryHotkeysJs,
|
||||
"web/ui/static/vendor/js/jquery.min.js": webUiStaticVendorJsJqueryMinJs,
|
||||
"web/ui/static/vendor/js/jquery.selection.js": webUiStaticVendorJsJquerySelectionJs,
|
||||
"web/ui/static/vendor/rickshaw/rickshaw.min.css": webUiStaticVendorRickshawRickshawMinCss,
|
||||
"web/ui/static/vendor/rickshaw/rickshaw.min.js": webUiStaticVendorRickshawRickshawMinJs,
|
||||
"web/ui/static/vendor/rickshaw/vendor/d3.layout.min.js": webUiStaticVendorRickshawVendorD3LayoutMinJs,
|
||||
"web/ui/static/vendor/rickshaw/vendor/d3.v3.js": webUiStaticVendorRickshawVendorD3V3Js,
|
||||
}
|
||||
|
||||
// AssetDir returns the file names below a certain
|
||||
|
@ -864,69 +864,70 @@ type bintree struct {
|
|||
Func func() (*asset, error)
|
||||
Children map[string]*bintree
|
||||
}
|
||||
|
||||
var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"web": &bintree{nil, map[string]*bintree{
|
||||
"ui": &bintree{nil, map[string]*bintree{
|
||||
"static": &bintree{nil, map[string]*bintree{
|
||||
"css": &bintree{nil, map[string]*bintree{
|
||||
"alerts.css": &bintree{webUiStaticCssAlertsCss, map[string]*bintree{}},
|
||||
"graph.css": &bintree{webUiStaticCssGraphCss, map[string]*bintree{}},
|
||||
"alerts.css": &bintree{webUiStaticCssAlertsCss, map[string]*bintree{}},
|
||||
"graph.css": &bintree{webUiStaticCssGraphCss, map[string]*bintree{}},
|
||||
"prom_console.css": &bintree{webUiStaticCssProm_consoleCss, map[string]*bintree{}},
|
||||
"prometheus.css": &bintree{webUiStaticCssPrometheusCss, map[string]*bintree{}},
|
||||
"prometheus.css": &bintree{webUiStaticCssPrometheusCss, map[string]*bintree{}},
|
||||
}},
|
||||
"img": &bintree{nil, map[string]*bintree{
|
||||
"ajax-loader.gif": &bintree{webUiStaticImgAjaxLoaderGif, map[string]*bintree{}},
|
||||
}},
|
||||
"js": &bintree{nil, map[string]*bintree{
|
||||
"alerts.js": &bintree{webUiStaticJsAlertsJs, map[string]*bintree{}},
|
||||
"graph.js": &bintree{webUiStaticJsGraphJs, map[string]*bintree{}},
|
||||
"alerts.js": &bintree{webUiStaticJsAlertsJs, map[string]*bintree{}},
|
||||
"graph.js": &bintree{webUiStaticJsGraphJs, map[string]*bintree{}},
|
||||
"graph_template.handlebar": &bintree{webUiStaticJsGraph_templateHandlebar, map[string]*bintree{}},
|
||||
"prom_console.js": &bintree{webUiStaticJsProm_consoleJs, map[string]*bintree{}},
|
||||
"prom_console.js": &bintree{webUiStaticJsProm_consoleJs, map[string]*bintree{}},
|
||||
}},
|
||||
"vendor": &bintree{nil, map[string]*bintree{
|
||||
"bootstrap-3.3.1": &bintree{nil, map[string]*bintree{
|
||||
"css": &bintree{nil, map[string]*bintree{
|
||||
"bootstrap-theme.min.css": &bintree{webUiStaticVendorBootstrap331CssBootstrapThemeMinCss, map[string]*bintree{}},
|
||||
"bootstrap.min.css": &bintree{webUiStaticVendorBootstrap331CssBootstrapMinCss, map[string]*bintree{}},
|
||||
"bootstrap.min.css": &bintree{webUiStaticVendorBootstrap331CssBootstrapMinCss, map[string]*bintree{}},
|
||||
}},
|
||||
"fonts": &bintree{nil, map[string]*bintree{
|
||||
"glyphicons-halflings-regular.eot": &bintree{webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularEot, map[string]*bintree{}},
|
||||
"glyphicons-halflings-regular.svg": &bintree{webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularSvg, map[string]*bintree{}},
|
||||
"glyphicons-halflings-regular.ttf": &bintree{webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularTtf, map[string]*bintree{}},
|
||||
"glyphicons-halflings-regular.eot": &bintree{webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularEot, map[string]*bintree{}},
|
||||
"glyphicons-halflings-regular.svg": &bintree{webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularSvg, map[string]*bintree{}},
|
||||
"glyphicons-halflings-regular.ttf": &bintree{webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularTtf, map[string]*bintree{}},
|
||||
"glyphicons-halflings-regular.woff": &bintree{webUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularWoff, map[string]*bintree{}},
|
||||
}},
|
||||
"js": &bintree{nil, map[string]*bintree{
|
||||
"bootstrap.min.js": &bintree{webUiStaticVendorBootstrap331JsBootstrapMinJs, map[string]*bintree{}},
|
||||
"npm.js": &bintree{webUiStaticVendorBootstrap331JsNpmJs, map[string]*bintree{}},
|
||||
"npm.js": &bintree{webUiStaticVendorBootstrap331JsNpmJs, map[string]*bintree{}},
|
||||
}},
|
||||
}},
|
||||
"bootstrap-datetimepicker": &bintree{nil, map[string]*bintree{
|
||||
"bootstrap-datetimepicker.js": &bintree{webUiStaticVendorBootstrapDatetimepickerBootstrapDatetimepickerJs, map[string]*bintree{}},
|
||||
"bootstrap-datetimepicker.js": &bintree{webUiStaticVendorBootstrapDatetimepickerBootstrapDatetimepickerJs, map[string]*bintree{}},
|
||||
"bootstrap-datetimepicker.min.css": &bintree{webUiStaticVendorBootstrapDatetimepickerBootstrapDatetimepickerMinCss, map[string]*bintree{}},
|
||||
}},
|
||||
"bootstrap3-typeahead": &bintree{nil, map[string]*bintree{
|
||||
"bootstrap3-typeahead.min.js": &bintree{webUiStaticVendorBootstrap3TypeaheadBootstrap3TypeaheadMinJs, map[string]*bintree{}},
|
||||
}},
|
||||
"js": &bintree{nil, map[string]*bintree{
|
||||
"handlebars.js": &bintree{webUiStaticVendorJsHandlebarsJs, map[string]*bintree{}},
|
||||
"jquery.hotkeys.js": &bintree{webUiStaticVendorJsJqueryHotkeysJs, map[string]*bintree{}},
|
||||
"jquery.min.js": &bintree{webUiStaticVendorJsJqueryMinJs, map[string]*bintree{}},
|
||||
"handlebars.js": &bintree{webUiStaticVendorJsHandlebarsJs, map[string]*bintree{}},
|
||||
"jquery.hotkeys.js": &bintree{webUiStaticVendorJsJqueryHotkeysJs, map[string]*bintree{}},
|
||||
"jquery.min.js": &bintree{webUiStaticVendorJsJqueryMinJs, map[string]*bintree{}},
|
||||
"jquery.selection.js": &bintree{webUiStaticVendorJsJquerySelectionJs, map[string]*bintree{}},
|
||||
}},
|
||||
"rickshaw": &bintree{nil, map[string]*bintree{
|
||||
"rickshaw.min.css": &bintree{webUiStaticVendorRickshawRickshawMinCss, map[string]*bintree{}},
|
||||
"rickshaw.min.js": &bintree{webUiStaticVendorRickshawRickshawMinJs, map[string]*bintree{}},
|
||||
"rickshaw.min.js": &bintree{webUiStaticVendorRickshawRickshawMinJs, map[string]*bintree{}},
|
||||
"vendor": &bintree{nil, map[string]*bintree{
|
||||
"d3.layout.min.js": &bintree{webUiStaticVendorRickshawVendorD3LayoutMinJs, map[string]*bintree{}},
|
||||
"d3.v3.js": &bintree{webUiStaticVendorRickshawVendorD3V3Js, map[string]*bintree{}},
|
||||
"d3.v3.js": &bintree{webUiStaticVendorRickshawVendorD3V3Js, map[string]*bintree{}},
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
"templates": &bintree{nil, map[string]*bintree{
|
||||
"_base.html": &bintree{webUiTemplates_baseHtml, map[string]*bintree{}},
|
||||
"_base.html": &bintree{webUiTemplates_baseHtml, map[string]*bintree{}},
|
||||
"alerts.html": &bintree{webUiTemplatesAlertsHtml, map[string]*bintree{}},
|
||||
"graph.html": &bintree{webUiTemplatesGraphHtml, map[string]*bintree{}},
|
||||
"graph.html": &bintree{webUiTemplatesGraphHtml, map[string]*bintree{}},
|
||||
"status.html": &bintree{webUiTemplatesStatusHtml, map[string]*bintree{}},
|
||||
}},
|
||||
}},
|
||||
|
@ -979,4 +980,3 @@ func _filePath(dir, name string) string {
|
|||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package blob
|
||||
|
||||
//go:generate go-bindata -pkg blob -o files.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' templates/... static/...
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/common/log"
|
||||
"github.com/prometheus/common/route"
|
||||
)
|
||||
|
||||
// Sub-directories for templates and static content.
|
||||
const (
|
||||
TemplateFiles = "templates"
|
||||
StaticFiles = "static"
|
||||
)
|
||||
|
||||
var mimeMap = map[string]string{
|
||||
"css": "text/css",
|
||||
"js": "text/javascript",
|
||||
"descriptor": "application/vnd.google.protobuf;proto=google.protobuf.FileDescriptorSet",
|
||||
}
|
||||
|
||||
// GetFile retrieves the content of an embedded file.
|
||||
func GetFile(bucket string, name string) ([]byte, error) {
|
||||
data, err := Asset(fmt.Sprintf("%s/%s", bucket, name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// Handler implements http.Handler.
|
||||
type Handler struct{}
|
||||
|
||||
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := route.Context(r)
|
||||
|
||||
name := strings.Trim(route.Param(ctx, "filepath"), "/")
|
||||
if name == "" {
|
||||
name = "index.html"
|
||||
}
|
||||
|
||||
file, err := GetFile(StaticFiles, name)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
log.Warn("Could not get file: ", err)
|
||||
}
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
contentType := http.DetectContentType(file)
|
||||
if strings.Contains(contentType, "text/plain") || strings.Contains(contentType, "application/octet-stream") {
|
||||
parts := strings.Split(name, ".")
|
||||
contentType = mimeMap[parts[len(parts)-1]]
|
||||
}
|
||||
w.Header().Set("Content-Type", contentType)
|
||||
w.Header().Set("Cache-Control", "public, max-age=259200")
|
||||
w.Write(file)
|
||||
}
|
53
web/ui/templates/_base.html
Normal file
53
web/ui/templates/_base.html
Normal file
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Prometheus Time Series Collection and Processing Server</title>
|
||||
<script src="{{ pathPrefix }}/static/vendor/js/jquery.min.js"></script>
|
||||
<script src="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js"></script>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/prometheus.css">
|
||||
|
||||
<script>
|
||||
var PATH_PREFIX = "{{ pathPrefix }}";
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
})
|
||||
</script>
|
||||
|
||||
{{template "head" .}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{ pathPrefix }}/">Prometheus</a>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
{{$consoles := consolesPath}}
|
||||
{{if $consoles}}
|
||||
<li><a href="{{$consoles}}">Consoles</a></li>
|
||||
{{ end }}
|
||||
<li><a href="{{ pathPrefix }}/alerts">Alerts</a></li>
|
||||
<li><a href="{{ pathPrefix }}/graph">Graph</a></li>
|
||||
<li><a href="{{ pathPrefix }}/status">Status</a></li>
|
||||
<li>
|
||||
<a href="http://prometheus.io" target="_blank">Help</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{{template "content" .}}
|
||||
</body>
|
||||
</html>
|
78
web/web.go
78
web/web.go
|
@ -14,6 +14,7 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -46,7 +47,7 @@ import (
|
|||
"github.com/prometheus/prometheus/version"
|
||||
"github.com/prometheus/prometheus/web/api/legacy"
|
||||
"github.com/prometheus/prometheus/web/api/v1"
|
||||
"github.com/prometheus/prometheus/web/blob"
|
||||
"github.com/prometheus/prometheus/web/ui"
|
||||
)
|
||||
|
||||
var localhostRepresentations = []string{"127.0.0.1", "localhost"}
|
||||
|
@ -181,11 +182,7 @@ func New(st local.Storage, qe *promql.Engine, rm *rules.Manager, status *Prometh
|
|||
|
||||
router.Get("/consoles/*filepath", instrf("consoles", h.consoles))
|
||||
|
||||
if o.UseLocalAssets {
|
||||
router.Get("/static/*filepath", instrf("static", route.FileServe("web/blob/static")))
|
||||
} else {
|
||||
router.Get("/static/*filepath", instrh("static", blob.Handler{}))
|
||||
}
|
||||
router.Get("/static/*filepath", instrf("static", serveStaticAsset))
|
||||
|
||||
if o.UserAssetsPath != "" {
|
||||
router.Get("/user/*filepath", instrf("user", route.FileServe(o.UserAssetsPath)))
|
||||
|
@ -203,6 +200,28 @@ func New(st local.Storage, qe *promql.Engine, rm *rules.Manager, status *Prometh
|
|||
return h
|
||||
}
|
||||
|
||||
func serveStaticAsset(w http.ResponseWriter, req *http.Request) {
|
||||
fp := route.Param(route.Context(req), "filepath")
|
||||
fp = filepath.Join("web/ui/static", fp)
|
||||
|
||||
info, err := ui.AssetInfo(fp)
|
||||
if err != nil {
|
||||
log.With("file", fp).Warn("Could not get file info: ", err)
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
file, err := ui.Asset(fp)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
log.With("file", fp).Warn("Could not get file: ", err)
|
||||
}
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
http.ServeContent(w, req, info.Name(), info.ModTime(), bytes.NewReader(file))
|
||||
}
|
||||
|
||||
// ListenError returns the receive-only channel that signals errors while starting the web server.
|
||||
func (h *Handler) ListenError() <-chan error {
|
||||
return h.listenErrCh
|
||||
|
@ -237,7 +256,7 @@ func (h *Handler) alerts(w http.ResponseWriter, r *http.Request) {
|
|||
rules.StateFiring: "danger",
|
||||
},
|
||||
}
|
||||
h.executeTemplate(w, "alerts", alertStatus)
|
||||
h.executeTemplate(w, "alerts.html", alertStatus)
|
||||
}
|
||||
|
||||
func (h *Handler) consoles(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -291,14 +310,14 @@ func (h *Handler) consoles(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func (h *Handler) graph(w http.ResponseWriter, r *http.Request) {
|
||||
h.executeTemplate(w, "graph", nil)
|
||||
h.executeTemplate(w, "graph.html", nil)
|
||||
}
|
||||
|
||||
func (h *Handler) status(w http.ResponseWriter, r *http.Request) {
|
||||
h.statusInfo.mu.RLock()
|
||||
defer h.statusInfo.mu.RUnlock()
|
||||
|
||||
h.executeTemplate(w, "status", struct {
|
||||
h.executeTemplate(w, "status.html", struct {
|
||||
Status *PrometheusStatus
|
||||
Info map[string]string
|
||||
}{
|
||||
|
@ -324,23 +343,6 @@ func (h *Handler) reload(w http.ResponseWriter, r *http.Request) {
|
|||
h.reloadCh <- struct{}{}
|
||||
}
|
||||
|
||||
func (h *Handler) getTemplateFile(name string) (string, error) {
|
||||
if h.options.UseLocalAssets {
|
||||
file, err := ioutil.ReadFile(fmt.Sprintf("web/blob/templates/%s.html", name))
|
||||
if err != nil {
|
||||
log.Errorf("Could not read %s template: %s", name, err)
|
||||
return "", err
|
||||
}
|
||||
return string(file), nil
|
||||
}
|
||||
file, err := blob.GetFile(blob.TemplateFiles, name+".html")
|
||||
if err != nil {
|
||||
log.Errorf("Could not read %s template: %s", name, err)
|
||||
return "", err
|
||||
}
|
||||
return string(file), nil
|
||||
}
|
||||
|
||||
func (h *Handler) consolesPath() string {
|
||||
if _, err := os.Stat(h.options.ConsoleTemplatesPath + "/index.html"); !os.IsNotExist(err) {
|
||||
return h.options.ExternalURL.Path + "/consoles/index.html"
|
||||
|
@ -353,18 +355,6 @@ func (h *Handler) consolesPath() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (h *Handler) getTemplate(name string) (string, error) {
|
||||
baseTmpl, err := h.getTemplateFile("_base")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error reading base template: %s", err)
|
||||
}
|
||||
pageTmpl, err := h.getTemplateFile(name)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error reading page template %s: %s", name, err)
|
||||
}
|
||||
return baseTmpl + pageTmpl, nil
|
||||
}
|
||||
|
||||
func tmplFuncs(consolesPath string, opts *Options) template_text.FuncMap {
|
||||
return template_text.FuncMap{
|
||||
"since": time.Since,
|
||||
|
@ -439,6 +429,18 @@ func tmplFuncs(consolesPath string, opts *Options) template_text.FuncMap {
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Handler) getTemplate(name string) (string, error) {
|
||||
baseTmpl, err := ui.Asset("web/ui/templates/_base.html")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error reading base template: %s", err)
|
||||
}
|
||||
pageTmpl, err := ui.Asset(filepath.Join("web/ui/templates", name))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error reading page template %s: %s", name, err)
|
||||
}
|
||||
return string(baseTmpl) + string(pageTmpl), nil
|
||||
}
|
||||
|
||||
func (h *Handler) executeTemplate(w http.ResponseWriter, name string, data interface{}) {
|
||||
text, err := h.getTemplate(name)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue