Merge pull request #3008 from mtanda/prometheus_link

Revert prometheus graph view link
This commit is contained in:
Torkel Ödegaard 2015-10-28 09:29:07 +01:00
commit 89eedd59a8
3 changed files with 21 additions and 0 deletions

View File

@ -21,6 +21,7 @@ function (angular, _, moment, dateMath) {
this.name = datasource.name;
this.supportMetrics = true;
this.url = datasource.url;
this.directUrl = datasource.directUrl;
this.basicAuth = datasource.basicAuth;
this.lastErrors = {};
}

View File

@ -110,6 +110,11 @@
ng-change="refreshMetricData()">
</select>
</li>
<li class="tight-form-item">
<a href="{{linkToPrometheus()}}" target="_blank" bs-tooltip="'Link to Graph in Prometheus'">
<i class="fa fa-share-square-o"></i>
</a>
</li>
</ul>
<div class="clearfix"></div>

View File

@ -44,6 +44,21 @@ function (angular, _) {
.then(callback);
};
$scope.linkToPrometheus = function() {
var range = Math.ceil(($scope.range.to.valueOf() - $scope.range.from.valueOf()) / 1000);
var endTime = $scope.range.to.utc().format('YYYY-MM-DD HH:MM');
var expr = {
expr: $scope.target.expr,
range_input: range + 's',
end_input: endTime,
step_input: '',
stacked: $scope.panel.stack,
tab: 0
};
var hash = encodeURIComponent(JSON.stringify([expr]));
return $scope.datasource.directUrl + '/graph#' + hash;
};
$scope.init();
});