signoz/frontend/src/constants/antlrQueryConstants.ts

146 lines
4.1 KiB
TypeScript
Raw Normal View History

/* eslint-disable @typescript-eslint/naming-convention */
2025-07-31 12:16:55 +05:30
export const OPERATORS = {
IN: 'IN',
LIKE: 'LIKE',
ILIKE: 'ILIKE',
REGEXP: 'REGEXP',
EXISTS: 'EXISTS',
CONTAINS: 'CONTAINS',
BETWEEN: 'BETWEEN',
NOT: 'NOT',
'=': '=',
'!=': '!=',
'>=': '>=',
'>': '>',
'<=': '<=',
'<': '<',
};
Feature/trace operators (#8869) * feat: added traceoperator component and styles * chore: minor style improvments * feat: added conditions for traceoperator * chore: minor UI fixes * chore: type changes * chore: added initialvalue for trace operators * chore: Added changes to prepare request payload * chore: fixed minor styles + minor ux fix * feat: added span selector * chore: added ui changes in the editor * chore: removed traceoperations and reused queryoperations * chore: minor changes in queryaddon and aggregation for support * chore: added traceoperators in alerts * chore: minor pr review change * chore: linter fix * fix: fixed minor ts issues * fix: added limit support in traceoperator * chore: minor fix in traceoperator styles * chore: linting fix + icon changes * chore: updated type * chore: lint fixes * feat: added changes for showing querynames in alerts * feat: added trace operator grammer + antlr files * feat: added traceoperator context util * chore: added traceoperator validation function * feat: added traceoperator editor * feat: added queryname boost + operator constants * fix: pr reviews * chore: minor ui fix * fix: updated grammer files * test: added test for traceoperatorcontext * chore: removed check for multiple queries in traceexplorer * test: minor test fix * test: fixed breaking mapQueryDataFromApi test * chore: fixed logic to show trace operator * chore: updated docs link * chore: minor ui issue fix * chore: changed trace operator query name * chore: removed using spans from in trace opeartors * fix: added fix for order by in trace opeartor * feat: added changes related to saved in views in trace opeartor * chore: added changes to keep indirect descendent operator at bottom * chore: removed returnspansfrom field from traceoperator * chore: updated file names + regenerated grammer * chore: added beta tag in trace opeartor * chore: pr review fixes * Fix/tsc trace operator + tests (#8942) * fix: added tsc fixes for trace operator * chore: moved traceoperator utils * test: added test for traceopertor util * chore: tsc fix * fix: fixed tsc issue * Feat/trace operator dashboards (#8992) * chore: added callout message for multiple queries without trace operators * feat: added changes for supporting trace operators in dashboards * chore: minor changes for list panel
2025-09-05 21:30:24 +05:30
export const TRACE_OPERATOR_OPERATORS = {
AND: '&&',
OR: '||',
NOT: 'NOT',
DIRECT_DESCENDENT: '=>',
INDIRECT_DESCENDENT: '->',
};
export const TRACE_OPERATOR_OPERATORS_WITH_PRIORITY = {
[TRACE_OPERATOR_OPERATORS.DIRECT_DESCENDENT]: 1,
[TRACE_OPERATOR_OPERATORS.AND]: 2,
[TRACE_OPERATOR_OPERATORS.OR]: 3,
[TRACE_OPERATOR_OPERATORS.NOT]: 4,
[TRACE_OPERATOR_OPERATORS.INDIRECT_DESCENDENT]: 5,
};
export const TRACE_OPERATOR_OPERATORS_LABELS = {
[TRACE_OPERATOR_OPERATORS.DIRECT_DESCENDENT]: 'Direct Descendant',
[TRACE_OPERATOR_OPERATORS.INDIRECT_DESCENDENT]: 'Indirect Descendant',
};
fixes: includes fixes required in the new QB (#8675) * fix: removed unused code for querycontext (#8674) * Update frontend/src/utils/queryValidationUtils.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * feat: added tooltips in metric aggregations * feat: enabled legend enhancement for explorer pages and alert page * feat: updated the error state in explorer pages with new APIError * fix: cloned panel query shows previous query (#8681) * fix: cloned panel query shows previous query * chore: removed comments * chore: added null check * fix: added fix for auto run query in dashboard panel + trace view issue --------- Co-authored-by: Abhi Kumar <abhikumar@Mac.lan> * feat: added new SubstituteVars api and enable v5 for creating new alerts (#8683) * feat: added new SubstituteVars api and enable v5 for creating new alerts * feat: add warning notification for query response * feat: fixed failing test case * fix: metric histogram UI config state in edit mode * fix: fixed table columns getting duplicate data (#8685) * fix: added fix for conversion of QB function to filter expression. (#8684) * fix: added fix for QB filters for functions * chore: minor fix --------- Co-authored-by: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com> * feat: query builder fixes and enhancement (#8692) * feat: legend format fixes around single and multiple aggregation * feat: fixed table unit and metric units * feat: add fallbacks to columnWidth and columnUnits for old-dashboards * feat: fixed metric edit issue and having filter suggestion duplications * feat: fix and cleanup functions across product for v5 * chore: add tooltips with links to documentation (#8676) * fix: added fix for query validation and empty query error (#8694) * fix: added fix for selected columns being empty in logs explorer (#8709) * feat: added columnUnit changes for old dashboard migrations (#8706) * fix: fixed keyfetching logic (#8712) * chore: lint fix * fix: fixed logs explorer test * feat: fix type checks --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: SagarRajput-7 <sagar@signoz.io> Co-authored-by: Abhi Kumar <abhikumar@Mac.lan> Co-authored-by: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com> Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
2025-08-06 00:16:20 +05:30
export const QUERY_BUILDER_FUNCTIONS = {
HAS: 'has',
HASANY: 'hasAny',
HASALL: 'hasAll',
};
export function negateOperator(operatorOrFunction: string): string {
// Special cases for equals/not equals
if (operatorOrFunction === OPERATORS['=']) {
return OPERATORS['!='];
}
if (operatorOrFunction === OPERATORS['!=']) {
return OPERATORS['='];
}
// For all other operators and functions, add NOT in front
return `${OPERATORS.NOT} ${operatorOrFunction}`;
}
export enum DEPRECATED_OPERATORS {
REGEX = 'regex',
NIN = 'nin',
NREGEX = 'nregex',
NLIKE = 'nlike',
NILIKE = 'nilike',
NEXTISTS = 'nexists',
NCONTAINS = 'ncontains',
NHAS = 'nhas',
NHASANY = 'nhasany',
NHASALL = 'nhasall',
}
export const DEPRECATED_OPERATORS_MAP = {
[DEPRECATED_OPERATORS.REGEX]: OPERATORS.REGEXP,
[DEPRECATED_OPERATORS.NIN]: negateOperator(OPERATORS.IN),
[DEPRECATED_OPERATORS.NREGEX]: negateOperator(OPERATORS.REGEXP),
[DEPRECATED_OPERATORS.NLIKE]: negateOperator(OPERATORS.LIKE),
[DEPRECATED_OPERATORS.NILIKE]: negateOperator(OPERATORS.ILIKE),
[DEPRECATED_OPERATORS.NEXTISTS]: negateOperator(OPERATORS.EXISTS),
[DEPRECATED_OPERATORS.NCONTAINS]: negateOperator(OPERATORS.CONTAINS),
[DEPRECATED_OPERATORS.NHAS]: negateOperator(QUERY_BUILDER_FUNCTIONS.HAS),
[DEPRECATED_OPERATORS.NHASANY]: negateOperator(QUERY_BUILDER_FUNCTIONS.HASANY),
[DEPRECATED_OPERATORS.NHASALL]: negateOperator(QUERY_BUILDER_FUNCTIONS.HASALL),
};
2025-07-31 12:16:55 +05:30
export const NON_VALUE_OPERATORS = [OPERATORS.EXISTS];
// eslint-disable-next-line @typescript-eslint/naming-convention
export enum QUERY_BUILDER_KEY_TYPES {
STRING = 'string',
NUMBER = 'number',
BOOLEAN = 'boolean',
}
export const QUERY_BUILDER_OPERATORS_BY_KEY_TYPE = {
[QUERY_BUILDER_KEY_TYPES.STRING]: [
OPERATORS['='],
OPERATORS['!='],
OPERATORS.IN,
OPERATORS.LIKE,
OPERATORS.ILIKE,
OPERATORS.CONTAINS,
OPERATORS.EXISTS,
OPERATORS.REGEXP,
OPERATORS.NOT,
],
[QUERY_BUILDER_KEY_TYPES.NUMBER]: [
OPERATORS['='],
OPERATORS['!='],
OPERATORS['>='],
OPERATORS['>'],
OPERATORS['<='],
OPERATORS['<'],
OPERATORS.IN,
OPERATORS.EXISTS,
OPERATORS.BETWEEN,
OPERATORS.NOT,
],
[QUERY_BUILDER_KEY_TYPES.BOOLEAN]: [
OPERATORS['='],
OPERATORS['!='],
OPERATORS.EXISTS,
OPERATORS.NOT,
],
};
export const negationQueryOperatorSuggestions = [
{ label: OPERATORS.LIKE, type: 'operator', info: 'Like' },
{ label: OPERATORS.ILIKE, type: 'operator', info: 'Case insensitive like' },
{ label: OPERATORS.EXISTS, type: 'operator', info: 'Exists' },
{ label: OPERATORS.BETWEEN, type: 'operator', info: 'Between' },
{ label: OPERATORS.IN, type: 'operator', info: 'In' },
{ label: OPERATORS.REGEXP, type: 'operator', info: 'Regular expression' },
{ label: OPERATORS.CONTAINS, type: 'operator', info: 'Contains' },
];
export const queryOperatorSuggestions = [
{ label: OPERATORS['='], type: 'operator', info: 'Equal to' },
{ label: OPERATORS['!='], type: 'operator', info: 'Not equal to' },
{ label: OPERATORS['>'], type: 'operator', info: 'Greater than' },
{ label: OPERATORS['<'], type: 'operator', info: 'Less than' },
{ label: OPERATORS['>='], type: 'operator', info: 'Greater than or equal to' },
{ label: OPERATORS['<='], type: 'operator', info: 'Less than or equal to' },
{ label: OPERATORS.NOT, type: 'operator', info: 'Not' },
...negationQueryOperatorSuggestions,
];