loki: backend-mode: add "limit" dataframe meta attribute (#48894)

This commit is contained in:
Gábor Farkas 2022-05-12 08:56:09 +02:00 committed by GitHub
parent a1217ef8da
commit 44e7602ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -91,6 +91,37 @@ describe('loki backendResultTransformer', () => {
expect(result).toEqual(expected); expect(result).toEqual(expected);
}); });
it('applies maxLines correctly', () => {
const response: DataQueryResponse = { data: [cloneDeep(inputFrame)] };
const frame1: DataFrame = transformBackendResult(
response,
[
{
refId: 'A',
expr: LOKI_EXPR,
},
],
[]
).data[0];
expect(frame1.meta?.limit).toBeUndefined();
const frame2 = transformBackendResult(
response,
[
{
refId: 'A',
expr: LOKI_EXPR,
maxLines: 42,
},
],
[]
).data[0];
expect(frame2.meta?.limit).toBe(42);
});
it('processed derived fields correctly', () => { it('processed derived fields correctly', () => {
const input: DataFrame = { const input: DataFrame = {
length: 1, length: 1,

View File

@ -27,6 +27,7 @@ function processStreamFrame(
): DataFrame { ): DataFrame {
const meta: QueryResultMeta = { const meta: QueryResultMeta = {
preferredVisualisationType: 'logs', preferredVisualisationType: 'logs',
limit: query?.maxLines,
searchWords: query !== undefined ? getHighlighterExpressionsFromQuery(formatQuery(query.expr)) : undefined, searchWords: query !== undefined ? getHighlighterExpressionsFromQuery(formatQuery(query.expr)) : undefined,
custom: { custom: {
// used by logs_model // used by logs_model