|
@@ -32,7 +32,6 @@ export class StackdriverFilterCtrl {
|
|
|
|
|
|
|
|
metricDescriptors: any[];
|
|
metricDescriptors: any[];
|
|
|
metrics: any[];
|
|
metrics: any[];
|
|
|
- metricGroups: any[];
|
|
|
|
|
services: any[];
|
|
services: any[];
|
|
|
groupBySegments: any[];
|
|
groupBySegments: any[];
|
|
|
filterSegments: FilterSegments;
|
|
filterSegments: FilterSegments;
|
|
@@ -46,7 +45,6 @@ export class StackdriverFilterCtrl {
|
|
|
this.target = $scope.target;
|
|
this.target = $scope.target;
|
|
|
this.metricDescriptors = [];
|
|
this.metricDescriptors = [];
|
|
|
this.metrics = [];
|
|
this.metrics = [];
|
|
|
- this.metricGroups = [];
|
|
|
|
|
this.services = [];
|
|
this.services = [];
|
|
|
|
|
|
|
|
this.getCurrentProject()
|
|
this.getCurrentProject()
|
|
@@ -103,7 +101,6 @@ export class StackdriverFilterCtrl {
|
|
|
this.metricDescriptors = await this.datasource.getMetricTypes(this.target.defaultProject);
|
|
this.metricDescriptors = await this.datasource.getMetricTypes(this.target.defaultProject);
|
|
|
this.services = this.getServicesList();
|
|
this.services = this.getServicesList();
|
|
|
this.metrics = this.getMetricsList();
|
|
this.metrics = this.getMetricsList();
|
|
|
- this.metricGroups = this.getMetricGroups();
|
|
|
|
|
return this.metricDescriptors;
|
|
return this.metricDescriptors;
|
|
|
} else {
|
|
} else {
|
|
|
return [];
|
|
return [];
|
|
@@ -119,26 +116,6 @@ export class StackdriverFilterCtrl {
|
|
|
return services.length > 0 ? _.uniqBy(services, s => s.value) : [];
|
|
return services.length > 0 ? _.uniqBy(services, s => s.value) : [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- getMetricGroups() {
|
|
|
|
|
- return [
|
|
|
|
|
- this.getTemplateVariablesGroup(),
|
|
|
|
|
- {
|
|
|
|
|
- label: 'Metrics',
|
|
|
|
|
- options: this.getMetricsList(),
|
|
|
|
|
- },
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- getTemplateVariablesGroup() {
|
|
|
|
|
- return {
|
|
|
|
|
- label: 'Template Variables',
|
|
|
|
|
- options: this.templateSrv.variables.map(v => ({
|
|
|
|
|
- label: `$${v.name}`,
|
|
|
|
|
- value: `$${v.name}`,
|
|
|
|
|
- })),
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
getMetricsList() {
|
|
getMetricsList() {
|
|
|
const metricsByService = this.metricDescriptors.filter(m => m.service === this.target.service).map(m => ({
|
|
const metricsByService = this.metricDescriptors.filter(m => m.service === this.target.service).map(m => ({
|
|
|
service: m.service,
|
|
service: m.service,
|
|
@@ -183,7 +160,6 @@ export class StackdriverFilterCtrl {
|
|
|
handleServiceChange(service) {
|
|
handleServiceChange(service) {
|
|
|
this.target.service = service;
|
|
this.target.service = service;
|
|
|
this.metrics = this.getMetricsList();
|
|
this.metrics = this.getMetricsList();
|
|
|
- this.metricGroups = this.getMetricGroups();
|
|
|
|
|
this.setMetricType();
|
|
this.setMetricType();
|
|
|
this.getLabels();
|
|
this.getLabels();
|
|
|
if (!this.metrics.some(m => m.value === this.target.metricType)) {
|
|
if (!this.metrics.some(m => m.value === this.target.metricType)) {
|
|
@@ -194,13 +170,14 @@ export class StackdriverFilterCtrl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
setMetricType() {
|
|
setMetricType() {
|
|
|
- const { valueType, metricKind, unit } = this.metricDescriptors.find(
|
|
|
|
|
- m => m.type === this.templateSrv.replace(this.target.metricType)
|
|
|
|
|
- );
|
|
|
|
|
- this.target.unit = unit;
|
|
|
|
|
- this.target.valueType = valueType;
|
|
|
|
|
- this.target.metricKind = metricKind;
|
|
|
|
|
- this.$rootScope.$broadcast('metricTypeChanged');
|
|
|
|
|
|
|
+ const metric = this.metricDescriptors.find(m => m.type === this.templateSrv.replace(this.target.metricType));
|
|
|
|
|
+ if (metric) {
|
|
|
|
|
+ const { valueType, metricKind, unit } = metric;
|
|
|
|
|
+ this.target.unit = unit;
|
|
|
|
|
+ this.target.valueType = valueType;
|
|
|
|
|
+ this.target.metricKind = metricKind;
|
|
|
|
|
+ this.$rootScope.$broadcast('metricTypeChanged');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async createLabelKeyElements() {
|
|
async createLabelKeyElements() {
|