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

Commit

Permalink
HAWKULAR-922 Alert Migration
Browse files Browse the repository at this point in the history
- fix angular version issue (in same way as master)
- deal with notification issues
  - no e-mail set at OOB-time
  - new ActionDefinition api compat
- remove trigger defs from ui code
- fix a dampening issue
  • Loading branch information
jshaughn committed Feb 11, 2016
1 parent 314584f commit e7bbdfe
Show file tree
Hide file tree
Showing 14 changed files with 304 additions and 931 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<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="hkAlertEmail" ng-disabled="hkDisabled">
<input type="text" id="email-heap" class="form-control" ng-model="hkAlertEmail"
ng-disabled="!tc.adm.trigger.emailEnabled">
</div>
<div class="col-sm-3">
<hk-switch hk-model="tc.adm.trigger.emailEnabled" class="pull-right" id="email-switch" ></hk-switch>
</div>
</div>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ <h3>Alert Settings</h3>
<hk-fieldset-dampening hk-duration="tc.adm.trigger.evalTimeSetting"></hk-fieldset-dampening>

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

</form>

<div class="form-actions hk-form-actions-separator text-right">
Expand Down
33 changes: 33 additions & 0 deletions console/src/main/scripts/plugins/metrics/ts/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,39 @@ module HawkularMetrics {
}
return evalTimeSetting;
}

protected updateAction(actions: any, actionPlugin: string, actionId: string) {
if ( !actions ) {
actions[0].actionPlugin = actionPlugin;
actions[0].actionId = actionId;
return actions;
}

let i = actions.length;
while( i-- ) {
if( actions[i] && actions[i].actionPlugin === actionPlugin ) {
actions[i].actionId = actionId;
return actions;
}
}
actions[actions.length].actionPlugin = actionPlugin;
actions[actions.length].actionId = actionId;
return actions;
}

protected removeAction(actions: any, actionPlugin: string) {
if ( !actions ) {
return null;
}

let i = actions.length;
while( i-- ) {
if( actions[i] && actions[i].actionPlugin === actionPlugin ) {
actions.splice(i,1);
}
}
return actions;
}
}

export class MetricsAlertController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ module HawkularMetrics {
});
this.resourceList = tmpResourceList;
this.resourceList.$resolved = true;
this.loadTriggers();
});
});
}
Expand Down Expand Up @@ -290,190 +289,6 @@ module HawkularMetrics {

}

public loadTriggers(currentTenantId?: TenantId): any {
_.forEach(this.resourceList, function(res: IResource, idx) {
// The Wildfly agent generates resource IDs unique among the app servers it is monitoring because
// each resource is prefixed with the managedServerName. But when dealing with multiple Wildfly-agent feeds
// a resource ID is not guaranteed to be unique. So, we further qualify the resource ID with the feed ID and
// use this qualifiedResourceId in the trigger definition.
this.loadDatasourceTriggers(this.feedId + '/' + res.id, res.path);
}, this);
}

