Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Jvm alerts setup init
Browse files Browse the repository at this point in the history
  • Loading branch information
Viliam Rockai committed Jul 29, 2015
1 parent e82fa48 commit 1c4faae
Show file tree
Hide file tree
Showing 4 changed files with 542 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<div class="modal-header">
<button type="button" class="close" ng-click="jas.cancel()">
<span class="pficon pficon-close"></span>
</button>
<h4 class="modal-title">Alert Settings</h4>
</div>
<div class="modal-body alert-settings">
<p>Configure conditions settings for Heap usage alerts and notifications.</p>
<form class="form-horizontal">
<fieldset>
<legend>Threshold Conditions</legend>
<div class="form-group">
<label class="col-sm-3 control-label">Maximum usage</label>
<div class="col-sm-6">
<span class="hk-input-text">500 MB</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="usage-greater">Usage greater than</label>
<div class="col-sm-5">
<div class="input-group hk-input-small">
<input type="number" min="0" max="100" ng-model="jas.conditionGt.threshold" class="form-control" id="usage-greater" ng-disabled="!jas.conditionGtEnabled">
<div class="input-group-addon">%</div>
</div>
<span class="input-detail">(400 MB)</span>
</div>
<div class="col-sm-4">
<div class="onoffswitch pull-right">
<input type="checkbox" id="usage-greater-switch" class="onoffswitch-checkbox" ng-model="jas.conditionGtEnabled" ng-click="jas.enableGt()">
<label class="onoffswitch-label" for="usage-greater-switch">
<span class="onoffswitch-inner">
<span class="onoffswitch-active ng-binding">ON</span>
<span class="onoffswitch-inactive ng-binding">OFF</span>
</span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="usage-less">Usage less than</label>
<div class="col-sm-5">
<div class="input-group hk-input-small">
<input type="number" min="0" max="100" ng-model="jas.conditionLt.threshold" class="form-control" id="usage-less" ng-disabled="!jas.conditionLtEnabled">
<div class="input-group-addon">%</div>
</div>
<span class="input-detail">(100 MB)</span>
</div>
<div class="col-sm-4">
<div class="onoffswitch pull-right">
<input type="checkbox" id="usage-less-switch" class="onoffswitch-checkbox" ng-model="jas.conditionLtEnabled" ng-click="jas.enableLt()">
<label class="onoffswitch-label" for="usage-less-switch">
<span class="onoffswitch-inner">
<span class="onoffswitch-active ng-binding">ON</span>
<span class="onoffswitch-inactive ng-binding">OFF</span>
</span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Alert</legend>
<div class="form-group">
<label class="col-sm-3 control-label">Create Alert</label>
<div class="col-sm-9">
<div class="radio">
<label for="every-time-heap">
<input type="radio" name="alert-heap" id="every-time-heap" value="option1" checked="">
Every time conditions are met.
</label>
</div>
<div class="radio">
<label for="greater-time-heap">
<input type="radio" name="alert-heap" id="greater-time-heap" value="option2">
Only when conditions are met for greater than:
</label>
</div>
<div class="input-group input-select indented">
<input type="number" class="form-control" placeholder="Duration" ng-model="jas.dampening.evalTimeSetting">
<select class="selectpicker" style="display: none;">
<option>seconds</option>
<option selected="selected">minutes</option>
<option>hours</option>
</select><div class="btn-group bootstrap-select input-group-btn"><button type="button" class="btn dropdown-toggle selectpicker btn-default" data-toggle="dropdown" title="minutes"><span class="filter-option pull-left">minutes</span>&nbsp;<span class="caret"></span></button><div class="dropdown-menu open"><ul class="dropdown-menu inner selectpicker" role="menu"><li rel="0"><a tabindex="0" class="" style=""><span class="text">seconds</span><i class="glyphicon glyphicon-ok icon-ok check-mark"></i></a></li><li rel="1" class="selected"><a tabindex="0" class="" style=""><span class="text">minutes</span><i class="glyphicon glyphicon-ok icon-ok check-mark"></i></a></li><li rel="2"><a tabindex="0" class="" style=""><span class="text">hours</span><i class="glyphicon glyphicon-ok icon-ok check-mark"></i></a></li></ul></div></div>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Notification</legend>
<p>Receive an email notification every time the conditions are met.</p>
<div class="form-group">
<label class="col-sm-3 control-label" for="email-heap">Email</label>
<div class="col-sm-6">
<input type="text" id="email-heap" class="form-control" ng-model="jas.trigger.actions.email[0]">
</div>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer alert-settings">
<button type="button" class="btn btn-primary" ng-click="jas.save()">
<div ng-show="jas.saveProgress" class="spinner spinner-xs hk-modal-spinner"></div>Save</button>
<button type="button" class="btn btn-default" ng-click="jas.cancel()">Cancel</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h3 class="pull-left">JVM Status</h3>
<h3 class="pull-left">
<button class="btn btn-link hk-trigger" ng-click="showAllAlerts = !showAllAlerts" tooltip-trigger tooltip-placement="top" tooltip="Expand/collapse"><i class="fa" ng-show="vm.alertList.length > 0" ng-class="showAllAlerts ? 'fa-minus-square-o' : 'fa-plus-square-o'"></i> JVM Alerts <span ng-show="vm.alertList.length > 0">({{showAllAlerts ? vm.alertList.length : vm.math.min(vm.alertList.length, 3)}} of {{vm.alertList.length}})</span></button>
</h3>
<span class="hk-settings pull-right"><a href="#" ng-controller="JvmAlertController as jac" ng-click="jac.openSetup()"><i class="fa fa-cog"></i>JVM Alert Settings</a></span>
<!--<span class="hk-settings pull-right"><a href="#" ng-controller="MetricsAlertController as mac" ng-click="mac.openSetup()"><i class="fa fa-cog"></i>Alert Settings</a></span>-->
</div>
<div class="clearfix">
Expand Down
72 changes: 72 additions & 0 deletions console/src/main/scripts/plugins/metrics/ts/alertsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ module HawkularMetrics {
updateTrigger(triggerId: TriggerId, data: any): ng.IPromise<void>;
createTrigger(triggerId: TriggerId, triggerName: string, enabled: boolean, conditionType: string,
email: EmailType): ng.IPromise<void>;

createJvmHeapTrigger(triggerId: TriggerId, triggerName: string, enabled: boolean, conditionType: string,
email: EmailType): ng.IPromise<void>;
createJvmNonHeapTrigger(triggerId: TriggerId, triggerName: string, enabled: boolean, conditionType: string,
email: EmailType): ng.IPromise<void>;
createJvmGarbageTrigger(triggerId: TriggerId, triggerName: string, enabled: boolean, conditionType: string,
email: EmailType): ng.IPromise<void>;

deleteTrigger(triggerId: TriggerId): ng.IPromise<void>;
createCondition(triggerId: TriggerId, condition: any): ng.IPromise<void>;
updateCondition(triggerId: TriggerId, conditionId: ConditionId, condition: any): ng.IPromise<void>;
deleteCondition(conditionId: ConditionId): ng.IPromise<void>;
createDampening(triggerId: TriggerId, duration: number, triggerMode?: string): ng.IPromise<void>;
updateDampening(triggerId: TriggerId, dampeningId: DampeningId, dampening: any): ng.IPromise<void>;
getAction(email: EmailType): ng.IPromise<void>;
Expand Down Expand Up @@ -123,6 +132,65 @@ module HawkularMetrics {
});
}

