Prometheus: Add info that using Loki as Prometheus data source is no longer supported and might stop working (#34650)

* Add information that Loki as Prometheus data source is not supported

* Fix ugly error when loki as prometheus used

* Refactor, add test

* Fix type error

* Fix test by passing missing method

* Update public/app/plugins/datasource/prometheus/query_hints.ts

* Remove optionality in prop
This commit is contained in:
Ivana Huckova
2021-05-28 17:10:10 +02:00
committed by GitHub
parent 6adcfa9e50
commit add1b827ae
6 changed files with 94 additions and 14 deletions

View File

@@ -127,3 +127,24 @@ export function getQueryHints(query: string, series?: any[], datasource?: Promet
return hints;
}
export function getInitHints(datasource: PrometheusDatasource): QueryHint[] {
const hints = [];
// Hint if using Loki as Prometheus data source
if (datasource.directUrl.includes('/loki') && !datasource.languageProvider.metrics.length) {
hints.push({
label: `Using Loki as a Prometheus data source is no longer supported. You must use the Loki data source for your Loki instance.`,
type: 'INFO',
});
}
// Hint for big disabled lookups
if (datasource.lookupsDisabled) {
hints.push({
label: `Labels and metrics lookup was disabled in data source settings.`,
type: 'INFO',
});
}
return hints;
}