diff --git a/web/api/api.go b/web/api/api.go index 572eb515dd..da69775e75 100644 --- a/web/api/api.go +++ b/web/api/api.go @@ -24,7 +24,7 @@ import ( type MetricsService struct { gorest.RestService `root:"/api/" consumes:"application/json" produces:"application/json"` - query gorest.EndPoint `method:"GET" path:"/query?{expr:string}&{json:string}" output:"string"` + query gorest.EndPoint `method:"GET" path:"/query?{expr:string}&{as_text:string}" output:"string"` queryRange gorest.EndPoint `method:"GET" path:"/query_range?{expr:string}&{end:int64}&{range:int64}&{step:int64}" output:"string"` metrics gorest.EndPoint `method:"GET" path:"/metrics" output:"string"` diff --git a/web/api/query.go b/web/api/query.go index 85c0866fc7..3ce26049bc 100644 --- a/web/api/query.go +++ b/web/api/query.go @@ -37,7 +37,7 @@ func (serv MetricsService) setAccessControlHeaders(rb *gorest.ResponseBuilder) { rb.AddHeader("Access-Control-Expose-Headers", "Date") } -func (serv MetricsService) Query(expr string, formatJson string) string { +func (serv MetricsService) Query(expr string, asText string) string { exprNode, err := rules.LoadExprFromString(expr) if err != nil { return ast.ErrorToJSON(err) @@ -48,7 +48,8 @@ func (serv MetricsService) Query(expr string, formatJson string) string { rb := serv.ResponseBuilder() serv.setAccessControlHeaders(rb) var format ast.OutputFormat - if formatJson != "" { + // BUG(julius): Use Content-Type negotiation. + if asText == "" { format = ast.JSON rb.SetContentType(gorest.Application_Json) } else { diff --git a/web/static/css/graph.css b/web/static/css/graph.css index 0967844147..b8c1907891 100644 --- a/web/static/css/graph.css +++ b/web/static/css/graph.css @@ -107,9 +107,8 @@ input[title=*]:hover:after { display: inline; } -.console { - white-space: pre; - overflow: scroll; +.console_table { + margin-top: 5px; } .ui-widget { diff --git a/web/static/js/graph.js b/web/static/js/graph.js index 4eb78304da..ffb6ce919a 100644 --- a/web/static/js/graph.js +++ b/web/static/js/graph.js @@ -293,26 +293,22 @@ Prometheus.Graph.prototype.submitQuery = function() { self.queryForm.find("input[name=end]").val(endDate); if (self.queryXhr) { - self.queryXhr.abort() + self.queryXhr.abort(); } - var url - var data + var url; + var success; if (self.tab[0] == self.graphTab[0]) { - url = self.queryForm.attr("action") - data = self.queryForm.serialize() - dataType = "json" - success = function(json, textStatus) { self.handleGraphResponse(json, textStatus) } + url = self.queryForm.attr("action"); + success = function(json, textStatus) { self.handleGraphResponse(json, textStatus); }; } else { - url = '/api/query' - data = self.expr.serialize() - dataType = "text" - success = function(text, textStatus) { self.handleConsoleResponse(text, textStatus) } + url = "/api/query"; + success = function(text, textStatus) { self.handleConsoleResponse(text, textStatus); }; } self.queryXhr = $.ajax({ method: self.queryForm.attr("method"), url: url, - dataType: dataType, + dataType: "json", data: self.queryForm.serialize(), success: success, error: function(xhr, resp) { @@ -507,20 +503,39 @@ Prometheus.Graph.prototype.handleGraphResponse = function(json, textStatus) { self.updateGraph(true); } -Prometheus.Graph.prototype.handleConsoleResponse = function(text, textStatus) { +Prometheus.Graph.prototype.handleConsoleResponse = function(data, textStatus) { var self = this; - var body = "
Element | +Value | + + + +
---|