mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #14636 from grafana/davkal/fix-14635
Loki: fix timestamp field
This commit is contained in:
commit
b05e7aaecb
@ -81,7 +81,9 @@ export interface LogsStream {
|
||||
|
||||
export interface LogsStreamEntry {
|
||||
line: string;
|
||||
timestamp: string;
|
||||
ts: string;
|
||||
// Legacy, was renamed to ts
|
||||
timestamp?: string;
|
||||
}
|
||||
|
||||
export interface LogsStreamLabels {
|
||||
|
@ -99,7 +99,7 @@ describe('mergeStreamsToLogs()', () => {
|
||||
entries: [
|
||||
{
|
||||
line: 'WARN boooo',
|
||||
timestamp: '1970-01-01T00:00:00Z',
|
||||
ts: '1970-01-01T00:00:00Z',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -120,7 +120,7 @@ describe('mergeStreamsToLogs()', () => {
|
||||
entries: [
|
||||
{
|
||||
line: 'WARN boooo',
|
||||
timestamp: '1970-01-01T00:00:01Z',
|
||||
ts: '1970-01-01T00:00:01Z',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -129,11 +129,11 @@ describe('mergeStreamsToLogs()', () => {
|
||||
entries: [
|
||||
{
|
||||
line: 'INFO 1',
|
||||
timestamp: '1970-01-01T00:00:00Z',
|
||||
ts: '1970-01-01T00:00:00Z',
|
||||
},
|
||||
{
|
||||
line: 'INFO 2',
|
||||
timestamp: '1970-01-01T00:00:02Z',
|
||||
ts: '1970-01-01T00:00:02Z',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
@ -116,10 +116,11 @@ export function processEntry(
|
||||
uniqueLabels: LogsStreamLabels,
|
||||
search: string
|
||||
): LogRow {
|
||||
const { line, timestamp } = entry;
|
||||
const { line } = entry;
|
||||
const ts = entry.ts || entry.timestamp;
|
||||
// Assumes unique-ness, needs nanosec precision for timestamp
|
||||
const key = `EK${timestamp}${labels}`;
|
||||
const time = moment(timestamp);
|
||||
const key = `EK${ts}${labels}`;
|
||||
const time = moment(ts);
|
||||
const timeEpochMs = time.valueOf();
|
||||
const timeFromNow = time.fromNow();
|
||||
const timeLocal = time.format('YYYY-MM-DD HH:mm:ss');
|
||||
@ -135,7 +136,7 @@ export function processEntry(
|
||||
entry: line,
|
||||
labels: parsedLabels,
|
||||
searchWords: search ? [search] : [],
|
||||
timestamp: timestamp,
|
||||
timestamp: ts,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user