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

Commit

Permalink
Fix JVM Metrics Heap Alerts plus other fixes
Browse files Browse the repository at this point in the history
- Use RANGE condition instead of 2 THRESHOLD;
- Make percentage work as percentage and not as value;
- Show/Refresh correct alerts (not _thres and _avail);
- Adapt metric querying to Agent ID changed;
- Update to Alerts 0.3.2.Final;
- Other fixes...
  • Loading branch information
ammendonca authored and Viliam Rockai committed Jul 29, 2015
1 parent 036c1b4 commit 94f272d
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ <h4 class="modal-title">Alert Settings</h4>
<div class="form-group">
<label class="col-sm-3 control-label">Maximum usage</label>
<div class="col-sm-6">
<span class="hk-input-text">{{jas.maxUsage}} MB</span>
<span class="hk-input-text">{{jas.maxUsage / 1024 / 1024 | number : 2}} 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">
<input type="number" min="0" max="100" ng-model="jas.conditionGtPercent" class="form-control" id="usage-greater" ng-disabled="!jas.conditionGtEnabled">
<div class="input-group-addon">%</div>
</div>
<span class="input-detail">({{jas.conditionGtEnabled && jas.conditionGt.threshold ? jas.maxUsage * jas.conditionGt.threshold / 100 : '-'}} MB)</span>
<span class="input-detail">({{jas.conditionGtEnabled && jas.conditionGtPercent ? (jas.maxUsage * jas.conditionGtPercent / 100/1024/1024 | number:2) : '-'}} MB)</span>
</div>
<div class="col-sm-4">
<div class="onoffswitch pull-right">
Expand All @@ -41,10 +41,10 @@ <h4 class="modal-title">Alert Settings</h4>
<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">
<input type="number" min="0" max="100" ng-model="jas.conditionLtPercent" class="form-control" id="usage-less" ng-disabled="!jas.conditionLtEnabled">
<div class="input-group-addon">%</div>
</div>
<span class="input-detail">({{jas.conditionLtEnabled && jas.conditionLt.threshold ? jas.maxUsage * jas.conditionLt.threshold / 100 : '-'}} MB)</span>
<span class="input-detail">({{jas.conditionLtEnabled && jas.conditionLtPercent ? (jas.maxUsage * jas.conditionLtPercent / 100/1024/1024 | number:2) : '-'}} MB)</span>
</div>
<div class="col-sm-4">
<div class="onoffswitch pull-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ <h3 class="pull-left">
<!-- Alerts exist -->
<div class="panel panel-default alert alert-danger" ng-repeat="alert in vm.alertList | limitTo: (showAllAlerts ? 100000 : 3) track by $index">
<div class="hk-alert-icon"><i class="fa fa-flag"></i></div>
<div class="hk-date">{{alert.evalSets[0][0].evalTimestamp | date:'medium' }}</div>
<div class="hk-event"><strong>Alert Summary</strong>: alert details.</div>
<div class="hk-date">{{alert.start | date:'medium' }}</div>
<div class="hk-event"><strong>Heap Memory</strong>: The Heap memory usage was {{alert.avg / 1024 / 1024 | number:2}} MB.</div>
</div>
</div>


