- Bump tries to 7 on histogram sizing

- Abort if somehow the histogram interval gets below 1 second
This commit is contained in:
Jordan Sissel 2011-02-13 03:44:37 -08:00
parent 025ebbcf7d
commit 782ab1b04c

View file

@ -37,10 +37,11 @@
histogram: function(tries) {
if (typeof(tries) == 'undefined') {
tries = 5;
tries = 7;
}
/* Uncomment to activate GeoCities mode on the graph while waiting . */
/* GeoCities mode on the graph while waiting ...
* This won't likely survive 1.0, but it's fun for now... */
$("#visual").html("<center><img src='/media/truckconstruction.gif'><center>");
jQuery.getJSON("/api/histogram", logstash.params, function(histogram, text, jqxhr) {
@ -50,7 +51,7 @@
for (var i in histogram) {
flot_data.push([parseInt(histogram[i]["key"]), histogram[i]["count"]])
}
//console.log("Histo:" + flot_data.length);
//console.log(histogram);
/* Try to be intelligent about how we choose the histogram interval.
* If there are too few data points, try a smaller interval.
@ -62,12 +63,18 @@
if (flot_data.length < 6 && tries > 0) {
//console.log("Histogram bucket " + logstash.params.interval + " has only " + flot_data.length + " data points, trying smaller...");
logstash.params.interval /= 2;
if (logstash.params.interval < 1000) {
tries = 0; /* stop trying, too small... */
logstash.plot(flot_data, logstash.params.interval);
return;
}
logstash.histogram(tries - 1);
} else if (flot_data.length > 50 && tries > 0) {
//console.log("Histogram bucket " + logstash.params.interval + " too many (" + flot_data.length + ") data points, trying larger interval...");
logstash.params.interval *= 2;
logstash.histogram(tries - 1);
} else {
//console.log("Histo:" + logstash.params.interval);
logstash.plot(flot_data, logstash.params.interval);
}
});