mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
add loading custom metrics definitions
This commit is contained in:
@@ -172,6 +172,47 @@ function (angular, _, kbn) {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
/* jshint +W101 */
|
/* jshint +W101 */
|
||||||
|
|
||||||
|
/* load custom metrics definitions */
|
||||||
|
var self = this;
|
||||||
|
$q.all(
|
||||||
|
_.map(datasource.jsonData.customMetricsAttributes, function(u) {
|
||||||
|
return $http({ method: 'GET', url: u });
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(function(allResponse) {
|
||||||
|
_.chain(allResponse)
|
||||||
|
.map(function(d) {
|
||||||
|
return d.data.Metrics;
|
||||||
|
})
|
||||||
|
.flatten()
|
||||||
|
.reject(function(metric) {
|
||||||
|
return metric.Namespace.indexOf('AWS/') === 0;
|
||||||
|
})
|
||||||
|
.map(function(metric) {
|
||||||
|
metric.Dimensions = _.chain(metric.Dimensions)
|
||||||
|
.map(function(d) {
|
||||||
|
return d.Name;
|
||||||
|
})
|
||||||
|
.value().sort();
|
||||||
|
return metric;
|
||||||
|
})
|
||||||
|
.uniq(function(metric) {
|
||||||
|
return metric.Namespace + metric.MetricName + metric.Dimensions.join('');
|
||||||
|
})
|
||||||
|
.each(function(metric) {
|
||||||
|
if (!_.has(self.supportedMetrics, metric.Namespace)) {
|
||||||
|
self.supportedMetrics[metric.Namespace] = [];
|
||||||
|
}
|
||||||
|
self.supportedMetrics[metric.Namespace].push(metric.MetricName);
|
||||||
|
|
||||||
|
if (!_.has(self.supportedDimensions, metric.Namespace)) {
|
||||||
|
self.supportedDimensions[metric.Namespace] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.supportedDimensions[metric.Namespace] = _.union(self.supportedDimensions[metric.Namespace], metric.Dimensions);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once per panel (graph)
|
// Called once per panel (graph)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tight-form last" ng-show="current.jsonData.access === 'direct'">
|
<div class="tight-form" ng-show="current.jsonData.access === 'direct'">
|
||||||
<ul class="tight-form-list">
|
<ul class="tight-form-list">
|
||||||
<li class="tight-form-item" style="width: 80px">
|
<li class="tight-form-item" style="width: 80px">
|
||||||
Access Key Id
|
Access Key Id
|
||||||
@@ -37,3 +37,14 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tight-form last">
|
||||||
|
<ul class="tight-form-list">
|
||||||
|
<li class="tight-form-item" style="width: 80px">
|
||||||
|
Custom Metrics Attributes
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<input type="text" class="tight-form-input input-xlarge" ng-model='current.jsonData.customMetricsAttributes[0]' ng-init="current.jsonData.customMetricsAttributes = current.jsonData.customMetricsAttributes || []" placeholder="" required></input>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user