public createJvmHeapTrigger(id: TriggerId, triggerName: string, enabled: boolean,
conditionType: string, email: EmailType): ng.IPromise<void> {
// Create a trigger
var triggerId: TriggerId;
var DEFAULT_DAMPENING_INTERVAL = 7 * 60000;

return this.HawkularAlert.Trigger.save({
name: triggerName,
id: id,
description: 'Created on ' + Date(),
firingMatch: 'ALL',
autoResolveMatch: 'ALL',
enabled: enabled,
autoResolve: false,
actions: { email: [email] }
}).$promise.then((trigger)=> {

triggerId = trigger.id;

// Parse metrics id from the trigger name
var resourceId: string = triggerId.slice(0,-10);
var dataId: string = 'MI~R~[' + resourceId + '~/]~MT~WildFly Memory Metrics~Heap Used';

// Create a conditions for that trigger
return this.createCondition(triggerId, {
type: conditionType,
triggerId: triggerId,
threshold: 80,
dataId: dataId,
operator: 'GT'
}).then(()=> {
return this.createCondition(triggerId, {
type: conditionType,
triggerId: triggerId,
threshold: 20,
dataId: dataId,
operator: 'LT'
});
});
}).then(() => {
// Create dampening for that trigger
return this.createDampening(triggerId, DEFAULT_DAMPENING_INTERVAL);
});
}

public createJvmNonHeapTrigger(id: TriggerId, triggerName: string, enabled: boolean,
conditionType: string, email: EmailType): ng.IPromise<void> {
return this.$q.when('createJvmNonHeapTrigger').then(() => {
this.$log.debug('createJvmNonHeapTrigger');
});
}

public createJvmGarbageTrigger(id: TriggerId, triggerName: string, enabled: boolean,
conditionType: string, email: EmailType): ng.IPromise<void> {
return this.$q.when('createJvmGarbageTrigger').then(() => {
this.$log.debug('createJvmGarbageTrigger');
});
}

public deleteTrigger(triggerId: TriggerId): ng.IPromise<void> {
return this.HawkularAlert.Trigger.delete({triggerId: triggerId}).$promise;
}
Expand Down Expand Up @@ -177,6 +245,10 @@ module HawkularMetrics {
return this.HawkularAlert.Condition.put({triggerId: triggerId, conditionId: conditionId}, condition).$promise;
}

public deleteCondition(conditionId: ConditionId): ng.IPromise<void> {
return this.HawkularAlert.Condition.delete({conditionId: conditionId}).$promise;
}

public createDampening(triggerId: TriggerId, duration: number, triggerMode?: string): ng.IPromise<void> {
return this.HawkularAlert.Dampening.save({ triggerId: triggerId }, {
triggerId: triggerId,
Expand Down

0 comments on commit 1c4faae

Please sign in to comment.