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
This commit is contained in:
@@ -329,11 +329,13 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else if (!event.shiftKey) {
|
||||||
|
// Run queries if Shift is not pressed, otherwise pass through
|
||||||
this.executeOnChangeAndRunQueries();
|
this.executeOnChangeAndRunQueries();
|
||||||
|
|
||||||
return undefined;
|
return true;
|
||||||
}
|
}
|
||||||
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
onKeyDown = (event: KeyboardEvent, change: Change) => {
|
onKeyDown = (event: KeyboardEvent, change: Change) => {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import QueryField, { TypeaheadInput, QueryFieldState } from 'app/features/explor
|
|||||||
// dom also includes Element polyfills
|
// dom also includes Element polyfills
|
||||||
import { getNextCharacter, getPreviousCousin } from 'app/features/explore/utils/dom';
|
import { getNextCharacter, getPreviousCousin } from 'app/features/explore/utils/dom';
|
||||||
import BracesPlugin from 'app/features/explore/slate-plugins/braces';
|
import BracesPlugin from 'app/features/explore/slate-plugins/braces';
|
||||||
import RunnerPlugin from 'app/features/explore/slate-plugins/runner';
|
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { LokiQuery } from '../types';
|
import { LokiQuery } from '../types';
|
||||||
@@ -77,7 +76,6 @@ export interface LokiQueryFieldFormProps extends ExploreQueryFieldProps<ExploreD
|
|||||||
|
|
||||||
export class LokiQueryFieldForm extends React.PureComponent<LokiQueryFieldFormProps> {
|
export class LokiQueryFieldForm extends React.PureComponent<LokiQueryFieldFormProps> {
|
||||||
plugins: any[];
|
plugins: any[];
|
||||||
pluginsSearch: any[];
|
|
||||||
modifiedSearch: string;
|
modifiedSearch: string;
|
||||||
modifiedQuery: string;
|
modifiedQuery: string;
|
||||||
|
|
||||||
@@ -86,14 +84,11 @@ export class LokiQueryFieldForm extends React.PureComponent<LokiQueryFieldFormPr
|
|||||||
|
|
||||||
this.plugins = [
|
this.plugins = [
|
||||||
BracesPlugin(),
|
BracesPlugin(),
|
||||||
RunnerPlugin({ handler: props.onRunQuery }),
|
|
||||||
PluginPrism({
|
PluginPrism({
|
||||||
onlyIn: (node: any) => node.type === 'code_block',
|
onlyIn: (node: any) => node.type === 'code_block',
|
||||||
getSyntax: (node: any) => 'promql',
|
getSyntax: (node: any) => 'promql',
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
this.pluginsSearch = [RunnerPlugin({ handler: props.onRunQuery })];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadOptions = (selectedOptions: CascaderOption[]) => {
|
loadOptions = (selectedOptions: CascaderOption[]) => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"id": "loki",
|
"id": "loki",
|
||||||
"category": "logging",
|
"category": "logging",
|
||||||
|
|
||||||
"metrics": true,
|
"metrics": false,
|
||||||
"alerting": false,
|
"alerting": false,
|
||||||
"annotations": false,
|
"annotations": false,
|
||||||
"logs": true,
|
"logs": true,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import { TypeaheadOutput, HistoryItem } from 'app/types/explore';
|
|||||||
// dom also includes Element polyfills
|
// dom also includes Element polyfills
|
||||||
import { getNextCharacter, getPreviousCousin } from 'app/features/explore/utils/dom';
|
import { getNextCharacter, getPreviousCousin } from 'app/features/explore/utils/dom';
|
||||||
import BracesPlugin from 'app/features/explore/slate-plugins/braces';
|
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 QueryField, { TypeaheadInput, QueryFieldState } from 'app/features/explore/QueryField';
|
||||||
import { PromQuery } from '../types';
|
import { PromQuery } from '../types';
|
||||||
import { CancelablePromise, makePromiseCancelable } from 'app/core/utils/CancelablePromise';
|
import { CancelablePromise, makePromiseCancelable } from 'app/core/utils/CancelablePromise';
|
||||||
@@ -126,7 +125,6 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
|
|||||||
|
|
||||||
this.plugins = [
|
this.plugins = [
|
||||||
BracesPlugin(),
|
BracesPlugin(),
|
||||||
RunnerPlugin({ handler: props.onRunQuery }),
|
|
||||||
PluginPrism({
|
PluginPrism({
|
||||||
onlyIn: (node: any) => node.type === 'code_block',
|
onlyIn: (node: any) => node.type === 'code_block',
|
||||||
getSyntax: (node: any) => 'promql',
|
getSyntax: (node: any) => 'promql',
|
||||||
|
|||||||
Reference in New Issue
Block a user