|
@@ -105,7 +105,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
|
|
|
|
|
|
|
|
async getLabels(selectedMetricType, selectedQueryType = this.state.selectedQueryType) {
|
|
async getLabels(selectedMetricType, selectedQueryType = this.state.selectedQueryType) {
|
|
|
let result = { labels: this.state.labels, labelKey: this.state.labelKey };
|
|
let result = { labels: this.state.labels, labelKey: this.state.labelKey };
|
|
|
- if (this.isLabelQuery(selectedQueryType)) {
|
|
|
|
|
|
|
+ if (selectedMetricType && this.isLabelQuery(selectedQueryType)) {
|
|
|
const refId = 'StackdriverTemplateQueryComponent';
|
|
const refId = 'StackdriverTemplateQueryComponent';
|
|
|
const response = await this.props.datasource.getLabels(selectedMetricType, refId);
|
|
const response = await this.props.datasource.getLabels(selectedMetricType, refId);
|
|
|
const labels = Object.keys(response.meta[selectedQueryType]);
|
|
const labels = Object.keys(response.meta[selectedQueryType]);
|
|
@@ -115,55 +115,64 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- servicePicker = (
|
|
|
|
|
- <SimpleSelect
|
|
|
|
|
- value={this.state.selectedService}
|
|
|
|
|
- options={this.state.services}
|
|
|
|
|
- onValueChange={this.onServiceChange}
|
|
|
|
|
- label="Services"
|
|
|
|
|
- />
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- metricTypesPicker = (
|
|
|
|
|
- <SimpleSelect
|
|
|
|
|
- value={this.state.selectedMetricType}
|
|
|
|
|
- options={this.state.metricTypes}
|
|
|
|
|
- onValueChange={this.onMetricTypeChange}
|
|
|
|
|
- label="Metric Types"
|
|
|
|
|
- />
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- labelPicker = (
|
|
|
|
|
- <SimpleSelect
|
|
|
|
|
- value={this.state.labelKey}
|
|
|
|
|
- options={this.state.labels.map(l => ({ value: l, name: l }))}
|
|
|
|
|
- onValueChange={this.onLabelKeyChange}
|
|
|
|
|
- label={
|
|
|
|
|
- this.state.selectedQueryType === MetricFindQueryTypes.ResourceLabels ? 'Resource Label Key' : 'Metric Label Key'
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
renderQueryTypeSwitch(queryType) {
|
|
renderQueryTypeSwitch(queryType) {
|
|
|
switch (queryType) {
|
|
switch (queryType) {
|
|
|
case MetricFindQueryTypes.MetricTypes:
|
|
case MetricFindQueryTypes.MetricTypes:
|
|
|
- return this.servicePicker;
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ <SimpleSelect
|
|
|
|
|
+ value={this.state.selectedService}
|
|
|
|
|
+ options={this.state.services}
|
|
|
|
|
+ onValueChange={this.onServiceChange}
|
|
|
|
|
+ label="Services"
|
|
|
|
|
+ />
|
|
|
|
|
+ );
|
|
|
case MetricFindQueryTypes.MetricLabels:
|
|
case MetricFindQueryTypes.MetricLabels:
|
|
|
case MetricFindQueryTypes.ResourceLabels:
|
|
case MetricFindQueryTypes.ResourceLabels:
|
|
|
case MetricFindQueryTypes.ResourceTypes:
|
|
case MetricFindQueryTypes.ResourceTypes:
|
|
|
return (
|
|
return (
|
|
|
<React.Fragment>
|
|
<React.Fragment>
|
|
|
- {this.servicePicker}
|
|
|
|
|
- {this.metricTypesPicker}
|
|
|
|
|
- {queryType !== MetricFindQueryTypes.ResourceTypes && this.labelPicker}
|
|
|
|
|
|
|
+ <SimpleSelect
|
|
|
|
|
+ value={this.state.selectedService}
|
|
|
|
|
+ options={this.state.services}
|
|
|
|
|
+ onValueChange={this.onServiceChange}
|
|
|
|
|
+ label="Services"
|
|
|
|
|
+ />
|
|
|
|
|
+ <SimpleSelect
|
|
|
|
|
+ value={this.state.selectedMetricType}
|
|
|
|
|
+ options={this.state.metricTypes}
|
|
|
|
|
+ onValueChange={this.onMetricTypeChange}
|
|
|
|
|
+ label="Metric Types"
|
|
|
|
|
+ />
|
|
|
|
|
+ {queryType !== MetricFindQueryTypes.ResourceTypes && (
|
|
|
|
|
+ <SimpleSelect
|
|
|
|
|
+ value={this.state.labelKey}
|
|
|
|
|
+ options={this.state.labels.map(l => ({ value: l, name: l }))}
|
|
|
|
|
+ onValueChange={this.onLabelKeyChange}
|
|
|
|
|
+ label={
|
|
|
|
|
+ this.state.selectedQueryType === MetricFindQueryTypes.ResourceLabels
|
|
|
|
|
+ ? 'Resource Label Key'
|
|
|
|
|
+ : 'Metric Label Key'
|
|
|
|
|
+ }
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
</React.Fragment>
|
|
</React.Fragment>
|
|
|
);
|
|
);
|
|
|
case MetricFindQueryTypes.Alignerns:
|
|
case MetricFindQueryTypes.Alignerns:
|
|
|
case MetricFindQueryTypes.Aggregations:
|
|
case MetricFindQueryTypes.Aggregations:
|
|
|
return (
|
|
return (
|
|
|
<React.Fragment>
|
|
<React.Fragment>
|
|
|
- {this.servicePicker}
|
|
|
|
|
- {this.metricTypesPicker}
|
|
|
|
|
|
|
+ <SimpleSelect
|
|
|
|
|
+ value={this.state.selectedService}
|
|
|
|
|
+ options={this.state.services}
|
|
|
|
|
+ onValueChange={this.onServiceChange}
|
|
|
|
|
+ label="Services"
|
|
|
|
|
+ />
|
|
|
|
|
+ <SimpleSelect
|
|
|
|
|
+ value={this.state.selectedMetricType}
|
|
|
|
|
+ options={this.state.metricTypes}
|
|
|
|
|
+ onValueChange={this.onMetricTypeChange}
|
|
|
|
|
+ label="Metric Types"
|
|
|
|
|
+ />
|
|
|
</React.Fragment>
|
|
</React.Fragment>
|
|
|
);
|
|
);
|
|
|
default:
|
|
default:
|