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

Commit

Permalink
datamining integration
Browse files Browse the repository at this point in the history
  • Loading branch information
pavolloffay committed Mar 22, 2016
1 parent 98e9573 commit 2b6affc
Show file tree
Hide file tree
Showing 8 changed files with 475 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,26 @@ <h2>JVM Heap Usage</h2>
</div>
</div>

<!-- Predicted chart -->
<div class="row row-cards-pf">
<div class="col-xs-12">
<div class="card-pf hk-graph" ng-if="vm.chartHeapData">
<h2>JVM Heap Used Predicted</h2>
<div class="hk-graph-container hk-graph-metrics">
<!-- HINT: colors for the chart can be changed in the hawkular-charts.css -->
<hawkular-chart
data="vm.predictedData.original"
forecast-data="vm.predictedData.predicted"
chart-type="line"
alert-value="1100"
y-axis-units="Usage (MB)">
<!--show-data-points="true"-->
</hawkular-chart>
</div>
</div>
</div>
</div>

<div class="row row-cards-pf">
<div class="col-xs-12">
<div class="card-pf hk-graph" ng-if="vm.chartNonHeapData">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ module HawkularMetrics {
public contextChartHeapUsedData: IContextChartDataPoint[];
public contextChartNonHeapUsedData: IContextChartDataPoint[];
public contextChartGCDurationData: IContextChartDataPoint[];
public predictedData: any = {};

// will contain in the format: 'metric name' : true | false
public skipChartData = {};
Expand All @@ -107,7 +108,8 @@ module HawkularMetrics {
private HawkularNav: any,
private HawkularAlertRouterManager: IHawkularAlertRouterManager,
private MetricsService: IMetricsService,
private $q: ng.IQService) {
private $q: ng.IQService,
private HawkularDatamining: any) {
$scope.vm = this;

this.feedId = this.$routeParams.feedId;
Expand All @@ -117,6 +119,7 @@ module HawkularMetrics {
this.endTimeStamp = +moment();
this.chartHeapData = [];
this.chartNonHeapData = [];
this.predictedData = [];

if ($rootScope.currentPersona) {
this.refresh();
Expand Down Expand Up @@ -264,6 +267,7 @@ module HawkularMetrics {
let heapPromises = [];
let tmpChartNonHeapData = [];
let nonHeapPromises = [];
let tmpPredictedData = { predicted: [], original: []};

const heapCommitted = JVMMetricsTabType.HEAP_COMMITTED;
if (!this.skipChartData[heapCommitted.getKey()]) {
Expand Down Expand Up @@ -297,6 +301,9 @@ module HawkularMetrics {
color: heapUsed.getColor(),
values: chartHeapDataUsed
};

tmpPredictedData.original =
MetricsService.formatBucketedChartOutput(data, AppServerJvmDetailsController.BYTES2MB);
});
}

Expand All @@ -315,8 +322,33 @@ module HawkularMetrics {
};
});
}

/**
* get predicted data
*/
if (!this.skipChartData['Heap Used Forecast']) {
let hUsedPredictPromise = this.HawkularDatamining.Predict(this.$rootScope.currentPersona.id).predict({
metricId: MetricsService.getMetricId('M', this.feedId, this.resourceId,
heapUsed.getWildflyFullMetricName()), ahead: 30
}).$promise;
heapPromises.push(hUsedPredictPromise);
hUsedPredictPromise.then((data) => {

console.log('Predicted data');
console.log('startTimestamp = ' + this.startTimeStamp + ' -> ' + (new Date(this.startTimeStamp)));
console.log('endTimestamp = ' + this.endTimeStamp + ' -> ' + (new Date(this.endTimeStamp)));

console.log('tmpPredictedData');
tmpPredictedData.predicted = this.HawkularDatamining.formatPredictedData(data);
_.each(tmpPredictedData.predicted, (point: any) => {
console.log('date = ' + (point.date) + ' value = ' + point.value);
});
});
}

this.$q.all(heapPromises).finally(() => {
this.chartHeapData = tmpChartHeapData;
this.predictedData = tmpPredictedData;
});

