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

Commit

Permalink
Hawkular-464 Deployment Failure Event Alerting
Browse files Browse the repository at this point in the history
Add alert generation for failed deployments.
- New src-deps versions for component enhancements to support this
  - with mazz, enhanced bus-commons with better classloading/deserialization support for MDBs
  - with mazz, enhanced command-gateway to support multiple commands on ws responses, now can notify UI and put a response on the bus
  - enhanced alerts to consume ws deploy app response messages on bus and generate events
- Added new trigger definition on app-servers to fire on a failed deployment event
  - note, also storing successful deployment events for future use/display
- Added new UI support for 'Event' trigger-type and DEPLOYMENT_FAIL alert-type

Also:
- fixed time-window bug in getAlerts query for some trigger types
- make bus-commons dep provided (by nest) for pinger
- make bus-commons dep provided (by nest) for avail-creator
- up src revision slightly for accounts to get the longer grace period for c* connection
  • Loading branch information
jshaughn committed Nov 20, 2015
1 parent a93a576 commit dd12188
Show file tree
Hide file tree
Showing 15 changed files with 382 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<div ng-switch-when="REJECTED_SESSIONS">
<strong>Rejected Web Sessions</strong>: The number of rejected web sessions was {{alert.avg}}.
</div>
<div ng-switch-when="DEPLOYMENT_FAIL">
<strong>Deployment Failed</strong>: {{alert.message}}.
</div>
<div ng-switch-default>
<strong>Alert</strong>: <code>{{alert}}</code>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ <h3>Alert Settings</h3>
<hk-fieldset-dampening hk-duration="tc.adm.trigger.evalTimeSetting"
hk-title="Downtime"
hk-title-met="Every time it goes down."
hk-title-unmet="Only when it is down for more than:"></hk-fieldset-dampening>
hk-title-unmet="Only when it is down for more than:">
</hk-fieldset-dampening>

<hk-fieldset-notification hk-alert-email="tc.adm.trigger.email"></hk-fieldset-notification>
</form>
Expand Down
57 changes: 57 additions & 0 deletions console/src/main/scripts/plugins/metrics/html/triggers/event.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<div class="hk-alert-center-detail">

<div class="hk-screen-top-nav">
<div class="container">
<div class="row hk-top-row">
<div class="col-xs-6">
<a href="/hawkular-ui/alerts-center-triggers" class="back">&laquo; All Definitions</a>
</div>
</div>
<div class="hk-heading">
<h1 class="offset-panels">Alert Definition Details</h1>
</div>
</div>
</div>

<div class="container">

<div class="row">
<div class="col-lg-9 col-md-8">
<div class="panel panel-default clearfix">
<div class="panel-heading">
<h2>{{tc.adm.trigger.name}}</h2>
</div>
<div class="panel-body">
<form class="form-horizontal">
<div ng-include="'plugins/metrics/html/partials/trigger-general-setup.html'"></div>

<h3>Alert Settings</h3>

<fieldset>
{{tc.adm.trigger.conditionContext.description !== '' ?
tc.adm.trigger.conditionContext.description : "Event"}}
</fieldset>

<hk-fieldset-notification hk-alert-email="tc.adm.trigger.email"></hk-fieldset-notification>
</form>

<div class="form-actions hk-form-actions-separator text-right">
<a type="button" class="btn btn-default" ng-href="{{tc.cancel()}}" class="button">Cancel</a>
<button type="button" class="btn btn-primary" ng-click="tc.save()"
ng-disabled="tc.saveProgress || !tc.isSettingChange">
<div ng-show="tc.saveProgress" class="spinner spinner-xs hk-modal-spinner"></div>
Save
</button>
</div>

</div>
</div>
</div>

<div ng-include="'plugins/metrics/html/partials/trigger-alerts-sidebar.html'"></div>

</div> <!-- row -->

