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 #355 from ammendonca/HAWKULAR-462
Browse files Browse the repository at this point in the history
HAWKULAR-462 : Add GC Info to JVM Metrics Screen
  • Loading branch information
mtho11 committed Jul 25, 2015
2 parents 59a0350 + 48e33ab commit 989031d
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ <h3 class="pull-left">JVM Status</h3>
<span class="hk-item">Average Heap Usage</span>
</div>
<div class="col-sm-3 hk-summary-item">
<span class="hk-data" ng-show="vm.garbageCollector">{{ vm.garbageCollector.gc / 1024 / 1024 | number : 0 }} s</span>
<span class="hk-data" ng-hide="vm.garbageCollector">n/a</span>
<span class="hk-item">Last Garbage Collection (Duration)</span>
<span class="hk-data" ng-show="vm.accGCDuration">{{ vm.accGCDuration }}ms</span>
<span class="hk-data" ng-hide="vm.accGCDuration">n/a</span>
<span class="hk-item">Accumulated GC Duration</span>
</div>
<div class="col-sm-3 hk-summary-item">
<span class="hk-data" ng-show="vm.heapMax">{{ vm.heapMax.max / 1024 / 1024 | number : 0 }} MB</span>
Expand Down Expand Up @@ -89,4 +89,21 @@ <h2>Non Heap Usage</h2>
</div>
</div>

</section>
<div class="panel panel-default hk-graph" ng-if="vm.chartNonHeapData[0]">
<h2>Accumulated GC Duration</h2>
<div class="metrics-chart">
<!-- HINT: colors for the chart can be changed in the hawkular-charts.css -->
<hawkular-chart
data="{{vm.chartGCDurationData}}"
chart-type="histogram"
alert-value="{{vm.threshold}}"
use-zero-min-value="true"
y-axis-units="GC Duration (ms)"
chart-height="250">
</hawkular-chart>
</div>
<div class="hk-legend text-left">
</div>
</div>

</section>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module HawkularMetrics {
export class AppServerJvmDetailsController {
/// this is for minification purposes
public static $inject = ['$location', '$scope', '$rootScope', '$interval', '$log', '$filter', '$routeParams',
'$modal', 'HawkularInventory', 'HawkularMetric', 'HawkularAlert', 'HawkularAlertsManager',
'$modal', '$window', 'HawkularInventory', 'HawkularMetric', 'HawkularAlert', 'HawkularAlertsManager',
'HawkularErrorManager', '$q', 'md5'];

public static USED_COLOR = '#1884c7'; /// blue
Expand All @@ -42,6 +42,7 @@ module HawkularMetrics {
public chartNonHeapData: IMultiDataPoint[];
public startTimeStamp:TimestampInMillis;
public endTimeStamp:TimestampInMillis;
public chartGCDurationData: IChartDataPoint[];

constructor(private $location: ng.ILocationService,
private $scope: any,
Expand All @@ -51,6 +52,7 @@ module HawkularMetrics {
private $filter: ng.IFilterService,
private $routeParams: any,
private $modal: any,
private $window: any,
private HawkularInventory: any,
private HawkularMetric: any,
private HawkularAlert: any,
Expand All @@ -66,11 +68,11 @@ module HawkularMetrics {
this.chartNonHeapData = [];

if ($rootScope.currentPersona) {
this.getJvmData(this.$rootScope.currentPersona.id);
this.getJvmData();
} else {
// currentPersona hasn't been injected to the rootScope yet, wait for it..
$rootScope.$watch('currentPersona',
(currentPersona) => currentPersona && this.getJvmData(currentPersona.id));
(currentPersona) => currentPersona && this.getJvmData());
}

this.autoRefresh(20);
Expand All @@ -97,6 +99,41 @@ module HawkularMetrics {
});
}

private formatCounterChartOutput(response, buckets = 60):IChartDataPoint[] {
var result = response;
/// FIXME: Simulating buckets.. this should come from metrics.
if (response.length > buckets) {
var step = this.$window.Math.floor(response.length / buckets);
result = [];
var accValue = 0;
_.forEach(response, function(point:any, idx) {
if (parseInt(idx, 10) % step === (step-1)) {
result.push({timestamp: point.timestamp, value: accValue });
accValue = 0;
}
else {
accValue += point.value;
}
});
}

// The schema is different for bucketed output
return _.map(result, (point:IChartDataPoint, idx) => {
var theValue = idx === 0 ? 0 : (result[idx-1].value - point.value);
return {
timestamp: point.timestamp,
date: new Date(point.timestamp),
value: theValue,
avg: theValue,
min: theValue,
max: theValue,
percentile95th: theValue,
median: theValue,
empty: !angular.isNumber(point.value)
};
});
}

public autoRefresh(intervalInSeconds: number): void {
this.autoRefreshPromise = this.$interval(() => {
this.getJvmData();
Expand All @@ -108,12 +145,11 @@ module HawkularMetrics {
});
}

public getJvmData(currentTenantId?: TenantId): any {
public getJvmData(): any {
this.alertList = []; // FIXME: when we have alerts for app server
this.endTimeStamp = this.$routeParams.endTime || +moment();
this.startTimeStamp = this.endTimeStamp - (this.$routeParams.timeOffset || 3600000);

var tenantId:TenantId = currentTenantId || this.$rootScope.currentPersona.id;
this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~[' + this.$routeParams.resourceId + '~/]~MT~WildFly Memory Metrics~Heap Used',
start: this.startTimeStamp,
Expand All @@ -128,15 +164,22 @@ module HawkularMetrics {
buckets: 1}, (resource) => {
this['heapMax'] = resource[0];
}, this);
this.getJvmChartData(currentTenantId);
this.HawkularMetric.CounterMetricData(this.$rootScope.currentPersona.id).queryMetrics({
counterId: 'MI~R~[' + this.$routeParams.resourceId + '~/]~MT~WildFly Memory Metrics~Accumulated GC Duration',
start: this.startTimeStamp,
end: this.endTimeStamp,
buckets: 1}, (resource) => {
this['accGCDuration'] = resource[0].value - resource[resource.length-1].value;
this.chartGCDurationData = this.formatCounterChartOutput(resource);
}, this);
this.getJvmChartData();
}

public getJvmChartData(currentTenantId?: TenantId): any {
public getJvmChartData(): any {

this.endTimeStamp = this.$routeParams.endTime || +moment();
this.startTimeStamp = this.endTimeStamp - (this.$routeParams.timeOffset || 3600000);

//var tenantId:TenantId = currentTenantId || this.$rootScope.currentPersona.id;
this.HawkularMetric.GaugeMetricData(this.$rootScope.currentPersona.id).queryMetrics({
gaugeId: 'MI~R~[' + this.$routeParams.resourceId + '~/]~MT~WildFly Memory Metrics~Heap Committed',
start: this.startTimeStamp,
Expand Down

0 comments on commit 989031d

Please sign in to comment.