const nonHeapCommitted = JVMMetricsTabType.NON_HEAP_COMMITTED;
Expand Down
90 changes: 90 additions & 0 deletions console/src/main/scripts/plugins/metrics/ts/hawkularDatamining.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
///
/// Copyright 2015-2016 Red Hat, Inc. and/or its affiliates
/// and other contributors as indicated by the @author tags.
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///

/// <reference path="metricsPlugin.ts"/>
/// <reference path="../../includes.ts"/>

module HawkularMetrics {

_module.provider('HawkularDatamining', new function() {
this.setProtocol = function(protocol) {
this.protocol = protocol;
return this;
};

this.setHost = function(host) {
this.host = host;
return this;
};

this.setPort = function(port) {
this.port = 8080;
return this;
};

this.$get = ['$resource', '$location', function($resource, $location) {

this.setProtocol(this.protocol || $location.protocol() || 'http');
this.setHost(this.host || $location.host() || 'localhost');
this.setPort(this.port || $location.port() || '8080');

let prefix = this.protocol + '://' + this.host + ':' + this.port;
let predictionUrlPart = '/hawkular/datamining';
let url = prefix + predictionUrlPart;
let factory: any = {};

factory.Predict = function(tenantId) {
return $resource(url + '/models/:metricId/predict', null, {
predict: {
method: 'GET',
isArray: true,
params: {ahead: '1'},
headers: {'Hawkular-Tenant': tenantId}
}
});
};

factory.formatPredictedData = function(data): IChartDataPoint[] {
function convertBytesToMegaBytes(bytes: number): number {
return bytes / 1024 / 1024;
}

// The schema is different for bucketed output
return _.map(data, (point: IChartDataPoint) => {

//point.timestamp = currentTimestamp;
console.log(point.timestamp);

return {
timestamp: point.timestamp,
date: new Date(point.timestamp),
value: convertBytesToMegaBytes(point.value),
avg: convertBytesToMegaBytes(point.value),
min: 0,
max: 0,
percentile95th: 0,
median: 0,
empty: false,
percentiles: []
};
});
};

return factory;
}];
});
}
6 changes: 6 additions & 0 deletions dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
<version>${version.org.hawkular.agent}</version>
</dependency>

<dependency>
<groupId>org.hawkular.datamining</groupId>
<artifactId>hawkular-datamining-dist</artifactId>
<type>war</type>
</dependency>

<dependency>
<groupId>org.hawkular.inventory</groupId>
<artifactId>hawkular-inventory-dist</artifactId>
Expand Down
1 change: 1 addition & 0 deletions feature-pack/feature-pack-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<copy-artifact artifact="org.hawkular.alerts:hawkular-alerts-rest" to-location="modules/system/layers/hawkular/org/hawkular/nest/main/deployments/hawkular-alerts-rest.war" />
<copy-artifact artifact="org.hawkular.alerts:hawkular-alerts-actions-email" to-location="modules/system/layers/hawkular/org/hawkular/nest/main/deployments/hawkular-alerts-actions-email.war" />

<copy-artifact artifact="org.hawkular.datamining:hawkular-datamining-dist" to-location="modules/system/layers/hawkular/org/hawkular/nest/main/deployments/hawkular-datamining-dist.war" />
<copy-artifact artifact="org.hawkular.inventory:hawkular-inventory-dist" to-location="modules/system/layers/hawkular/org/hawkular/nest/main/deployments/hawkular-inventory-dist.war" />
<copy-artifact artifact="org.hawkular.metrics:hawkular-metrics-component" to-location="modules/system/layers/hawkular/org/hawkular/nest/main/deployments/hawkular-metrics-component.war" />
<copy-artifact artifact="org.hawkular.cmdgw:hawkular-command-gateway-war" to-location="modules/system/layers/hawkular/org/hawkular/nest/main/deployments/hawkular-command-gateway-war.war" />
Expand Down
6 changes: 6 additions & 0 deletions feature-pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
<type>war</type>
</dependency>

<dependency>
<groupId>org.hawkular.datamining</groupId>
<artifactId>hawkular-datamining-dist</artifactId>
<type>war</type>
</dependency>

<dependency>
<groupId>org.hawkular.inventory</groupId>
<artifactId>hawkular-inventory-dist</artifactId>
Expand Down

0 comments on commit 2b6affc

Please sign in to comment.