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

Commit

Permalink
Alerts: JVM alerts views
Browse files Browse the repository at this point in the history
  • Loading branch information
Viliam Rockai committed Aug 13, 2015
1 parent 4a884ed commit 05e2bb8
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 114 deletions.
73 changes: 33 additions & 40 deletions console/src/main/scripts/plugins/directives/alert/html/alert.html
Original file line number Diff line number Diff line change
@@ -1,54 +1,47 @@
<div>
<div class="panel panel-default alert alert-danger" ng-if="alert.type=='AVAILABILITY'">
<div class="panel panel-default alert alert-danger">
<div class="hk-alert-icon">
<i class="fa fa-flag"></i>
</div>
<div class="hk-date">
{{alert.start | date:'d MMM y HH:mm:ss' }}
</div>
<div class="hk-event">
Server <strong>down</strong> for
<hk-time-interval hk-time="alert.durationTime"></hk-time-interval>
(until
<span ng-show="alert.isThisYear && alert.isToday">{{alert.end | date:'HH:mm' }}).</span>
<span ng-show="alert.isThisYear && !alert.isToday">{{alert.end | date:'d MMM HH:mm:ss' }}).</span>
<span ng-show="!alert.isThisYear">{{alert.end | date:'d MMM y HH:mm:ss' }}).</span>
</div>

<div class="alert-resolver">
<a ng-click="alertResolve(alert, $index)" tooltip="Mark as resolved"
tooltip-placement="top"
tooltip-trigger="mouseenter"
tooltip-popup-delay="500">
<i class="fa" ng-class="{'fa-check-square-o': hover, 'fa-square-o': !hover}"
ng-mouseenter="hover = true"
ng-mouseleave="hover = false">
</i>
</a>
</div>
</div>

<div class="panel panel-default alert alert-danger" ng-if="alert.type=='THRESHOLD'">
<div class="hk-alert-icon">
<i class="fa fa-flag"></i>
</div>
<div class="hk-date">
{{alert.start | date:'d MMM y HH:mm:ss' }}
</div>
<div class="hk-event">
<strong>Response time</strong> was above the threshold ({{alert.threshold | number: 0}} ms) for

<hk-time-interval hk-time="alert.durationTime"></hk-time-interval>

(until
<span ng-show="alert.isThisYear && alert.isToday">{{alert.end | date:'HH:mm' }}).</span>
<span ng-show="alert.isThisYear && !alert.isToday">{{alert.end | date:'d MMM HH:mm:ss' }}).</span>
<span ng-show="!alert.isThisYear">{{alert.end | date:'d MMM y HH:mm:ss' }}).</span>
The average response time was {{alert.avg | number: 0}} ms.
<div class="hk-event" ng-switch on="alert.alertType">
<div ng-switch-when="PINGAVAIL">
Server <strong>down</strong> for
<hk-time-interval hk-time="alert.durationTime"></hk-time-interval>
(until
<span ng-show="alert.isThisYear && alert.isToday">{{alert.end | date:'HH:mm' }}).</span>
<span ng-show="alert.isThisYear && !alert.isToday">{{alert.end | date:'d MMM HH:mm:ss' }}).</span>
<span ng-show="!alert.isThisYear">{{alert.end | date:'d MMM y HH:mm:ss' }}).</span>
</div>
<div ng-switch-when="PINGRESPONSE">
<strong>Response time</strong> was above the threshold ({{alert.threshold | number: 0}} ms) for
<hk-time-interval hk-time="alert.durationTime"></hk-time-interval>
(until
<span ng-show="alert.isThisYear && alert.isToday">{{alert.end | date:'HH:mm' }}).</span>
<span ng-show="alert.isThisYear && !alert.isToday">{{alert.end | date:'d MMM HH:mm:ss' }}).</span>
<span ng-show="!alert.isThisYear">{{alert.end | date:'d MMM y HH:mm:ss' }}).</span>
The average response time was {{alert.avg | number: 0}} ms.
</div>
<div ng-switch-when="PHEAP">
<strong>Heap Memory</strong>: The Heap memory usage was {{alert.avg / 1024 / 1024 | number:2}} MB.
</div>
<div ng-switch-when="NHEAP">
<strong>Non Heap Memory</strong>: The Non Heap memory usage was {{alert.avg / 1024 / 1024 | number:2}} MB.
</div>
<div ng-switch-when="GARBA">
<strong>Garbage collection</strong>: The garbage collection took more than {{alert.avg | number:2}} ms.
</div>
<div ng-switch-default>
<strong>Alert</strong>: <code>{{alert}}</code>
</div>
</div>

