diff --git a/.gitignore b/.gitignore index 207a4c604d..89dabd032e 100644 --- a/.gitignore +++ b/.gitignore @@ -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* diff --git a/Makefile b/Makefile index 9cadfd1e05..98eccb79cc 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ vet: @echo ">> vetting code" @$(GO) vet $(pkgs) -build: assets +build: @echo ">> building binaries" @./scripts/build.sh diff --git a/cmd/prometheus/config.go b/cmd/prometheus/config.go index 1f5c099d08..a8551eabcb 100644 --- a/cmd/prometheus/config.go +++ b/cmd/prometheus/config.go @@ -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.", diff --git a/web/ui/bindata.go b/web/ui/bindata.go index 070f4f7441..0c67759097 100644 --- a/web/ui/bindata.go +++ b/web/ui/bindata.go @@ -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, "/")...)...) } - diff --git a/web/ui/blob.go b/web/ui/blob.go deleted file mode 100644 index 2d9ccbca3c..0000000000 --- a/web/ui/blob.go +++ /dev/null @@ -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) -} diff --git a/web/ui/templates/_base.html b/web/ui/templates/_base.html new file mode 100644 index 0000000000..61ddc04543 --- /dev/null +++ b/web/ui/templates/_base.html @@ -0,0 +1,53 @@ + + +
+ +