private loadDatasourceTriggers(qualifiedResourceId: ResourceId, resourcePath: ResourcePath): void {
// Check if trigger exists on alerts setup modal open. If not, create the trigger before opening the modal

let connTriggerPromise = this.HawkularAlertsManager.existTrigger(qualifiedResourceId + '_ds_conn').then(() => {
this.$log.debug('Datasource connection trigger exists, nothing to do');
}, () => {
let triggerId: string = qualifiedResourceId + '_ds_conn';
let dataId: string = 'MI~R~[' + qualifiedResourceId + ']~MT~Datasource Pool Metrics~Available Count';
let fullTrigger = {
trigger: {
name: 'Datasource Available Connections',
id: triggerId,
description: 'Available Connection Count for Datasource ' + qualifiedResourceId,
autoDisable: true, // Disable trigger after firing, to not have repeated alerts of same issue
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
actions: { email: [this.defaultEmail] },
tags: {
resourceId: qualifiedResourceId
},
context: {
alertType: 'DSCONN',
resourceType: 'DataSource',
resourceName: qualifiedResourceId,
resourcePath: resourcePath,
triggerType: 'Threshold'
}
},
dampenings: [
{
triggerId: triggerId,
evalTimeSetting: 7 * 60000,
triggerMode: 'FIRING',
type: 'STRICT_TIME'
}
],
conditions: [
{
triggerId: triggerId,
type: 'THRESHOLD',
dataId: dataId,
threshold: AppServerDatasourcesDetailsController.DEFAULT_CONN_THRESHOLD,
operator: 'LT',
context: {
description: 'Available Count',
unit: 'connections'
}
}
]
};

return this.HawkularAlertsManager.createTrigger(fullTrigger, () => {
this.$log.error('Error on Trigger creation for ' + triggerId);
});
});

let waitTimeTriggerPromise = this.HawkularAlertsManager.existTrigger(
qualifiedResourceId + '_ds_wait').then(() => {
this.$log.debug('Datasource Wait Time trigger exists, nothing to do');
}, () => {
let triggerId: string = qualifiedResourceId + '_ds_wait';
let dataId: string = 'MI~R~[' + qualifiedResourceId + ']~MT~Datasource Pool Metrics~Average Wait Time';

let fullTrigger = {
trigger: {
name: 'Datasource Pool Wait Time',
id: triggerId,
description: 'Pool Wait Time Responsiveness for DS ' + qualifiedResourceId,
autoDisable: true, // Disable trigger after firing, to not have repeated alerts of same issue
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
actions: { email: [this.defaultEmail] },
tags: {
resourceId: qualifiedResourceId
},
context: {
alertType: 'DSRESP',
resourceType: 'DataSource',
resourceName: qualifiedResourceId,
resourcePath: resourcePath,
triggerType: 'Threshold'
}
},
dampenings: [
{
triggerId: triggerId,
evalTimeSetting: 7 * 60000,
triggerMode: 'FIRING',
type: 'STRICT_TIME'
}
],
conditions: [
{
triggerId: triggerId,
type: 'THRESHOLD',
dataId: dataId,
threshold: AppServerDatasourcesDetailsController.DEFAULT_WAIT_THRESHOLD,
operator: 'GT',
context: {
description: 'Average Wait Time',
unit: 'ms'
}
}
]
};

return this.HawkularAlertsManager.createTrigger(fullTrigger, () => {
this.$log.error('Error on Trigger creation for ' + triggerId);
});
});

let createTimeTriggerPromise = this.HawkularAlertsManager.existTrigger(
qualifiedResourceId + '_ds_create').then(() => {
this.$log.debug('Datasource create time trigger exists, nothing to do');
}, () => {
let triggerId: string = qualifiedResourceId + '_ds_create';
let dataId: string = 'MI~R~[' + qualifiedResourceId + ']~MT~Datasource Pool Metrics~Average Creation Time';
let fullTrigger = {
trigger: {
name: 'Datasource Pool Create Time',
id: triggerId,
description: 'Pool Create Time Responsiveness for DS ' + qualifiedResourceId,
autoDisable: true, // Disable trigger after firing, to not have repeated alerts of same issue
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
actions: { email: [this.defaultEmail] },
tags: {
resourceId: qualifiedResourceId
},
context: {
alertType: 'DSCREATE',
resourceType: 'DataSource',
resourceName: qualifiedResourceId,
resourcePath: resourcePath,
triggerType: 'Threshold'
}
},
dampenings: [
{
triggerId: triggerId,
evalTimeSetting: 7 * 60000,
triggerMode: 'FIRING',
type: 'STRICT_TIME'
}
],
conditions: [
{
triggerId: triggerId,
type: 'THRESHOLD',
dataId: dataId,
threshold: AppServerDatasourcesDetailsController.DEFAULT_CREA_THRESHOLD,
operator: 'GT',
context: {
description: 'Average Creation Time',
unit: 'ms'
}
}
]
};

return this.HawkularAlertsManager.createTrigger(fullTrigger, () => {
this.$log.error('Error on Trigger creation for ' + triggerId);
});

});

this.$q.all([connTriggerPromise, waitTimeTriggerPromise, createTimeTriggerPromise]).then(() => {
// do nothing
}, () => {
this.$log.error('Missing and unable to create new Datasource Alert triggers.');
});

}

// FIXME: This should be simplified
public redirectToDataSource(resource, event) {
if (this.canRedirect(event.target)) {
Expand Down

0 comments on commit e7bbdfe

Please sign in to comment.