Logs Panel: Add milliseconds to download file (#75045)

* add milliseconds to log panel txt file download
This commit is contained in:
Galen Kistler 2023-09-26 07:14:40 -05:00 committed by GitHub
parent 354c1e992e
commit af3ea54d0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 12 deletions

View File

@ -1,14 +1,6 @@
import saveAs from 'file-saver'; import saveAs from 'file-saver';
import { import { dataFrameFromJSON, DataFrameJSON, dateTimeFormat, FieldType, LogRowModel, LogsMetaKind } from '@grafana/data';
dataFrameFromJSON,
DataFrameJSON,
dateTimeFormat,
dateTimeFormatISO,
FieldType,
LogRowModel,
LogsMetaKind,
} from '@grafana/data';
import { downloadAsJson, downloadDataFrameAsCsv, downloadLogsModelAsTxt } from './download'; import { downloadAsJson, downloadDataFrameAsCsv, downloadLogsModelAsTxt } from './download';
@ -98,7 +90,7 @@ describe('inspector download', () => {
rows: [{ timeEpochMs: 100, entry: 'testEntry' } as unknown as LogRowModel], rows: [{ timeEpochMs: 100, entry: 'testEntry' } as unknown as LogRowModel],
}, },
'test', 'test',
`testLabel: 1\nsecondTestLabel: 2\n\n\n${dateTimeFormatISO(100)}\ttestEntry\n`, `testLabel: 1\nsecondTestLabel: 2\n\n\n${dateTimeFormat(100, { defaultWithMS: true })}\ttestEntry\n`,
], ],
])('should, when logsModel is %s and title is %s, resolve in %s', async (logsModel, title, expected) => { ])('should, when logsModel is %s and title is %s, resolve in %s', async (logsModel, title, expected) => {
downloadLogsModelAsTxt(logsModel, title); downloadLogsModelAsTxt(logsModel, title);

View File

@ -5,7 +5,6 @@ import {
DataFrame, DataFrame,
DataTransformerID, DataTransformerID,
dateTimeFormat, dateTimeFormat,
dateTimeFormatISO,
LogsModel, LogsModel,
MutableDataFrame, MutableDataFrame,
toCSV, toCSV,
@ -31,7 +30,7 @@ export function downloadLogsModelAsTxt(logsModel: Pick<LogsModel, 'meta' | 'rows
textToDownload = textToDownload + '\n\n'; textToDownload = textToDownload + '\n\n';
logsModel.rows.forEach((row) => { logsModel.rows.forEach((row) => {
const newRow = dateTimeFormatISO(row.timeEpochMs) + '\t' + row.entry + '\n'; const newRow = dateTimeFormat(row.timeEpochMs, { defaultWithMS: true }) + '\t' + row.entry + '\n';
textToDownload = textToDownload + newRow; textToDownload = textToDownload + newRow;
}); });