<div class="hk-info-top clearfix">
<h3 class="pull-left">Metrics</h3>
<div class="hk-update pull-right">
Expand Down
11 changes: 7 additions & 4 deletions console/src/main/scripts/plugins/metrics/ts/alertsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,21 @@ module HawkularMetrics {
return this.createCondition(triggerId, {
type: conditionType,
triggerId: triggerId,
threshold: 80,
dataId: dataId,
operator: 'GT'
}).then(()=> {
operatorLow: 'INCLUSIVE',
operatorHigh: 'INCLUSIVE',
thresholdLow: 20.0,
thresholdHigh: 80.0,
inRange: false
})/*.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ module HawkularMetrics {
angular.forEach(aResourceList, function(res, idx) {
tmpResourceList.push(res);
promises.push(this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~' + res.id + '~MT~Datasource Pool Metrics~Available Count',
gaugeId: 'MI~R~[' + res.id + ']~MT~Datasource Pool Metrics~Available Count',
distinct: true}, (data) => {
res.availableCount = data[0];
}).$promise);
promises.push(this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~' + res.id + '~MT~Datasource Pool Metrics~In Use Count',
gaugeId: 'MI~R~[' + res.id + ']~MT~Datasource Pool Metrics~In Use Count',
distinct: true}, (data) => {
res.inUseCount = data[0];
}).$promise);
Expand All @@ -141,7 +141,7 @@ module HawkularMetrics {
var tenantId:TenantId = currentTenantId || this.$rootScope.currentPersona.id;
angular.forEach(this.resourceList, function(res, idx) {
this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~' + res.id + '~MT~Datasource Pool Metrics~Available Count',
gaugeId: 'MI~R~[' + res.id + ']~MT~Datasource Pool Metrics~Available Count',
start: this.startTimeStamp,
end: this.endTimeStamp, buckets:60}, (data) => {
this.chartAvailData[res.id] = this.chartAvailData[res.id] || [];
Expand All @@ -150,7 +150,7 @@ module HawkularMetrics {
values: this.formatBucketedChartOutput(data) };
}, this);
this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~' + res.id + '~MT~Datasource Pool Metrics~In Use Count',
gaugeId: 'MI~R~[' + res.id + ']~MT~Datasource Pool Metrics~In Use Count',
start: this.startTimeStamp,
end: this.endTimeStamp, buckets:60}, (data) => {
this.chartAvailData[res.id] = this.chartAvailData[res.id] || [];
Expand All @@ -159,7 +159,7 @@ module HawkularMetrics {
values: this.formatBucketedChartOutput(data) };
}, this);
this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~' + res.id + '~MT~Datasource Pool Metrics~Timed Out',
gaugeId: 'MI~R~[' + res.id + ']~MT~Datasource Pool Metrics~Timed Out',
start: this.startTimeStamp,
end: this.endTimeStamp, buckets:60}, (data) => {
this.chartAvailData[res.id] = this.chartAvailData[res.id] || [];
Expand All @@ -169,7 +169,7 @@ module HawkularMetrics {
}, this);

this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~' + res.id + '~MT~Datasource Pool Metrics~Average Get Time',
gaugeId: 'MI~R~[' + res.id + ']~MT~Datasource Pool Metrics~Average Get Time',
start: this.startTimeStamp,
end: this.endTimeStamp, buckets:60}, (data) => {
this.chartRespData[res.id] = this.chartRespData[res.id] || [];
Expand All @@ -178,7 +178,7 @@ module HawkularMetrics {
values: this.formatBucketedChartOutput(data) };
}, this);
this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~' + res.id + '~MT~Datasource Pool Metrics~Average Creation Time',
gaugeId: 'MI~R~[' + res.id + ']~MT~Datasource Pool Metrics~Average Creation Time',
start: this.startTimeStamp,
end: this.endTimeStamp, buckets:60}, (data) => {
this.chartRespData[res.id] = this.chartRespData[res.id] || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module HawkularMetrics {
}, () => {
// Jvm trigger doesn't exist, need to create one
return this.HawkularAlertsManager.createJvmHeapTrigger(this.resourceId + '_jvm_pheap',
this.resourceId + '_jvm_pheap', true, 'THRESHOLD', this.defaultEmail);
this.resourceId + '_jvm_pheap', true, 'RANGE', this.defaultEmail);
});
/*
var nonHeapTriggerPromise = this.HawkularAlertsManager.getTrigger(this.resourceId + '_jvm_nheap').then(() => {
Expand Down Expand Up @@ -125,6 +125,7 @@ module HawkularMetrics {
}

public getAlerts():void {
/* FIXME: This is done in appServerJvmDetails
this.alertsTimeEnd = this.$routeParams.endTime ? this.$routeParams.endTime : (new Date()).getTime();
this.alertsTimeStart = this.alertsTimeEnd - this.alertsTimeOffset;
Expand All @@ -134,6 +135,7 @@ module HawkularMetrics {
this.alertList = queriedAlerts.alertList;
this.alertList.$resolved = true; // FIXME
}, (error) => { return this.HawkularErrorManager.errorHandler(error, 'Error fetching alerts.'); });
*/
}

