|
|
@ -385,18 +385,18 @@ Prometheus.Graph.prototype.parseValue = function(value) {
|
|
|
|
Prometheus.Graph.prototype.transformData = function(json) {
|
|
|
|
Prometheus.Graph.prototype.transformData = function(json) {
|
|
|
|
self = this;
|
|
|
|
self = this;
|
|
|
|
var palette = new Rickshaw.Color.Palette();
|
|
|
|
var palette = new Rickshaw.Color.Palette();
|
|
|
|
if (json.Type != "matrix") {
|
|
|
|
if (json.type != "matrix") {
|
|
|
|
self.showError("Result is not of matrix type! Please enter a correct expression.");
|
|
|
|
self.showError("Result is not of matrix type! Please enter a correct expression.");
|
|
|
|
return [];
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var data = json.Value.map(function(ts) {
|
|
|
|
var data = json.value.map(function(ts) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
name: escapeHTML(self.metricToTsName(ts.Metric)),
|
|
|
|
name: escapeHTML(self.metricToTsName(ts.metric)),
|
|
|
|
labels: ts.Metric,
|
|
|
|
labels: ts.metric,
|
|
|
|
data: ts.Values.map(function(value) {
|
|
|
|
data: ts.values.map(function(value) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
x: value.Timestamp,
|
|
|
|
x: value[0],
|
|
|
|
y: self.parseValue(value.Value)
|
|
|
|
y: self.parseValue(value[1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
color: palette.color()
|
|
|
|
color: palette.color()
|
|
|
@ -506,8 +506,8 @@ Prometheus.Graph.prototype.resizeGraph = function() {
|
|
|
|
|
|
|
|
|
|
|
|
Prometheus.Graph.prototype.handleGraphResponse = function(json, textStatus) {
|
|
|
|
Prometheus.Graph.prototype.handleGraphResponse = function(json, textStatus) {
|
|
|
|
var self = this
|
|
|
|
var self = this
|
|
|
|
if (json.Type == "error") {
|
|
|
|
if (json.type == "error") {
|
|
|
|
self.showError(json.Value);
|
|
|
|
self.showError(json.value);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.data = self.transformData(json);
|
|
|
|
self.data = self.transformData(json);
|
|
|
@ -526,38 +526,38 @@ Prometheus.Graph.prototype.handleConsoleResponse = function(data, textStatus) {
|
|
|
|
var tBody = self.consoleTab.find(".console_table tbody");
|
|
|
|
var tBody = self.consoleTab.find(".console_table tbody");
|
|
|
|
tBody.empty();
|
|
|
|
tBody.empty();
|
|
|
|
|
|
|
|
|
|
|
|
switch(data.Type) {
|
|
|
|
switch(data.type) {
|
|
|
|
case "vector":
|
|
|
|
case "vector":
|
|
|
|
if (data.Value.length === 0) {
|
|
|
|
if (data.value.length === 0) {
|
|
|
|
tBody.append("<tr><td colspan='2'><i>no data</i></td></tr>");
|
|
|
|
tBody.append("<tr><td colspan='2'><i>no data</i></td></tr>");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var i = 0; i < data.Value.length; i++) {
|
|
|
|
for (var i = 0; i < data.value.length; i++) {
|
|
|
|
var v = data.Value[i];
|
|
|
|
var v = data.value[i];
|
|
|
|
var tsName = self.metricToTsName(v.Metric);
|
|
|
|
var tsName = self.metricToTsName(v.metric);
|
|
|
|
tBody.append("<tr><td>" + escapeHTML(tsName) + "</td><td>" + v.Value + "</td></tr>");
|
|
|
|
tBody.append("<tr><td>" + escapeHTML(tsName) + "</td><td>" + v.value + "</td></tr>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "matrix":
|
|
|
|
case "matrix":
|
|
|
|
if (data.Value.length === 0) {
|
|
|
|
if (data.value.length === 0) {
|
|
|
|
tBody.append("<tr><td colspan='2'><i>no data</i></td></tr>");
|
|
|
|
tBody.append("<tr><td colspan='2'><i>no data</i></td></tr>");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var i = 0; i < data.Value.length; i++) {
|
|
|
|
for (var i = 0; i < data.value.length; i++) {
|
|
|
|
var v = data.Value[i];
|
|
|
|
var v = data.value[i];
|
|
|
|
var tsName = self.metricToTsName(v.Metric);
|
|
|
|
var tsName = self.metricToTsName(v.metric);
|
|
|
|
var valueText = "";
|
|
|
|
var valueText = "";
|
|
|
|
for (var j = 0; j < v.Values.length; j++) {
|
|
|
|
for (var j = 0; j < v.values.length; j++) {
|
|
|
|
valueText += v.Values[j].Value + " @" + v.Values[j].Timestamp + "<br/>";
|
|
|
|
valueText += v.values[j][1] + " @" + v.values[j][0] + "<br/>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tBody.append("<tr><td>" + escapeHTML(tsName) + "</td><td>" + valueText + "</td></tr>")
|
|
|
|
tBody.append("<tr><td>" + escapeHTML(tsName) + "</td><td>" + valueText + "</td></tr>")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "scalar":
|
|
|
|
case "scalar":
|
|
|
|
tBody.append("<tr><td>scalar</td><td>" + data.Value + "</td></tr>");
|
|
|
|
tBody.append("<tr><td>scalar</td><td>" + data.value + "</td></tr>");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "error":
|
|
|
|
case "error":
|
|
|
|
self.showError(data.Value);
|
|
|
|
self.showError(data.value);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
self.showError("Unsupported value type!");
|
|
|
|
self.showError("Unsupported value type!");
|
|
|
|