diff --git a/public/app/plugins/datasource/loki/querybuilder/operations.ts b/public/app/plugins/datasource/loki/querybuilder/operations.ts index 0fb3d593d35..062af2255ea 100644 --- a/public/app/plugins/datasource/loki/querybuilder/operations.ts +++ b/public/app/plugins/datasource/loki/querybuilder/operations.ts @@ -15,7 +15,7 @@ import { labelFilterRenderer, pipelineRenderer, } from './operationUtils'; -import { LokiOperationId, LokiOperationOrder, LokiVisualQueryOperationCategory } from './types'; +import { LokiOperationId, LokiOperationOrder, lokiOperators, LokiVisualQueryOperationCategory } from './types'; export function getOperationDefinitions(): QueryBuilderOperationDef[] { const aggregations = [ @@ -352,7 +352,12 @@ Example: \`\`error_level=\`level\` \`\` id: LokiOperationId.LineFilterIpMatches, name: 'IP line filter expression', params: [ - { name: 'Operator', type: 'string', options: ['|=', '!='] }, + { + name: 'Operator', + type: 'string', + minWidth: 16, + options: [lokiOperators.contains, lokiOperators.doesNotContain], + }, { name: 'Pattern', type: 'string', @@ -373,9 +378,23 @@ Example: \`\`error_level=\`level\` \`\` id: LokiOperationId.LabelFilter, name: 'Label filter expression', params: [ - { name: 'Label', type: 'string' }, - { name: 'Operator', type: 'string', options: ['=', '!=', ' =~', '!~', '>', '<', '>=', '<='] }, - { name: 'Value', type: 'string' }, + { name: 'Label', type: 'string', minWidth: 14 }, + { + name: 'Operator', + type: 'string', + minWidth: 14, + options: [ + lokiOperators.equals, + lokiOperators.doesNotEqual, + lokiOperators.matchesRegex, + lokiOperators.doesNotMatchRegex, + lokiOperators.greaterThan, + lokiOperators.lessThan, + lokiOperators.greaterThanOrEqual, + lokiOperators.lessThanOrEqual, + ], + }, + { name: 'Value', type: 'string', minWidth: 14 }, ], defaultParams: ['', '=', ''], alternativesKey: 'label filter', @@ -389,9 +408,14 @@ Example: \`\`error_level=\`level\` \`\` id: LokiOperationId.LabelFilterIpMatches, name: 'IP label filter expression', params: [ - { name: 'Label', type: 'string' }, - { name: 'Operator', type: 'string', options: ['=', '!='] }, - { name: 'Value', type: 'string' }, + { name: 'Label', type: 'string', minWidth: 14 }, + { + name: 'Operator', + type: 'string', + minWidth: 14, + options: [lokiOperators.equals, lokiOperators.doesNotEqual], + }, + { name: 'Value', type: 'string', minWidth: 14 }, ], defaultParams: ['', '=', ''], alternativesKey: 'label filter', diff --git a/public/app/plugins/datasource/loki/querybuilder/types.ts b/public/app/plugins/datasource/loki/querybuilder/types.ts index e4f30107b71..cc526f91a83 100644 --- a/public/app/plugins/datasource/loki/querybuilder/types.ts +++ b/public/app/plugins/datasource/loki/querybuilder/types.ts @@ -102,3 +102,16 @@ export enum LokiOperationOrder { RangeVectorFunction = 5, Last = 6, } + +export const lokiOperators = { + equals: { label: '=', value: '=', description: 'Equals', isMultiValue: false }, + doesNotEqual: { label: '!=', value: '!=', description: 'Does not equal', isMultiValue: false }, + matchesRegex: { label: '=~', value: '=~', description: 'Matches regex', isMultiValue: true }, + doesNotMatchRegex: { label: '!~', value: '!~', description: 'Does not match regex', isMultiValue: true }, + greaterThan: { label: '>', value: '>', description: 'Greater than', isMultiValue: false }, + greaterThanOrEqual: { label: '>=', value: '>=', description: 'Greater than or equal to', isMultiValue: false }, + lessThan: { label: '<', value: '<', description: 'Less than', isMultiValue: false }, + lessThanOrEqual: { label: '<=', value: '<=', description: 'Less than or equal to', isMultiValue: false }, + contains: { label: '|=', value: '|=', description: 'Contains', isMultiValue: false }, + doesNotContain: { label: '!=', value: '!=', description: 'Does not contain', isMultiValue: false }, +}; diff --git a/public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx b/public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx index c7c400273ec..093ff0c5c2c 100644 --- a/public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx +++ b/public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx @@ -5,6 +5,7 @@ import { SelectableValue, toOption } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; import { AccessoryButton, InputGroup } from '@grafana/experimental'; import { InlineField, Select } from '@grafana/ui'; +import { lokiOperators } from 'app/plugins/datasource/loki/querybuilder/types'; import { isConflictingSelector } from './operationUtils'; import { QueryBuilderLabelFilter } from './types'; @@ -160,8 +161,8 @@ export function LabelFilterItem({ } const operators = [ - { label: '=~', value: '=~', isMultiValue: true }, - { label: '=', value: '=', isMultiValue: false }, - { label: '!=', value: '!=', isMultiValue: false }, - { label: '!~', value: '!~', isMultiValue: true }, + lokiOperators.equals, + lokiOperators.doesNotEqual, + lokiOperators.matchesRegex, + lokiOperators.doesNotMatchRegex, ]; diff --git a/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationEditor.tsx b/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationEditor.tsx index eb68a3946d1..d17fa46b9ca 100644 --- a/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationEditor.tsx +++ b/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationEditor.tsx @@ -147,7 +147,7 @@ export function OperationEditor({
{ return { + cardWrapper: css({ + alignItems: 'stretch', + }), error: css({ marginBottom: theme.spacing(1), }), @@ -258,6 +261,7 @@ const getStyles = (theme: GrafanaTheme2) => { marginBottom: theme.spacing(1), position: 'relative', transition: 'all 0.5s ease-in 0s', + height: '100%', }), cardError: css({ boxShadow: `0px 0px 4px 0px ${theme.colors.warning.main}`, diff --git a/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationParamEditor.tsx b/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationParamEditor.tsx index 2e0941d5bfb..de069eb71ff 100644 --- a/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationParamEditor.tsx +++ b/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationParamEditor.tsx @@ -105,6 +105,7 @@ function SelectInputParamEditor({ placeholder={paramDef.placeholder} allowCustomValue={true} onChange={(value) => onChange(index, value.value!)} + width={paramDef.minWidth || 'auto'} /> {paramDef.optional && (