public setPage(page:number):void {
Expand Down Expand Up @@ -166,14 +168,16 @@ module HawkularMetrics {
private trigger: any;
private dampening: any;
private conditionGt: any;
private conditionLt: any;
public responseDuration: number;

private conditionGtEnabled: boolean;
private conditionLtEnabled: boolean;

public conditionGtPercent: number;
public conditionLtPercent: number;

// TODO - Get the actual data from backend
public maxUsage: number = 500;
public maxUsage: number = AppServerJvmDetailsController.MAX_HEAP;

public saveProgress: boolean = false;
public duration: number;
Expand Down Expand Up @@ -211,6 +215,8 @@ module HawkularMetrics {
this.$log.debug('querying data');
this.$log.debug('$routeParams', $routeParams.resourceId);

this.maxUsage = AppServerJvmDetailsController.MAX_HEAP;

// TODO - update the pfly notification service to support more and category based notifications containers.
this.$rootScope.hkNotifications = {alerts: []};
this.resourceId = $routeParams.resourceId;
Expand Down Expand Up @@ -238,67 +244,49 @@ module HawkularMetrics {
this.$log.debug('HawkularAlert.Dampening.query', data);
return HawkularAlert.Condition.query({triggerId: triggerId}).$promise;
}).then((data)=> {
this.conditionGt = _.filter(data, {operator: 'GT'})[0];
this.conditionGtEnabled = !!this.conditionGt;
this.conditionLt = _.filter(data, {operator: 'LT'})[0];
this.conditionLtEnabled = !!this.conditionLt;
this.conditionGt = data[0];
this.conditionGtEnabled = this.conditionGt.thresholdHigh < this.maxUsage;
this.conditionGtPercent = this.conditionGt.thresholdHigh > 0 ?
this.conditionGt.thresholdHigh * 100 / this.maxUsage : 0;

this.conditionLtEnabled = this.conditionGt.thresholdLow > 0;
this.conditionLtPercent = this.conditionGt.thresholdLow > 0 ?
this.conditionGt.thresholdLow * 100 / this.maxUsage : 0;

this.$log.debug('HawkularAlert.Condition.query', this.conditionLt, this.conditionGt);
this.$log.debug('HawkularAlert.Condition.query', this.conditionGt);
});
}

public enableGt(): void {
this.$log.debug('enableGt');

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

if (this.conditionGtEnabled) {
this.HawkularAlertsManager.createCondition(triggerId, {
type: 'THRESHOLD',
triggerId: triggerId,
threshold: 80,
dataId: dataId,
operator: 'GT'
}).then( (data:any) => {
this.conditionGt = _.filter(data, {operator: 'GT'})[0];
this.$log.debug('this.conditionGt', this.conditionGt);
});
} else {
this.$log.debug('Going to delete', this.conditionGt.conditionId);
this.HawkularAlertsManager.deleteCondition(triggerId, this.conditionGt.conditionId).then(()=> {
this.conditionGt = undefined;
});
}
var conditionId: string = this.conditionGt.conditionId;

this.conditionGt.thresholdHigh = this.conditionGtEnabled ? (this.maxUsage / this.conditionGtPercent) :
this.maxUsage;

this.HawkularAlertsManager.updateCondition(triggerId, conditionId, this.conditionGt).then((data:any) => {
this.conditionGt = data[0];
this.$log.debug('this.conditionGt', this.conditionGt);
});
}

public enableLt(): void {
this.$log.debug('enableLt');

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

if (this.conditionLtEnabled) {
this.HawkularAlertsManager.createCondition(triggerId, {
type: 'THRESHOLD',
triggerId: triggerId,
threshold: 20,
dataId: dataId,
operator: 'LT'
}).then( (data:any) => {
this.conditionLt = _.filter(data, {operator: 'LT'})[0];
this.$log.debug('this.conditionLt', this.conditionLt);
});
} else {
this.$log.debug('Going to delete', this.conditionLt.conditionId);
this.HawkularAlertsManager.deleteCondition(triggerId, this.conditionLt.conditionId).then(()=> {
this.conditionLt = undefined;
});
}
var conditionId: string = this.conditionGt.conditionId;

this.conditionGt.thresholdLow = this.conditionLtEnabled ? (this.maxUsage / this.conditionLtPercent) : 0;

this.HawkularAlertsManager.updateCondition(triggerId, conditionId, this.conditionGt).then((data:any) => {
this.conditionGt = data[0];
this.$log.debug('this.conditionGt', this.conditionGt);
});
}


// Get the most meaningful time unit (so that time value is not a very long fraction).
private getTimeUnit(timeValue: number): number {
var timeUnit = 1;
Expand Down Expand Up @@ -348,26 +336,23 @@ module HawkularMetrics {
var dampening = angular.copy(this.dampening);

if (!this.durationEnabled) {
this.dampening.evalTimeSetting = 0;
dampening.evalTimeSetting = 0;
}

return this.HawkularAlertsManager.updateDampening(this.trigger.id,this.dampening.dampeningId,
dampening);
return this.HawkularAlertsManager.updateDampening(this.trigger.id,this.dampening.dampeningId, dampening);
}, (error)=> {
return this.HawkularErrorManager.errorHandler(error, 'Error updating trigger', errorCallback);
}).then(()=> {
this.conditionGt.thresholdHigh = this.conditionGtEnabled ? this.maxUsage * this.conditionGtPercent / 100 :
this.maxUsage;
this.conditionGt.thresholdLow = this.conditionLtEnabled ? this.maxUsage * this.conditionLtPercent / 100 : 0;
return this.HawkularAlertsManager.updateCondition(this.trigger.id, this.conditionGt.conditionId,
this.conditionGt);
}, (error)=> {
return this.HawkularErrorManager.errorHandler(error, 'Error updating dampening.', errorCallback);
}).then(() => {
return this.HawkularAlertsManager.updateCondition(this.trigger.id, this.conditionLt.conditionId,
this.conditionLt);
}, (error) => {
return this.HawkularErrorManager.errorHandler(error, 'Error updating conditionGt condition.', errorCallback);
}).then(angular.noop, (error)=> {
isError = true;
return this.HawkularErrorManager.errorHandler(error, 'Error updating conditionLt condition.', errorCallback);
return this.HawkularErrorManager.errorHandler(error, 'Error updating conditionGt condition.', errorCallback);
}).finally(()=> {
this.saveProgress = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ module HawkularMetrics {
public static MAXIMUM_COLOR = '#f57f20'; /// orange
public static COMMITTED_COLOR = '#515252'; /// dark gray

public static MAX_HEAP = 1024*1024*1024;

public alertList;
public chartHeapData: IMultiDataPoint[];
public chartNonHeapData: IMultiDataPoint[];
Expand Down Expand Up @@ -75,9 +77,9 @@ module HawkularMetrics {
(currentPersona) => currentPersona && this.getJvmData());
}

var metricId = 'MI~R~[' + this.$routeParams.resourceId + '~/]~MT~WildFly Memory Metrics~Heap Used';
//var metricId = 'MI~R~[' + this.$routeParams.resourceId + '~/]~MT~WildFly Memory Metrics~Heap Used';

this.getAlerts(metricId, this.startTimeStamp, this.endTimeStamp);
this.getAlerts(this.$routeParams.resourceId + '_jvm_pheap', this.startTimeStamp, this.endTimeStamp);

this.autoRefresh(20);
}
Expand Down Expand Up @@ -151,6 +153,7 @@ module HawkularMetrics {
this.autoRefreshPromise = this.$interval(() => {
this.getJvmData();
this.getJvmChartData();
this.getAlerts(this.$routeParams.resourceId + '_jvm_pheap', this.startTimeStamp, this.endTimeStamp);
}, intervalInSeconds * 1000);

this.$scope.$on('$destroy', () => {
Expand All @@ -176,6 +179,7 @@ module HawkularMetrics {
end: this.endTimeStamp,
buckets: 1}, (resource) => {
this['heapMax'] = resource[0];
AppServerJvmDetailsController.MAX_HEAP = resource[0].max;
}, this);
this.HawkularMetric.CounterMetricData(this.$rootScope.currentPersona.id).queryMetrics({
counterId: 'MI~R~[' + this.$routeParams.resourceId + '~/]~MT~WildFly Memory Metrics~Accumulated GC Duration',
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<version.gnu.getopt>1.0.13</version.gnu.getopt>
<version.org.hawkular.accounts>1.0.8.Final</version.org.hawkular.accounts>
<version.org.hawkular.agent>0.3.4.Final</version.org.hawkular.agent>
<version.org.hawkular.alerts>0.3.1.Final</version.org.hawkular.alerts>
<version.org.hawkular.alerts>0.3.2.Final</version.org.hawkular.alerts>
<version.org.hawkular.availCreator>${project.version}</version.org.hawkular.availCreator>
<version.org.hawkular.bus>0.3.3.Final</version.org.hawkular.bus>
<version.org.hawkular.commons>0.1.1.Final</version.org.hawkular.commons>
Expand Down

0 comments on commit 94f272d

Please sign in to comment.