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

@@ -153,24 +153,21 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
refreshHint = () => {
const { datasource, query, data } = this.props;
const initHints = datasource.getInitHints();
const initHint = initHints.length > 0 ? initHints[0] : null;
if (!data || data.series.length === 0) {
this.setState({ hint: null });
this.setState({
hint: initHint,
});
return;
}
const result = isDataFrame(data.series[0]) ? data.series.map(toLegacyResponseData) : data.series;
const hints = datasource.getQueryHints(query, result);
let hint = hints.length > 0 ? hints[0] : null;
const queryHints = datasource.getQueryHints(query, result);
let queryHint = queryHints.length > 0 ? queryHints[0] : null;
// Hint for big disabled lookups
if (!hint && datasource.lookupsDisabled) {
hint = {
label: `Labels and metrics lookup was disabled in data source settings.`,
type: 'INFO',
};
}
this.setState({ hint });
this.setState({ hint: queryHint ?? initHint });
};
refreshMetrics = async () => {