diff --git a/public/app/features/explore/Logs/LogsTable.test.tsx b/public/app/features/explore/Logs/LogsTable.test.tsx index 7eb047add6f..b22a2277395 100644 --- a/public/app/features/explore/Logs/LogsTable.test.tsx +++ b/public/app/features/explore/Logs/LogsTable.test.tsx @@ -164,7 +164,7 @@ describe('LogsTable', () => { }); }); - it('should not render `tsNs`', async () => { + it('should not render `tsNs` column', async () => { setup(undefined, getMockLokiFrame()); await waitFor(() => { @@ -174,6 +174,28 @@ describe('LogsTable', () => { }); }); + it('should render numeric field aligned right', async () => { + setup( + { + columnsWithMeta: { + Time: { active: true, percentOfLinesWithLabel: 100, index: 0 }, + line: { active: true, percentOfLinesWithLabel: 100, index: 1 }, + tsNs: { active: true, percentOfLinesWithLabel: 100, index: 2 }, + }, + }, + getMockLokiFrame() + ); + + await waitFor(() => { + const columns = screen.queryAllByRole('columnheader', { name: 'tsNs' }); + expect(columns.length).toBe(1); + }); + + const cells = screen.queryAllByRole('cell'); + + expect(cells[cells.length - 1].style.textAlign).toBe('right'); + }); + it('should not render `labels`', async () => { setup(); diff --git a/public/app/features/explore/Logs/LogsTable.tsx b/public/app/features/explore/Logs/LogsTable.tsx index 37ad7591032..23c78fed2bf 100644 --- a/public/app/features/explore/Logs/LogsTable.tsx +++ b/public/app/features/explore/Logs/LogsTable.tsx @@ -9,6 +9,7 @@ import { DataTransformerConfig, Field, FieldType, + guessFieldTypeForField, LogsSortOrder, sortDataFrame, SplitOpen, @@ -86,6 +87,9 @@ export function LogsTable(props: Props) { // This sets the individual field value as filterable filterable: isFieldFilterable(field, logsFrame?.bodyField.name ?? '', logsFrame?.timeField.name ?? ''), }; + + // If it's a string, then try to guess for a better type for numeric support in viz + field.type = field.type === FieldType.string ? guessFieldTypeForField(field) ?? FieldType.string : field.type; } return frameWithOverrides;