Commit bf5b60f7 by David Committed by GitHub

fix(explore): Prevent double querying for Prometheus and Loki (#17004)

* fix(explore): Prevent double querying for Prometheus and Loki

- queries were triggered twice because two Enter handlers existed
- removed runner plugin from Loki and Prom query fields (runner plugin
is still being used in azure)

Part of #16995

* Set loki's mtrics capability to false

Loki is not a metrics store. Explore was using the `metrics` field in
the plugin definition to issue a second query run. But Loki shows only
one result viewer.

Fixes #16995
parent e0b760e0
......@@ -329,11 +329,13 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
}
return true;
} else {
} else if (!event.shiftKey) {
// Run queries if Shift is not pressed, otherwise pass through
this.executeOnChangeAndRunQueries();
return undefined;
return true;
}
return undefined;
};
onKeyDown = (event: KeyboardEvent, change: Change) => {
......
......@@ -12,7 +12,6 @@ import QueryField, { TypeaheadInput, QueryFieldState } from 'app/features/explor
// dom also includes Element polyfills
import { getNextCharacter, getPreviousCousin } from 'app/features/explore/utils/dom';
import BracesPlugin from 'app/features/explore/slate-plugins/braces';
import RunnerPlugin from 'app/features/explore/slate-plugins/runner';
// Types
import { LokiQuery } from '../types';
......@@ -77,7 +76,6 @@ export interface LokiQueryFieldFormProps extends ExploreQueryFieldProps<ExploreD
export class LokiQueryFieldForm extends React.PureComponent<LokiQueryFieldFormProps> {
plugins: any[];
pluginsSearch: any[];
modifiedSearch: string;
modifiedQuery: string;
......@@ -86,14 +84,11 @@ export class LokiQueryFieldForm extends React.PureComponent<LokiQueryFieldFormPr
this.plugins = [
BracesPlugin(),
RunnerPlugin({ handler: props.onRunQuery }),
PluginPrism({
onlyIn: (node: any) => node.type === 'code_block',
getSyntax: (node: any) => 'promql',
}),
];
this.pluginsSearch = [RunnerPlugin({ handler: props.onRunQuery })];
}
loadOptions = (selectedOptions: CascaderOption[]) => {
......
......@@ -4,7 +4,7 @@
"id": "loki",
"category": "logging",
"metrics": true,
"metrics": false,
"alerting": false,
"annotations": false,
"logs": true,
......
......@@ -12,7 +12,6 @@ import { TypeaheadOutput, HistoryItem } from 'app/types/explore';
// dom also includes Element polyfills
import { getNextCharacter, getPreviousCousin } from 'app/features/explore/utils/dom';
import BracesPlugin from 'app/features/explore/slate-plugins/braces';
import RunnerPlugin from 'app/features/explore/slate-plugins/runner';
import QueryField, { TypeaheadInput, QueryFieldState } from 'app/features/explore/QueryField';
import { PromQuery } from '../types';
import { CancelablePromise, makePromiseCancelable } from 'app/core/utils/CancelablePromise';
......@@ -126,7 +125,6 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
this.plugins = [
BracesPlugin(),
RunnerPlugin({ handler: props.onRunQuery }),
PluginPrism({
onlyIn: (node: any) => node.type === 'code_block',
getSyntax: (node: any) => 'promql',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment