Prometheus: Add off switch for metric/label name lookup (#24034)

* Prometheus: Add off switch for metric/label name lookup

This will help users with amounts of metric name
data that is too much for a browser to handle.

Autocomplete will be disabled and metrics chooser hidden,
since obviously both rely on this data.

Fixes #22702

* Use onUpdateDatasourceJsonDataOptionChecked

... from `@grafana/data`. Refactor naming to faciliate its
use and stick with prop names as passed down from
`ConfigEditor`.

PLUS:
- Rephrase switch label, add a tooltip and reduce the
size of the to what "Custom query parameters" originally
was.
- Change `languageProvider` type in `PromQueryField`.

* Put language provider back in

Functions and history still work, even when metrics
lookup gets disabled.
Also: Rewording of setting.

* Display a message when lookup got disabled manually

* Call property for setting disableMetricsLookup

* Show disabled metrics chooser instead of warning
This commit is contained in:
Andreas Opferkuch
2020-05-05 18:02:55 +02:00
committed by GitHub
parent 42ba13b346
commit de0e1b2c58
7 changed files with 100 additions and 31 deletions

View File

@@ -112,10 +112,15 @@ export default class PromQlLanguageProvider extends LanguageProvider {
};
start = async (): Promise<any[]> => {
if (this.datasource.lookupsDisabled) {
return [];
}
this.metrics = await this.request('/api/v1/label/__name__/values', []);
this.lookupsDisabled = this.metrics.length > this.lookupMetricsThreshold;
this.metricsMetadata = await this.request('/api/v1/metadata', {});
this.processHistogramMetrics(this.metrics);
return [];
};