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

Commit

Permalink
Merge pull request #846 from jshaughn/hawkular-922
Browse files Browse the repository at this point in the history
Hawkular 922
  • Loading branch information
mtho11 committed Feb 12, 2016
2 parents 3f35055 + c347f1c commit f97ef74
Show file tree
Hide file tree
Showing 29 changed files with 1,413 additions and 1,093 deletions.
2 changes: 1 addition & 1 deletion console/src/main/scripts/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"animate.css": "3.0.0",
"ngInfiniteScroll": "1.2.1",
"hawkular-charts": "hawkular/hawkular-charts#9bfefa9",
"hawkular-ui-services": "hawkular/hawkular-ui-services#77ca10a",
"hawkular-ui-services": "0.9.2",
"hawtio-core-navigation": "2.0.51",
"hawtio-core": "2.0.30",
"hawtio-utilities": "2.0.25",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
<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="!hkAlertEmailEnabled">
</div>
<div class="col-sm-3">
<hk-switch hk-model="hkAlertEmailEnabled" class="pull-right" id="email-switch" ></hk-switch>
</div>
</div>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ <h3>General</h3>
</select>
</div>
</div>
<!-- Name and Description are not editable at the group level but should be at the member level
<div class="form-group">
<label class="col-sm-2 control-label">Name</label>
<div class="col-sm-10 hk-input-text">
Expand All @@ -34,6 +35,19 @@ <h3>General</h3>
<input class="form-control" ng-model="tc.adm.trigger.description" />
</div>
</div>
-->
<div class="form-group">
<label class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<span class="hk-input-text hk-bold">{{tc.adm.trigger.name}}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Description</label>
<div class="col-sm-10">
<span class="hk-input-text hk-bold">{{tc.adm.trigger.description}}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Resource</label>
<div class="col-sm-10">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ <h3>Alert Settings</h3>
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>
<hk-fieldset-notification
hk-alert-email="tc.adm.trigger.email"
hk-alert-email-enabled="tc.adm.trigger.emailEnabled"></hk-fieldset-notification>
</form>

<div class="form-actions hk-form-actions-separator text-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ <h3>Alert Settings</h3>
tc.adm.trigger.conditionContext.description : "Event"}}
</fieldset>

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

<div class="form-actions hk-form-actions-separator text-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ <h3>Alert Settings</h3>
</fieldset>
<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>
<hk-fieldset-notification
hk-alert-email="tc.adm.trigger.email"
hk-alert-email-enabled="tc.adm.trigger.emailEnabled"></hk-fieldset-notification>
</form>

<div class="form-actions hk-form-actions-separator text-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ <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>
<hk-fieldset-notification
hk-alert-email="tc.adm.trigger.email"
hk-alert-email-enabled="tc.adm.trigger.emailEnabled"></hk-fieldset-notification>
</form>

<div class="form-actions hk-form-actions-separator text-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ <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>
<hk-fieldset-notification
hk-alert-email="tc.adm.trigger.email"
hk-alert-email-enabled="tc.adm.trigger.emailEnabled"></hk-fieldset-notification>

</form>

<div class="form-actions hk-form-actions-separator text-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ module HawkularMetrics {
public autoResolveAlerts: boolean;
public autoResolveMatch: string;
public enabled: boolean;
public group: boolean;
public orphan: boolean;
public type: string;
public severity: string;
public tenantId: HawkularMetrics.TenantId;
public triggerId: HawkularMetrics.TriggerId;
Expand Down
34 changes: 34 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,40 @@ module HawkularMetrics {
}
return evalTimeSetting;
}

protected updateAction(actions: ITriggerAction[], actionPlugin: string, actionId: string, properties: any) {
if ((undefined === actions) || (null === actions)) {
actions = [{
actionPlugin: actionPlugin,
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 f97ef74

Please sign in to comment.