Merge pull request #30 from cloudflare/watchdog-fixes

Watchdog fixes
This commit is contained in:
Łukasz Mierzwa
2017-04-01 10:31:26 -07:00
committed by GitHub
4 changed files with 16 additions and 18 deletions
+5
View File
@@ -97,6 +97,11 @@ This option can also be set using `-alertmanager.ttl` flag. Example:
Default is `1m`.
Note that the maximum value for this option is `15m`.
The UI has a watchdog that tracks the timestamp of the last pull. If the UI
does not receive updates for more than 15 minutes it will print an error and
reload the page.
#### ALERTMANAGER_URI
URI of the Alertmanager instance, unsee will use it to pull alert groups and
+6 -5
View File
@@ -26,7 +26,7 @@ var Unsee = (function(params) {
Grid.Init();
Autocomplete.Init();
Filters.Init();
Watchdog.Init(10, 300);
Watchdog.Init(30, 60*15); // set watchdog to 15 minutes
$(selectors.refreshButton).click(function() {
if (!$(selectors.refreshButton).prop('disabled')) {
@@ -53,7 +53,6 @@ var Unsee = (function(params) {
}
}
refreshInterval = rate;
Watchdog.UpdateTolerance(rate);
Progress.Reset();
}
@@ -131,10 +130,12 @@ var Unsee = (function(params) {
Colors.Update(resp['colors']);
Alerts.Update(resp);
updateCompleted();
Watchdog.Pong(moment(resp['timestamp']).unix());
Watchdog.Pong(moment(resp['timestamp']);
Unsee.WaitForNextReload();
$(selectors.errors).html('');
$(selectors.errors).hide('');
if (!Watchdog.IsFatal()) {
$(selectors.errors).html('');
$(selectors.errors).hide('');
}
} catch (err) {
Counter.Unknown();
handleError(err);
+3 -11
View File
@@ -21,15 +21,13 @@ var Watchdog = (function() {
// don't raise an error if autorefresh is disabled
if (!Config.GetOption('autorefresh').Get()) return;
var now = moment().unix();
var now = moment().utc().unix();
if (now - lastTs > maxLag) {
Grid.Clear();
$('#errors').html(haml.compileHaml('fatal-error')({
last_ts: lastTs,
seconds_left: fatalCountdown
}));
})).show();
Counter.Unknown();
Summary.Reset();
if (!inCountdown) {
fatalCountdown = 60;
fatalReloadTimer = setTimeout(function() {
@@ -54,13 +52,8 @@ var Watchdog = (function() {
}
updateMaxLag = function(interval) {
maxLag = Math.max(interval + 50, 300);
}
updateTs = function(ts) {
lastTs = ts;
lastTs = ts.utc().unix();
}
@@ -75,7 +68,6 @@ var Watchdog = (function() {
return {
Init: init,
UpdateTolerance: updateMaxLag,
Pong: updateTs,
GetLastUpdate: getTs,
IsFatal: getFatal
+2 -2
View File
File diff suppressed because one or more lines are too long