mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
revert prometheus link
This commit is contained in:
@@ -21,6 +21,7 @@ function (angular, _, moment, dateMath) {
|
|||||||
this.name = datasource.name;
|
this.name = datasource.name;
|
||||||
this.supportMetrics = true;
|
this.supportMetrics = true;
|
||||||
this.url = datasource.url;
|
this.url = datasource.url;
|
||||||
|
this.directUrl = datasource.directUrl;
|
||||||
this.basicAuth = datasource.basicAuth;
|
this.basicAuth = datasource.basicAuth;
|
||||||
this.lastErrors = {};
|
this.lastErrors = {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,11 @@
|
|||||||
ng-change="refreshMetricData()">
|
ng-change="refreshMetricData()">
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="tight-form-item">
|
||||||
|
<a href="{{target.prometheusLink}}" target="_blank" bs-tooltip="'Link to Graph in Prometheus'">
|
||||||
|
<i class="fa fa-share-square-o"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ function (angular, _) {
|
|||||||
|
|
||||||
target.expr = target.expr || '';
|
target.expr = target.expr || '';
|
||||||
target.intervalFactor = target.intervalFactor || 2;
|
target.intervalFactor = target.intervalFactor || 2;
|
||||||
|
target.prometheusLink = $scope.linkToPrometheus();
|
||||||
|
|
||||||
$scope.metric = '';
|
$scope.metric = '';
|
||||||
$scope.resolutions = _.map([1,2,3,4,5,10], function(f) {
|
$scope.resolutions = _.map([1,2,3,4,5,10], function(f) {
|
||||||
@@ -27,6 +28,7 @@ function (angular, _) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.refreshMetricData = function() {
|
$scope.refreshMetricData = function() {
|
||||||
|
$scope.target.prometheusLink = $scope.linkToPrometheus();
|
||||||
if (!_.isEqual($scope.oldTarget, $scope.target)) {
|
if (!_.isEqual($scope.oldTarget, $scope.target)) {
|
||||||
$scope.oldTarget = angular.copy($scope.target);
|
$scope.oldTarget = angular.copy($scope.target);
|
||||||
$scope.get_data();
|
$scope.get_data();
|
||||||
@@ -44,6 +46,21 @@ function (angular, _) {
|
|||||||
.then(callback);
|
.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();
|
$scope.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user