mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Show error when parsing nodes not supported in visual query builder (#47321)
* Show error when parsing nodes not supported in visual query builder * Refactor, simplify * Spell fix * Spell fix
This commit is contained in:
@@ -67,6 +67,18 @@ describe('buildVisualQueryFromString', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('returns error for query with ip matching line filter', () => {
|
||||
const context = buildVisualQueryFromString('{app="frontend"} |= ip("192.168.4.5/16")');
|
||||
expect(context.errors).toEqual([
|
||||
{
|
||||
text: 'Matching ip addresses not supported in query builder: |= ip("192.168.4.5/16")',
|
||||
from: 17,
|
||||
to: 40,
|
||||
parentType: 'LineFilters',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('parses query with matcher label filter', () => {
|
||||
expect(buildVisualQueryFromString('{app="frontend"} | bar="baz"')).toEqual(
|
||||
noErrors({
|
||||
@@ -127,6 +139,30 @@ describe('buildVisualQueryFromString', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('returns error for query with "and", "or", "comma" in label filter', () => {
|
||||
const context = buildVisualQueryFromString('{app="frontend"} | logfmt | level="error" and job="grafana"');
|
||||
expect(context.errors).toEqual([
|
||||
{
|
||||
text: 'Label filter with comma, "and", "or" not supported in query builder: level="error" and job="grafana"',
|
||||
from: 28,
|
||||
to: 59,
|
||||
parentType: 'PipelineStage',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns error for query with ip label filter', () => {
|
||||
const context = buildVisualQueryFromString('{app="frontend"} | logfmt | address=ip("192.168.4.5/16")');
|
||||
expect(context.errors).toEqual([
|
||||
{
|
||||
text: 'IpLabelFilter not supported in query builder: address=ip("192.168.4.5/16")',
|
||||
from: 28,
|
||||
to: 56,
|
||||
parentType: 'PipelineStage',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('parses query with with parser', () => {
|
||||
expect(buildVisualQueryFromString('{app="frontend"} | json')).toEqual(
|
||||
noErrors({
|
||||
@@ -142,6 +178,18 @@ describe('buildVisualQueryFromString', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('returns error for query with JSON expression parser', () => {
|
||||
const context = buildVisualQueryFromString('{app="frontend"} | json label="value" ');
|
||||
expect(context.errors).toEqual([
|
||||
{
|
||||
text: 'JsonExpressionParser not supported in visual query builder: json label="value"',
|
||||
from: 19,
|
||||
to: 37,
|
||||
parentType: 'PipelineStage',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('parses query with with simple unwrap', () => {
|
||||
expect(
|
||||
buildVisualQueryFromString('sum_over_time({app="frontend"} | logfmt | unwrap bytes_processed [1m])')
|
||||
@@ -163,6 +211,20 @@ describe('buildVisualQueryFromString', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('returns error for query with unwrap and conversion operation', () => {
|
||||
const context = buildVisualQueryFromString(
|
||||
'sum_over_time({app="frontend"} | logfmt | unwrap duration(label) [5m])'
|
||||
);
|
||||
expect(context.errors).toEqual([
|
||||
{
|
||||
text: 'Unwrap with conversion operator not supported in query builder: | unwrap duration(label)',
|
||||
from: 40,
|
||||
to: 64,
|
||||
parentType: 'LogRangeExpr',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('parses metrics query with function', () => {
|
||||
expect(buildVisualQueryFromString('rate({app="frontend"} | json [5m])')).toEqual(
|
||||
noErrors({
|
||||
@@ -323,7 +385,7 @@ describe('buildVisualQueryFromString', () => {
|
||||
label: 'app',
|
||||
},
|
||||
],
|
||||
operations: [{ id: 'label_format', params: ['newLabel', '=', 'oldLabel'] }],
|
||||
operations: [{ id: 'label_format', params: ['newLabel', 'oldLabel'] }],
|
||||
})
|
||||
);
|
||||
});
|
||||
@@ -339,8 +401,8 @@ describe('buildVisualQueryFromString', () => {
|
||||
},
|
||||
],
|
||||
operations: [
|
||||
{ id: 'label_format', params: ['newLabel', '=', 'oldLabel'] },
|
||||
{ id: 'label_format', params: ['bar', '=', 'baz'] },
|
||||
{ id: 'label_format', params: ['newLabel', 'oldLabel'] },
|
||||
{ id: 'label_format', params: ['bar', 'baz'] },
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user