mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
Limit number of merics in prometheus UI (#5139)
Signed-off-by: Vishnunarayan K I <appukuttancr@gmail.com>
This commit is contained in:
parent
50e1228f88
commit
108b9b0e5f
File diff suppressed because one or more lines are too long
|
@ -138,7 +138,7 @@ input[name="end_input"], input[name="range_input"] {
|
||||||
margin-right: -1px;
|
margin-right: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.error, .warning {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
}
|
}
|
||||||
|
@ -196,3 +196,8 @@ input[name="end_input"], input[name="range_input"] {
|
||||||
background-color: #222222;
|
background-color: #222222;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.typeahead.dropdown-menu {
|
||||||
|
max-height: 400px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="error alert alert-danger"></div>
|
<div class="error alert alert-danger"></div>
|
||||||
|
<div class="warning alert alert-warning"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,7 @@ Prometheus.Graph.prototype.initialize = function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
self.error = graphWrapper.find(".error").hide();
|
self.error = graphWrapper.find(".error").hide();
|
||||||
|
self.warning = graphWrapper.find(".warning").hide();
|
||||||
self.graphArea = graphWrapper.find(".graph_area");
|
self.graphArea = graphWrapper.find(".graph_area");
|
||||||
self.graph = self.graphArea.find(".graph");
|
self.graph = self.graphArea.find(".graph");
|
||||||
self.yAxis = self.graphArea.find(".y_axis");
|
self.yAxis = self.graphArea.find(".y_axis");
|
||||||
|
@ -237,7 +238,7 @@ Prometheus.Graph.prototype.checkTimeDrift = function() {
|
||||||
var diff = Math.abs(browserTime - serverTime);
|
var diff = Math.abs(browserTime - serverTime);
|
||||||
|
|
||||||
if (diff >= 30) {
|
if (diff >= 30) {
|
||||||
$("#graph_wrapper0").prepend(
|
this.showWarning(
|
||||||
"<div class=\"alert alert-warning\"><strong>Warning!</strong> Detected " +
|
"<div class=\"alert alert-warning\"><strong>Warning!</strong> Detected " +
|
||||||
diff.toFixed(2) +
|
diff.toFixed(2) +
|
||||||
" seconds time difference between your browser and the server. Prometheus relies on accurate time and time drift might cause unexpected query results.</div>"
|
" seconds time difference between your browser and the server. Prometheus relies on accurate time and time drift might cause unexpected query results.</div>"
|
||||||
|
@ -286,7 +287,7 @@ Prometheus.Graph.prototype.initTypeahead = function(self) {
|
||||||
self.expr.typeahead({
|
self.expr.typeahead({
|
||||||
autoSelect: false,
|
autoSelect: false,
|
||||||
source: source,
|
source: source,
|
||||||
items: "all",
|
items: 1000,
|
||||||
matcher: function (item) {
|
matcher: function (item) {
|
||||||
// If we have result for current query, skip
|
// If we have result for current query, skip
|
||||||
if (self.fuzzyResult.query !== this.query) {
|
if (self.fuzzyResult.query !== this.query) {
|
||||||
|
@ -462,6 +463,7 @@ Prometheus.Graph.prototype.decreaseMoment = function() {
|
||||||
Prometheus.Graph.prototype.submitQuery = function() {
|
Prometheus.Graph.prototype.submitQuery = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.clearError();
|
self.clearError();
|
||||||
|
self.clearWarning();
|
||||||
if (!self.expr.val()) {
|
if (!self.expr.val()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -546,12 +548,24 @@ Prometheus.Graph.prototype.showError = function(msg) {
|
||||||
self.error.show();
|
self.error.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
Prometheus.Graph.prototype.clearError = function(msg) {
|
Prometheus.Graph.prototype.clearError = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.error.text('');
|
self.error.text('');
|
||||||
self.error.hide();
|
self.error.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Prometheus.Graph.prototype.showWarning = function(msg) {
|
||||||
|
var self = this;
|
||||||
|
self.warning.html(msg);
|
||||||
|
self.warning.show();
|
||||||
|
};
|
||||||
|
|
||||||
|
Prometheus.Graph.prototype.clearWarning = function() {
|
||||||
|
var self = this;
|
||||||
|
self.warning.html('');
|
||||||
|
self.warning.hide();
|
||||||
|
};
|
||||||
|
|
||||||
Prometheus.Graph.prototype.updateRefresh = function() {
|
Prometheus.Graph.prototype.updateRefresh = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
@ -803,6 +817,7 @@ Prometheus.Graph.prototype.handleConsoleResponse = function(data, textStatus) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
data.result = self.limitSeries(data.result);
|
||||||
for (var i = 0; i < data.result.length; i++) {
|
for (var i = 0; i < data.result.length; i++) {
|
||||||
var s = data.result[i];
|
var s = data.result[i];
|
||||||
var tsName = self.metricToTsName(s.metric);
|
var tsName = self.metricToTsName(s.metric);
|
||||||
|
@ -814,6 +829,7 @@ Prometheus.Graph.prototype.handleConsoleResponse = function(data, textStatus) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
data.result = self.limitSeries(data.result);
|
||||||
for (var i = 0; i < data.result.length; i++) {
|
for (var i = 0; i < data.result.length; i++) {
|
||||||
var v = data.result[i];
|
var v = data.result[i];
|
||||||
var tsName = self.metricToTsName(v.metric);
|
var tsName = self.metricToTsName(v.metric);
|
||||||
|
@ -887,6 +903,20 @@ Prometheus.Graph.prototype.formatKMBT = function(y) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Prometheus.Graph.prototype.limitSeries = function(result) {
|
||||||
|
var self = this;
|
||||||
|
var MAX_SERIES_NUM = 10000;
|
||||||
|
var message = "<strong>Warning!</strong> Fetched " +
|
||||||
|
result.length + " series, but displaying only first " +
|
||||||
|
MAX_SERIES_NUM + ".";
|
||||||
|
|
||||||
|
if (result.length > MAX_SERIES_NUM) {
|
||||||
|
self.showWarning(message);
|
||||||
|
return result.splice(0, MAX_SERIES_NUM);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page
|
* Page
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue