mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Add support for distinct operation in autocomplete and query builder (#69003)
* Loki Autocomplete: add support for suggesting distinct * Loki query builder: add distinct as format operation * Remove unused import * Loki visual query: add support to parse distinct filters * Query builder: use label param editor for distinct * Loki Autocomplete: Improve distinct label suggestions * Query Builder: improve distinct parsing * Fix tests * Update tests
This commit is contained in:
@@ -716,6 +716,36 @@ describe('buildVisualQueryFromString', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('parses a log query with distinct and no labels', () => {
|
||||
expect(buildVisualQueryFromString('{app="frontend"} | distinct')).toEqual(
|
||||
noErrors({
|
||||
labels: [
|
||||
{
|
||||
op: '=',
|
||||
value: 'frontend',
|
||||
label: 'app',
|
||||
},
|
||||
],
|
||||
operations: [{ id: LokiOperationId.Distinct, params: [] }],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('parses a log query with distinct and labels', () => {
|
||||
expect(buildVisualQueryFromString('{app="frontend"} | distinct id, email')).toEqual(
|
||||
noErrors({
|
||||
labels: [
|
||||
{
|
||||
op: '=',
|
||||
value: 'frontend',
|
||||
label: 'app',
|
||||
},
|
||||
],
|
||||
operations: [{ id: LokiOperationId.Distinct, params: ['id', 'email'] }],
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function noErrors(query: LokiVisualQuery) {
|
||||
|
||||
Reference in New Issue
Block a user