diff --git a/console_libraries/menu.lib b/console_libraries/menu.lib index dc0678895..6506f18c1 100644 --- a/console_libraries/menu.lib +++ b/console_libraries/menu.lib @@ -17,7 +17,7 @@ diff --git a/console_libraries/prom.lib b/console_libraries/prom.lib index 72ea238e5..32975dbb7 100644 --- a/console_libraries/prom.lib +++ b/console_libraries/prom.lib @@ -1,17 +1,17 @@ {{/* vim: set ft=html: */}} {{/* Load Prometheus console library JS/CSS. Should go in */}} {{ define "prom_console_head" }} - - - - - - - - + + + + + + + + - + {{ end }} {{/* Top of all pages. */}} diff --git a/main.go b/main.go index a146cd91e..ff429867a 100644 --- a/main.go +++ b/main.go @@ -71,7 +71,7 @@ var ( storageDirty = flag.Bool("storage.local.dirty", false, "If set, the local storage layer will perform crash recovery even if the last shutdown appears to be clean.") storagePedanticChecks = flag.Bool("storage.local.pedantic-checks", false, "If set, a crash recovery will perform checks on each series file. This might take a very long time.") - pathPrefix = flag.String("web.path-prefix", "/", "Prefix for all web paths.") + pathPrefix = flag.String("web.path-prefix", "", "Prefix for all web paths.") printVersion = flag.Bool("version", false, "Print version information.") ) @@ -377,12 +377,10 @@ func main() { os.Exit(2) } - if !strings.HasPrefix(*pathPrefix, "/") { + *pathPrefix = strings.TrimRight(*pathPrefix, "/") + if *pathPrefix != "" && !strings.HasPrefix(*pathPrefix, "/") { *pathPrefix = "/" + *pathPrefix } - if !strings.HasSuffix(*pathPrefix, "/") { - *pathPrefix = *pathPrefix + "/" - } versionInfoTmpl.Execute(os.Stdout, BuildInfo) diff --git a/rules/alerting.go b/rules/alerting.go index 65cfab407..4e3d94b79 100644 --- a/rules/alerting.go +++ b/rules/alerting.go @@ -17,7 +17,6 @@ import ( "fmt" "html/template" "reflect" - "strings" "sync" "time" @@ -221,9 +220,9 @@ func (rule *AlertingRule) HTMLSnippet(pathPrefix string) template.HTML { } return template.HTML(fmt.Sprintf( `ALERT %s IF %s FOR %s WITH %s`, - pathPrefix+strings.TrimLeft(utility.GraphLinkForExpression(alertMetric.String()), "/"), + pathPrefix+utility.GraphLinkForExpression(alertMetric.String()), rule.name, - pathPrefix+strings.TrimLeft(utility.GraphLinkForExpression(rule.Vector.String()), "/"), + pathPrefix+utility.GraphLinkForExpression(rule.Vector.String()), rule.Vector, utility.DurationToString(rule.holdDuration), rule.Labels)) diff --git a/rules/recording.go b/rules/recording.go index d9d2b0028..ea4be24d6 100644 --- a/rules/recording.go +++ b/rules/recording.go @@ -17,7 +17,6 @@ import ( "fmt" "html/template" "reflect" - "strings" clientmodel "github.com/prometheus/client_golang/model" @@ -90,9 +89,9 @@ func (rule RecordingRule) HTMLSnippet(pathPrefix string) template.HTML { ruleExpr := rule.vector.String() return template.HTML(fmt.Sprintf( `%s%s = %s`, - pathPrefix+strings.TrimLeft(utility.GraphLinkForExpression(rule.name), "/"), + pathPrefix+utility.GraphLinkForExpression(rule.name), rule.name, rule.labels, - pathPrefix+strings.TrimLeft(utility.GraphLinkForExpression(ruleExpr), "/"), + pathPrefix+utility.GraphLinkForExpression(ruleExpr), ruleExpr)) } diff --git a/templates/templates_test.go b/templates/templates_test.go index b53b0656c..10799065c 100644 --- a/templates/templates_test.go +++ b/templates/templates_test.go @@ -190,7 +190,7 @@ func TestTemplateExpansion(t *testing.T) { for i, s := range scenarios { var result string var err error - expander := NewTemplateExpander(s.text, "test", s.input, time, engine, "/") + expander := NewTemplateExpander(s.text, "test", s.input, time, engine, "") if s.html { result, err = expander.ExpandHTML(nil) } else { diff --git a/web/api/api.go b/web/api/api.go index 40da8d83e..49bfa2d39 100644 --- a/web/api/api.go +++ b/web/api/api.go @@ -39,13 +39,13 @@ func (msrv *MetricsService) RegisterHandler(pathPrefix string) { Handler: http.HandlerFunc(h), } } - http.Handle(pathPrefix+"api/query", prometheus.InstrumentHandler( - pathPrefix+"api/query", handler(msrv.Query), + http.Handle(pathPrefix+"/api/query", prometheus.InstrumentHandler( + pathPrefix+"/api/query", handler(msrv.Query), )) - http.Handle(pathPrefix+"api/query_range", prometheus.InstrumentHandler( - pathPrefix+"api/query_range", handler(msrv.QueryRange), + http.Handle(pathPrefix+"/api/query_range", prometheus.InstrumentHandler( + pathPrefix+"/api/query_range", handler(msrv.QueryRange), )) - http.Handle(pathPrefix+"api/metrics", prometheus.InstrumentHandler( - pathPrefix+"api/metrics", handler(msrv.Metrics), + http.Handle(pathPrefix+"/api/metrics", prometheus.InstrumentHandler( + pathPrefix+"/api/metrics", handler(msrv.Metrics), )) } diff --git a/web/api/api_test.go b/web/api/api_test.go index e16a149ff..a663926cf 100644 --- a/web/api/api_test.go +++ b/web/api/api_test.go @@ -97,7 +97,7 @@ func TestQuery(t *testing.T) { Storage: storage, QueryEngine: promql.NewEngine(storage), } - api.RegisterHandler("/") + api.RegisterHandler("") server := httptest.NewServer(http.DefaultServeMux) defer server.Close() diff --git a/web/static/js/graph.js b/web/static/js/graph.js index 73caf0204..275e751b2 100644 --- a/web/static/js/graph.js +++ b/web/static/js/graph.js @@ -160,7 +160,7 @@ Prometheus.Graph.prototype.populateInsertableMetrics = function() { var self = this; $.ajax({ method: "GET", - url: PATH_PREFIX + "api/metrics", + url: PATH_PREFIX + "/api/metrics", dataType: "json", success: function(json, textStatus) { var availableMetrics = []; @@ -312,7 +312,7 @@ Prometheus.Graph.prototype.submitQuery = function() { url = self.queryForm.attr("action"); success = function(json, textStatus) { self.handleGraphResponse(json, textStatus); }; } else { - url = PATH_PREFIX + "api/query"; + url = PATH_PREFIX + "/api/query"; success = function(text, textStatus) { self.handleConsoleResponse(text, textStatus); }; } @@ -611,7 +611,7 @@ function init() { }); $.ajax({ - url: PATH_PREFIX + "static/js/graph_template.handlebar", + url: PATH_PREFIX + "/static/js/graph_template.handlebar", success: function(data) { graphTemplate = Handlebars.compile(data); var options = parseGraphOptionsFromURL(); diff --git a/web/static/js/graph_template.handlebar b/web/static/js/graph_template.handlebar index 70b8d5f3b..9dafd738e 100644 --- a/web/static/js/graph_template.handlebar +++ b/web/static/js/graph_template.handlebar @@ -1,5 +1,5 @@
-
+
@@ -14,7 +14,7 @@
- ajax_spinner + ajax_spinner
diff --git a/web/static/js/prom_console.js b/web/static/js/prom_console.js index 3c088390c..22587ba2d 100644 --- a/web/static/js/prom_console.js +++ b/web/static/js/prom_console.js @@ -502,7 +502,7 @@ PromConsole.Graph.prototype.dispatch = function() { var pending_requests = this.params.expr.length; for (var i = 0; i < this.params.expr.length; ++i) { var endTime = this.params.endTime; - var url = PATH_PREFIX + "api/query_range?expr=" + encodeURIComponent(this.params.expr[i]) + var url = PATH_PREFIX + "/api/query_range?expr=" + encodeURIComponent(this.params.expr[i]) + "&step=" + this.params.duration / this.graphTd.offsetWidth + "&range=" + this.params.duration + "&end=" + endTime; var xhr = new XMLHttpRequest(); @@ -539,7 +539,7 @@ PromConsole.Graph.prototype.dispatch = function() { } var loadingImg = document.createElement("img"); - loadingImg.src = PATH_PREFIX + 'static/img/ajax-loader.gif'; + loadingImg.src = PATH_PREFIX + '/static/img/ajax-loader.gif'; loadingImg.alt = 'Loading...'; loadingImg.className = 'prom_graph_loading'; this.graphTd.appendChild(loadingImg); @@ -605,6 +605,6 @@ PromConsole._graphsToSlashGraphURL = function(exprs) { for (var i = 0; i < exprs.length; ++i) { data.push({'expr': exprs[i], 'tab': 0}); } - return PATH_PREFIX + 'graph#' + encodeURIComponent(JSON.stringify(data)); + return PATH_PREFIX + '/graph#' + encodeURIComponent(JSON.stringify(data)); }; diff --git a/web/templates/_base.html b/web/templates/_base.html index c36eb1b33..baaa8df93 100644 --- a/web/templates/_base.html +++ b/web/templates/_base.html @@ -3,10 +3,10 @@ Prometheus Time Series Collection and Processing Server - + - - + + @@ -23,7 +23,7 @@ - Prometheus + Prometheus