</div> <!-- container -->

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ module HawkularMetrics {

if ('Availability' === trigger.context.triggerType) {
route = '/hawkular-ui/alerts-center-triggers/availability/' + encodedId;
} else if ('Event' === trigger.context.triggerType) {
route = '/hawkular-ui/alerts-center-triggers/event/' + encodedId;
} else if ('Range' === trigger.context.triggerType) {
route = '/hawkular-ui/alerts-center-triggers/range/' + encodedId;
} else if ('RangeByPercent' === trigger.context.triggerType) {
Expand All @@ -206,6 +208,8 @@ module HawkularMetrics {

if ('App Server' === trigger.context.resourceType) {
route = '/hawkular-ui/app/app-details/' + trigger.context.resourceName + '/jvm';
} else if ('App Server Deployment' === trigger.context.resourceType) {
route = '/hawkular-ui/app/app-details/' + trigger.context.resourceName + '/deployments';
} else if ('DataSource' === trigger.context.resourceType) {
let resIdPart = trigger.context.resourceName.split('~/')[0];
route = '/hawkular-ui/app/app-details/' + resIdPart + '/datasources';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,6 @@ module HawkularMetrics {
this.autoRefresh(20);
}

private getAlerts(resourceId:ResourceId, startTime:TimestampInMillis, endTime:TimestampInMillis, res:any):void {
let dsArray:IAlert[];
let promise = this.HawkularAlertsManager.queryAlerts({
statuses: 'OPEN',
tags: 'resourceId|' + resourceId, startTime: startTime, endTime: endTime
}).then((data)=> {
_.forEach(data.alertList, (item) => {
item['alertType'] = item.context.alertType;
});
dsArray = data.alertList;
}, (error) => {
return this.ErrorsManager.errorHandler(error, 'Error fetching DS alerts.');
});

this.$q.all([promise]).finally(()=> {
res.alertList = dsArray;
});
}

public showDriverAddDialog():void {

/// create a new isolate scope for dialog inherited from current scope instead of default $rootScope
Expand Down Expand Up @@ -176,10 +157,6 @@ module HawkularMetrics {
});
}

public refresh():void {
this.getDatasources();
}

public autoRefresh(intervalInSeconds:number):void {
this.autoRefreshPromise = this.$interval(() => {
this.getDatasources();
Expand All @@ -190,6 +167,13 @@ module HawkularMetrics {
});
}

public refresh():void {
this.endTimeStamp = this.$routeParams.endTime || +moment();
this.startTimeStamp = this.endTimeStamp - (this.$routeParams.timeOffset || 3600000);

this.getDatasources();
}

public getDatasources(currentTenantId?:TenantId):void {
this.endTimeStamp = this.$routeParams.endTime || +moment();
this.startTimeStamp = this.endTimeStamp - (this.$routeParams.timeOffset || 3600000);
Expand Down Expand Up @@ -220,7 +204,7 @@ module HawkularMetrics {
}, (data) => {
res.inUseCount = data[0];
}).$promise);
this.getAlerts(res.id, this.startTimeStamp, this.endTimeStamp, res);
this.getAlerts(res);
}
}, this);
this.$q.all(promises).then(() => {
Expand All @@ -240,6 +224,27 @@ module HawkularMetrics {
this.getDrivers();
}

private getAlerts(res:any):void {
let dsArray:IAlert[];
let promise = this.HawkularAlertsManager.queryAlerts({
statuses: 'OPEN',
tags: 'resourceId|' + res.id,
startTime: this.startTimeStamp,
endTime: this.endTimeStamp
}).then((data)=> {
_.forEach(data.alertList, (item) => {
item['alertType'] = item.context.alertType;
});
dsArray = data.alertList;
}, (error) => {
return this.ErrorsManager.errorHandler(error, 'Error fetching DS alerts.');
});

this.$q.all([promise]).finally(()=> {
res.alertList = dsArray;
});
}

public getDrivers(currentTenantId?:TenantId):void {
this.HawkularInventory.ResourceOfTypeUnderFeed.query({
environmentId: globalEnvironmentId, feedId: this.$routeParams.resourceId.split('~')[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module HawkularMetrics {
private autoRefreshPromise:ng.IPromise<number>;
private resourceList;
public modalInstance;
public resourceId;
public alertList;
public selectCount:number = 0;
public lastUpdateTimestamp:Date;
Expand All @@ -57,7 +58,8 @@ module HawkularMetrics {
$scope.vm = this;
HawkularOps.init(this.NotificationsService);

this.startTimeStamp = +moment().subtract(1, 'hours');
this.resourceId = this.$routeParams.resourceId;
this.startTimeStamp = +moment().subtract(($routeParams.timeOffset || 3600000), 'milliseconds');
this.endTimeStamp = +moment();

if ($rootScope.currentPersona) {
Expand All @@ -68,20 +70,30 @@ module HawkularMetrics {
this.getResourceList(currentPersona.id));
}

this.getAlerts();

this.autoRefresh(20);
}


private autoRefresh(intervalInSeconds:number):void {
this.autoRefreshPromise = this.$interval(() => {
this.getResourceList();
this.refresh();
}, intervalInSeconds * 1000);

this.$scope.$on('$destroy', () => {
this.$interval.cancel(this.autoRefreshPromise);
});
}

public refresh():void {
this.endTimeStamp = this.$routeParams.endTime || +moment();
this.startTimeStamp = this.endTimeStamp - (this.$routeParams.timeOffset || 3600000);

this.getResourceList();
this.getAlerts();
}

public showDeploymentAddDialog():void {

this.$log.debug('Starting Show Add Dialog');
Expand All @@ -103,14 +115,35 @@ module HawkularMetrics {
});
}

public refresh(): void {
this.getResourceList();
private getAlerts():void {
let alertArray: IAlert[];
let promise = this.HawkularAlertsManager.queryAlerts({
statuses: 'OPEN',
tags: 'resourceId|' + this.resourceId,
startTime: this.startTimeStamp,
endTime: this.endTimeStamp
}).then((data)=> {
_.remove(data.alertList, (item) => {
switch( item.context.alertType ) {
case 'DEPLOYMENT_FAIL' :
item['alertType'] = item.context.alertType;
return false;
default : return true; // ignore non-jvm alert
}
});
alertArray = data.alertList;
}, (error) => {
return this.ErrorsManager.errorHandler(error, 'Error fetching deployment failure alerts.');
});

this.$q.all([promise]).finally(()=> {
this.alertList = alertArray;
});
}

public getResourceList(currentTenantId?:TenantId):void {
this.alertList = []; // FIXME: when we have alerts for app server
let tenantId:TenantId = currentTenantId || this.$rootScope.currentPersona.id;
let idParts = this.$routeParams.resourceId.split('~');
let idParts = this.resourceId.split('~');
let feedId = idParts[0];
this.HawkularInventory.ResourceOfTypeUnderFeed.query({
environmentId: globalEnvironmentId,
Expand All @@ -120,7 +153,7 @@ module HawkularMetrics {
let promises = [];
let tmpResourceList = [];
_.forEach(aResourceList, (res:IResource) => {
if (res.id.startsWith(new RegExp(this.$routeParams.resourceId + '~/'))) {
if (res.id.startsWith(new RegExp(this.resourceId + '~/'))) {
tmpResourceList.push(res);
res.selected = _.result(_.find(this.resourceList, {'id': res.id}), 'selected');
promises.push(this.HawkularMetric.AvailabilityMetricData(this.$rootScope.currentPersona.id).query({
Expand Down

0 comments on commit dd12188

Please sign in to comment.