Skip to content

Commit

Permalink
Add Resource.id to metrics names when submiting metrics to Hawkular-i…
Browse files Browse the repository at this point in the history
…nventory.
  • Loading branch information
mtho11 committed Feb 25, 2015
1 parent 3db0c97 commit 1922887
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 46 deletions.
39 changes: 19 additions & 20 deletions dist/hawkular-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
var HawkularMetrics;
(function (HawkularMetrics) {
HawkularMetrics.pluginName = "hawkular-metrics";
HawkularMetrics.tenantId = "rest-test";
HawkularMetrics.log = Logger.get(HawkularMetrics.pluginName);
HawkularMetrics.templatePath = "plugins/metrics/html";
})(HawkularMetrics || (HawkularMetrics = {}));
Expand Down Expand Up @@ -60,7 +61,6 @@ var HawkularMetrics;
this.$log = $log;
this.HawkularInventory = HawkularInventory;
this.resourceUrl = resourceUrl;
this.tenantId = 'test';
this.httpUriPart = 'http://';
$scope.vm = this;
this.resourceUrl = this.httpUriPart;
Expand All @@ -75,20 +75,20 @@ var HawkularMetrics;
url: resourceId
}
};
var metrics = [{
name: 'status.time',
unit: 'MILLI_SECOND',
description: 'Response Time in ms.'
}, {
name: 'status.code',
unit: 'NONE',
description: 'Status Code'
}];
this.$log.info("Adding new Resource Url to backend: " + cleanedResourceId);
this.HawkularInventory.Resource.save({ tenantId: this.tenantId }, resource).$promise.then(function (newResource) {
this.$log.info("Adding new Resource Url to Hawkular-inventory: " + cleanedResourceId);
this.HawkularInventory.Resource.save({ tenantId: HawkularMetrics.tenantId }, resource).$promise.then(function (newResource) {
_this.$log.info("New Resource ID: " + newResource.id);
var metrics = [{
name: newResource.id + 'status.duration',
unit: 'MILLI_SECOND',
description: 'Response Time in ms.'
}, {
name: newResource.id + 'status.code',
unit: 'NONE',
description: 'Status Code'
}];
_this.HawkularInventory.Metric.save({
tenantId: _this.tenantId,
tenantId: HawkularMetrics.tenantId,
resourceId: newResource.id
}, metrics).$promise.then(function (newMetrics) {
_this.$location.url("/metrics/metricsResponse");
Expand Down Expand Up @@ -119,13 +119,12 @@ var HawkularMetrics;
this.searchId = '';
this.showPreviousRangeDataOverlay = false;
this.showContextZoom = true;
this.tenantId = 'test';
this.bucketedDataPoints = [];
this.contextDataPoints = [];
$scope.vm = this;
this.startTimeStamp = moment().subtract(72, 'hours').toDate();
this.startTimeStamp = moment().subtract(24, 'hours').toDate();
this.endTimeStamp = new Date();
this.dateRange = moment().subtract(72, 'hours').from(moment());
this.dateRange = moment().subtract(24, 'hours').from(moment());
$scope.$watch('vm.searchId', function (newValue, oldValue) {
_this.refreshChartDataNow();
});
Expand Down Expand Up @@ -171,7 +170,7 @@ var HawkularMetrics;
return nextTimeRange[1].getTime() < new Date().getTime();
};
MetricsViewController.prototype.refreshChartDataNow = function (startTime) {
var metricList = this.HawkularInventory.Resource.query({ tenantId: this.tenantId });
var metricList = this.HawkularInventory.Resource.query({ tenantId: HawkularMetrics.tenantId });
console.dir(metricList);
var adjStartTimeStamp = moment().subtract('hours', 72).toDate();
this.$rootScope.$broadcast('MultiChartOverlayDataChanged');
Expand All @@ -190,7 +189,7 @@ var HawkularMetrics;
startTime = this.startTimeStamp.getTime();
}
if (this.searchId !== '') {
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: this.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60 }).$promise.then(function (response) {
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: HawkularMetrics.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60 }).$promise.then(function (response) {
console.dir(response);
_this.bucketedDataPoints = _this.formatBucketedChartOutput(response);
console.dir(_this.bucketedDataPoints);
Expand Down Expand Up @@ -237,7 +236,7 @@ var HawkularMetrics;
var _this = this;
var previousTimeRange = MetricsViewController.calculatePreviousTimeRange(this.startTimeStamp, this.endTimeStamp);
if (this.searchId !== '') {
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: this.tenantId, numericId: this.searchId, start: previousTimeRange[0], end: previousTimeRange[1], buckets: 60 }).$promise.then(function (response) {
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: HawkularMetrics.tenantId, numericId: this.searchId, start: previousTimeRange[0], end: previousTimeRange[1], buckets: 60 }).$promise.then(function (response) {
var prevTimeRangeBucketedDataPoints = _this.formatPreviousBucketedOutput(response);
if (angular.isDefined(prevTimeRangeBucketedDataPoints) && prevTimeRangeBucketedDataPoints.length !== 0) {
_this.chartData = {
Expand Down Expand Up @@ -290,7 +289,7 @@ var HawkularMetrics;
this.$log.warn('Start Date was >= End Date');
return;
}
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: this.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60 }).$promise.then(function (response) {
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: HawkularMetrics.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60 }).$promise.then(function (response) {
_this.chartData.contextDataPoints = _this.formatContextOutput(response);
if (angular.isUndefined(_this.chartData.contextDataPoints) || _this.chartData.contextDataPoints.length === 0) {
_this.noDataFoundForId(_this.searchId);
Expand Down
3 changes: 1 addition & 2 deletions plugins/metrics/d.ts/metrics/ts/addUrlPage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ declare module HawkularMetrics {
private HawkularInventory;
resourceUrl: string;
static $inject: string[];
tenantId: string;
httpUriPart: string;
private httpUriPart;
constructor($location: ng.ILocationService, $scope: any, $log: ng.ILogService, HawkularInventory: any, resourceUrl: string);
addUrl(resourceId: string): void;
}
Expand Down
1 change: 1 addition & 0 deletions plugins/metrics/d.ts/metrics/ts/metricsGlobals.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="../../includes.d.ts" />
declare module HawkularMetrics {
var pluginName: string;
var tenantId: string;
var log: Logging.Logger;
var templatePath: string;
}
1 change: 0 additions & 1 deletion plugins/metrics/d.ts/metrics/ts/metricsResponsePage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ declare module HawkularMetrics {
searchId: string;
showPreviousRangeDataOverlay: boolean;
showContextZoom: boolean;
private tenantId;
constructor($scope: any, $rootScope: ng.IRootScopeService, $interval: ng.IIntervalService, $log: ng.ILogService, HawkularMetric: any, HawkularInventory: any, startTimeStamp: Date, endTimeStamp: Date, dateRange: string);
private bucketedDataPoints;
private contextDataPoints;
Expand Down
34 changes: 18 additions & 16 deletions plugins/metrics/plugins/metrics/ts/addUrlPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

module HawkularMetrics {


export class AddUrlController {
public static $inject = ['$location', '$scope', '$log', 'HawkularInventory'];

///@todo: fixed tenant until we get it from KeyCloak
tenantId = 'test';
httpUriPart = 'http://';
private httpUriPart = 'http://';

constructor(private $location:ng.ILocationService,
private $scope:any,
Expand All @@ -43,26 +42,29 @@ module HawkularMetrics {
url: resourceId
}
};
var metrics = [{
name: 'status.time',
unit: 'MILLI_SECOND',
description: 'Response Time in ms.'
}, {
name: 'status.code',
unit: 'NONE',
description: 'Status Code'
}];

this.$log.info("Adding new Resource Url to backend: " + cleanedResourceId);

this.$log.info("Adding new Resource Url to Hawkular-inventory: " + cleanedResourceId);

/// Add the Resource
this.HawkularInventory.Resource.save({tenantId: this.tenantId}, resource).$promise
this.HawkularInventory.Resource.save({tenantId: tenantId}, resource).$promise
.then((newResource) => {
// we now have a resourceId from this call
this.$log.info("New Resource ID: " + newResource.id);
var metrics = [{
name: newResource.id + 'status.duration',
unit: 'MILLI_SECOND',
description: 'Response Time in ms.'
}, {
name: newResource.id + 'status.code',
unit: 'NONE',
description: 'Status Code'
}];


/// @todo: this will become the 'Metrics Selection' screen once we get that
/// For right now we will just Register a couple of metrics automatically
this.HawkularInventory.Metric.save({
tenantId: this.tenantId,
tenantId: tenantId,
resourceId: newResource.id
}, metrics).$promise.then((newMetrics) => {
/// Hop on over to the metricsView page for charting
Expand Down
2 changes: 2 additions & 0 deletions plugins/metrics/plugins/metrics/ts/metricsGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module HawkularMetrics {

export var pluginName = "hawkular-metrics";

export var tenantId = "rest-test";

export var log:Logging.Logger = Logger.get(pluginName);

export var templatePath = "plugins/metrics/html";
Expand Down
13 changes: 6 additions & 7 deletions plugins/metrics/plugins/metrics/ts/metricsResponsePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ module HawkularMetrics {
searchId = '';
showPreviousRangeDataOverlay = false;
showContextZoom = true;
private tenantId = 'test';

constructor(private $scope:any,
private $rootScope:ng.IRootScopeService,
Expand All @@ -97,9 +96,9 @@ module HawkularMetrics {
public dateRange:string) {
$scope.vm = this;

this.startTimeStamp = moment().subtract(72, 'hours').toDate();
this.startTimeStamp = moment().subtract(24, 'hours').toDate();
this.endTimeStamp = new Date();
this.dateRange = moment().subtract(72, 'hours').from(moment());
this.dateRange = moment().subtract(24, 'hours').from(moment());

$scope.$watch('vm.searchId', (newValue, oldValue) => {
this.refreshChartDataNow();
Expand Down Expand Up @@ -181,7 +180,7 @@ module HawkularMetrics {


refreshChartDataNow(startTime?:Date):void {
var metricList = this.HawkularInventory.Resource.query({tenantId: this.tenantId});
var metricList = this.HawkularInventory.Resource.query({tenantId: tenantId});
console.dir(metricList);

var adjStartTimeStamp:Date = moment().subtract('hours', 72).toDate(); //default time period set to 24 hours
Expand Down Expand Up @@ -212,7 +211,7 @@ module HawkularMetrics {

if (this.searchId !== '') {

this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: this.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60}).$promise
this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60}).$promise
.then((response) => {
console.dir(response);
// we want to isolate the response from the data we are feeding to the chart
Expand Down Expand Up @@ -270,7 +269,7 @@ module HawkularMetrics {
var previousTimeRange = MetricsViewController.calculatePreviousTimeRange(this.startTimeStamp, this.endTimeStamp);

if (this.searchId !== '') {
this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: this.tenantId, numericId: this.searchId, start: previousTimeRange[0], end: previousTimeRange[1], buckets: 60}).$promise
this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: tenantId, numericId: this.searchId, start: previousTimeRange[0], end: previousTimeRange[1], buckets: 60}).$promise
.then((response) => {
// we want to isolate the response from the data we are feeding to the chart
var prevTimeRangeBucketedDataPoints = this.formatPreviousBucketedOutput(response);
Expand Down Expand Up @@ -337,7 +336,7 @@ module HawkularMetrics {
}


this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: this.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60}).$promise
this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60}).$promise
.then((response) => {

this.chartData.contextDataPoints = this.formatContextOutput(response);
Expand Down

0 comments on commit 1922887

Please sign in to comment.