<div class="alert-resolver">
<a ng-click="alertResolve()" tooltip="Mark as resolved"
<a ng-click="alertResolve(alert, $index)" tooltip="Mark as resolved"
tooltip-placement="top"
tooltip-trigger="mouseenter"
tooltip-popup-delay="500">
Expand All @@ -59,4 +52,4 @@
</a>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,32 @@ <h3 class="pull-left">JVM Status</h3>
</div>
</div>

<!-- Alerts -->
<div class="hk-info-top clearfix">
<h3 class="pull-left">
<button class="btn btn-link hk-trigger" ng-click="vm.showAllAlerts = !vm.showAllAlerts" tooltip-trigger tooltip-placement="top" tooltip="Expand/collapse"><i class="fa" ng-show="vm.alertList.length > 0" ng-class="vm.showAllAlerts ? 'fa-minus-square-o' : 'fa-plus-square-o'"></i> JVM Alerts <span ng-show="vm.alertList.length > 0">({{vm.showAllAlerts ? vm.alertList.length : vm.math.min(vm.alertList.length, 3)}} of {{vm.alertList.length}})</span></button>
<button class="btn btn-link hk-trigger" ng-click="vm.showAllAlerts = !vm.showAllAlerts" tooltip-trigger
tooltip-placement="top" tooltip="Expand/collapse">
<i class="fa" ng-show="vm.alertList.length > 0"
ng-class="vm.showAllAlerts ? 'fa-minus-square-o' : 'fa-plus-square-o'"></i> JVM Alerts
<span ng-show="vm.alertList.length > 0">
({{vm.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>-->
<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>
</div>
<div class="clearfix">
<!-- No Alerts -->
<div class="panel panel-default alert alert-info" ng-show="vm.alertList.length === 0">
<div class="hk-alert-icon"><i class="fa fa-flag gray"></i></div>
<div>No alerts have been fired in this category and time range.</div>
<div class="hk-event">No Alerts have been fired in this category and time range.</div>
</div>
<!-- Alerts exist -->
<div class="panel panel-default alert alert-danger" ng-repeat="alert in vm.alertList | limitTo: (vm.showAllAlerts ? 100000 : 3) track by $index">
<div class="hk-alert-icon"><i class="fa fa-flag"></i></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>
<hk-alert-panel-list class="clearfix" hk-alert-list="vm.alertList"
hk-limit="(vm.showAllAlerts ? 100000 : 3)"></hk-alert-panel-list>
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,43 +298,10 @@ module HawkularMetrics {
this.$scope.$watch(angular.bind(this, () => {
return this.adm;
}), () => {
console.log('watching', this.adm, this.admBak, !angular.equals(this.adm, this.admBak));
this.isSettingChange = !angular.equals(this.adm, this.admBak);
}, true);
}

public xenableHeapGt(): void {
/*
var triggerId: string = this.adm.heap.trigger.id;
var conditionId: string = this.adm.heap.condition.conditionId;
this.adm.heap.condition.thresholdHigh = this.adm.heap.conditionGtEnabled ?
(this.maxUsage / this.adm.heap.conditionGtPercent) : this.maxUsage;
this.HawkularAlertsManager.updateCondition(triggerId, conditionId, this.adm.heap.condition).then((data:any) => {
this.triggerDefinition.heap.conditions = data;
this.adm.heap.condition = data[0];
this.$log.debug('this.conditionGt', this.adm.heap.condition);
});
*/
}

public xenableHeapLt(): void {
/*
var triggerId: string = this.adm.heap.trigger.id;
var conditionId: string = this.adm.heap.condition.conditionId;
this.adm.heap.condition.thresholdLow = this.adm.heap.conditionLtEnabled ?
(this.maxUsage / this.adm.heap.conditionLtPercent) : 0;
this.HawkularAlertsManager.updateCondition(triggerId, conditionId, this.adm.heap.condition).then((data:any) => {
this.triggerDefinition.heap.conditions = data;
this.adm.heap.condition = data[0];
this.$log.debug('this.conditionGt', this.adm.heap.condition);
});
*/
}

public cancel(): void {
this.$modalInstance.dismiss('cancel');
}
Expand Down Expand Up @@ -382,11 +349,14 @@ module HawkularMetrics {
garbaAlertDefinition.conditions[0].threshold = this.adm.garba.conditionEnabled ?
this.adm.garba.conditionThreshold : 0;

var garbaConditionDelete = this.$q.defer().promise;
var garbaConditionDeleteDefer = this.$q.defer();
var garbaConditionDelete: any = garbaConditionDeleteDefer.promise;
if(!this.adm.garba.conditionEnabled) {
this.HawkularAlertsManager.deleteCondition(garbaAlertDefinition.trigger.id,
garbaConditionDelete = this.HawkularAlertsManager.deleteCondition(garbaAlertDefinition.trigger.id,
garbaAlertDefinition.conditions[0].conditionId);
delete garbaAlertDefinition.conditions;
} else {
garbaConditionDeleteDefer.resolve('Nothing to do');
}

var heapSavePromise = this.HawkularAlertsManager.saveAlertDefinition(heapAlertDefinition, errorCallback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,41 @@ module HawkularMetrics {

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

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

this.autoRefresh(20);
}

private getAlerts(metricId:string, startTime:TimestampInMillis, endTime:TimestampInMillis):void {
this.HawkularAlertsManager.queryAlerts(metricId, startTime, endTime,
HawkularMetrics.AlertType.THRESHOLD).then((data)=> {
this.alertList = data.alertList;
private getAlerts(metricIdPrefix:string, startTime:TimestampInMillis, endTime:TimestampInMillis):void {
var pheapArray: any, nheapArray: any, garbaArray:any;

var pheapPromise = this.HawkularAlertsManager.queryAlerts(metricIdPrefix + '_jvm_pheap', startTime, endTime)
.then((pheapData)=> {
_.forEach(pheapData.alertList, (item) => {item['alertType']='PHEAP';});
pheapArray = pheapData.alertList;
}, (error) => {
return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.');
});

var nheapPromise = this.HawkularAlertsManager.queryAlerts(metricIdPrefix + '_jvm_nheap', startTime, endTime)
.then((nheapData)=> {
_.forEach(nheapData.alertList, (item) => {item['alertType']='NHEAP';});
nheapArray = nheapData.alertList;
}, (error) => {
return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.');
});

var garbaPromise = this.HawkularAlertsManager.queryAlerts(metricIdPrefix + '_jvm_garba', startTime, endTime)
.then((garbaData)=> {
_.forEach(garbaData.alertList, (item) => {item['alertType']='GARBA';});
garbaArray = garbaData.alertList;
}, (error) => {
return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.');
});

this.$q.all([pheapPromise, nheapPromise, garbaPromise]).finally(()=> {
this.alertList = [].concat(pheapArray, nheapArray, garbaArray);
});
}

private autoRefreshPromise: ng.IPromise<number>;
Expand Down Expand Up @@ -154,7 +177,7 @@ module HawkularMetrics {
this.autoRefreshPromise = this.$interval(() => {
this.getJvmData();
this.getJvmChartData();
this.getAlerts(this.$routeParams.resourceId + '_jvm_pheap', this.startTimeStamp, this.endTimeStamp);
this.getAlerts(this.$routeParams.resourceId, this.startTimeStamp, this.endTimeStamp);
}, intervalInSeconds * 1000);

this.$scope.$on('$destroy', () => {
Expand Down
17 changes: 12 additions & 5 deletions console/src/main/scripts/plugins/metrics/ts/metricsAlerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,18 @@ module HawkularMetrics {
this.alertsTimeStart = this.alertsTimeEnd - this.alertsTimeOffset;

this.HawkularAlertsManager.queryConsoleAlerts(this.metricId, this.alertsTimeStart, this.alertsTimeEnd, undefined,
this.resCurPage, this.resPerPage).then((queriedAlerts)=> {
this.headerLinks = this.HkHeaderParser.parse(queriedAlerts.headers);
this.alertList = queriedAlerts.alertList;
this.alertList.$resolved = true; // FIXME
}, (error) => { return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.'); });
this.resCurPage, this.resPerPage).then((queriedAlerts)=> {
this.headerLinks = this.HkHeaderParser.parse(queriedAlerts.headers);
_.forEach(queriedAlerts.alertList, (item) => {
if (item['type'] === 'THRESHOLD') {
item['alertType'] = 'PINGRESPONSE';
} else if (item['type'] === 'AVAILABILITY') {
item['alertType'] = 'PINGAVAIL';
}
});
this.alertList = queriedAlerts.alertList;
this.alertList.$resolved = true; // FIXME
}, (error) => { return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.'); });
}

public setPage(page:number):void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ module HawkularMetrics {

private getAlerts(metricId:string, startTime:TimestampInMillis, endTime:TimestampInMillis):void {
this.HawkularAlertsManager.queryConsoleAlerts(metricId, startTime, endTime,
HawkularMetrics.AlertType.AVAILABILITY).then((data)=> {
this.alertList = data.alertList;
HawkularMetrics.AlertType.AVAILABILITY).then((alertAvailData)=> {
_.forEach(alertAvailData.alertList, (item) => { item['alertType']='PINGAVAIL';});
this.alertList = alertAvailData.alertList;
}, (error) => {
return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.');
});
Expand Down
20 changes: 9 additions & 11 deletions console/src/main/scripts/plugins/metrics/ts/metricsResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

/// <reference path='metricsTypes.ts'/>
/// <reference path='metricsPlugin.ts'/>
/// <reference path='services/metricsService.ts'/>
/// <reference path='../../includes.ts'/>

module HawkularMetrics {



export class MetricsViewController {
/// for minification only
public static $inject = ['$scope', '$rootScope', '$interval', '$log', 'HawkularAlert',
Expand All @@ -48,10 +47,10 @@ module HawkularMetrics {
private $log:ng.ILogService,
private HawkularAlert:any,
private $routeParams:any,
private HawkularAlertsManager: IHawkularAlertsManager,
private ErrorsManager: IErrorsManager,
private NotificationsService: INotificationsService,
private MetricsService: IMetricsService ) {
private HawkularAlertsManager:IHawkularAlertsManager,
private ErrorsManager:IErrorsManager,
private NotificationsService:INotificationsService,
private MetricsService:IMetricsService) {
$scope.vm = this;

this.startTimeStamp = +moment().subtract(1, 'hours');
Expand Down Expand Up @@ -86,8 +85,9 @@ module HawkularMetrics {

private getAlerts(metricId:MetricId, startTime:TimestampInMillis, endTime:TimestampInMillis):void {
this.HawkularAlertsManager.queryConsoleAlerts(metricId, startTime, endTime,
HawkularMetrics.AlertType.THRESHOLD).then((data)=> {
this.alertList = data.alertList;
HawkularMetrics.AlertType.THRESHOLD).then((responseAlertData)=> {
_.forEach(responseAlertData.alertList, (item) => { item['alertType']='PINGRESPONSE';});
this.alertList = responseAlertData.alertList;
}, (error) => {
return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.');
});
Expand Down Expand Up @@ -122,7 +122,7 @@ module HawkularMetrics {
this.retrieveThreshold();
}

public getMetricId() :MetricId {
public getMetricId():MetricId {
return this.resourceId + '.status.duration';
}

Expand All @@ -131,7 +131,6 @@ module HawkularMetrics {
}



public refreshSummaryData(metricId:MetricId,
startTime?:TimestampInMillis,
endTime?:TimestampInMillis):void {
Expand Down Expand Up @@ -198,7 +197,6 @@ module HawkularMetrics {

// we want to isolate the response from the data we are feeding to the chart
this.bucketedDataPoints = MetricsService.formatBucketedChartOutput(response);
///console.dir(this.bucketedDataPoints);

if (this.bucketedDataPoints.length) {
// this is basically the DTO for the chart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module HawkularMetrics {
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(triggerId: TriggerId, conditionId: ConditionId): ng.IPromise<void>;
deleteCondition(triggerId: TriggerId, conditionId: ConditionId): ng.IPromise<any>;
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 All @@ -49,8 +49,7 @@ module HawkularMetrics {
queryConsoleAlerts(metricId: MetricId, startTime?:TimestampInMillis, endTime?:TimestampInMillis, type?:AlertType,
currentPage?:number, perPage?:number): any;
queryAlerts(metricId: MetricId, startTime?:TimestampInMillis,
endTime?:TimestampInMillis, alertType?:AlertType,
currentPage?:number, perPage?:number): any
endTime?:TimestampInMillis, currentPage?:number, perPage?:number): any

// Alert definitions part

Expand Down Expand Up @@ -261,7 +260,7 @@ module HawkularMetrics {
return this.HawkularAlert.Condition.put({triggerId: triggerId, conditionId: conditionId}, condition).$promise;
}

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

Expand Down Expand Up @@ -424,7 +423,7 @@ module HawkularMetrics {


public queryAlerts(metricId: MetricId, startTime?:TimestampInMillis, endTime?:TimestampInMillis,
alertType?:AlertType, currentPage?:number, perPage?:number): any {
currentPage?:number, perPage?:number): any {
var alertList = [];
var headers;

Expand Down

0 comments on commit 05e2bb8

Please sign in to comment.