Commit e694604b by David Kaltschmidt

Loki: fix timestamp field

- timestamp was renamed to `ts` in grafana/loki#152
- renamed here in result transformer and tests
parent b2401e37
...@@ -81,7 +81,7 @@ export interface LogsStream { ...@@ -81,7 +81,7 @@ export interface LogsStream {
export interface LogsStreamEntry { export interface LogsStreamEntry {
line: string; line: string;
timestamp: string; ts: string;
} }
export interface LogsStreamLabels { export interface LogsStreamLabels {
......
...@@ -99,7 +99,7 @@ describe('mergeStreamsToLogs()', () => { ...@@ -99,7 +99,7 @@ describe('mergeStreamsToLogs()', () => {
entries: [ entries: [
{ {
line: 'WARN boooo', line: 'WARN boooo',
timestamp: '1970-01-01T00:00:00Z', ts: '1970-01-01T00:00:00Z',
}, },
], ],
}; };
...@@ -120,7 +120,7 @@ describe('mergeStreamsToLogs()', () => { ...@@ -120,7 +120,7 @@ describe('mergeStreamsToLogs()', () => {
entries: [ entries: [
{ {
line: 'WARN boooo', line: 'WARN boooo',
timestamp: '1970-01-01T00:00:01Z', ts: '1970-01-01T00:00:01Z',
}, },
], ],
}; };
...@@ -129,11 +129,11 @@ describe('mergeStreamsToLogs()', () => { ...@@ -129,11 +129,11 @@ describe('mergeStreamsToLogs()', () => {
entries: [ entries: [
{ {
line: 'INFO 1', line: 'INFO 1',
timestamp: '1970-01-01T00:00:00Z', ts: '1970-01-01T00:00:00Z',
}, },
{ {
line: 'INFO 2', line: 'INFO 2',
timestamp: '1970-01-01T00:00:02Z', ts: '1970-01-01T00:00:02Z',
}, },
], ],
}; };
......
...@@ -116,10 +116,10 @@ export function processEntry( ...@@ -116,10 +116,10 @@ export function processEntry(
uniqueLabels: LogsStreamLabels, uniqueLabels: LogsStreamLabels,
search: string search: string
): LogRow { ): LogRow {
const { line, timestamp } = entry; const { line, ts } = entry;
// Assumes unique-ness, needs nanosec precision for timestamp // Assumes unique-ness, needs nanosec precision for timestamp
const key = `EK${timestamp}${labels}`; const key = `EK${ts}${labels}`;
const time = moment(timestamp); const time = moment(ts);
const timeEpochMs = time.valueOf(); const timeEpochMs = time.valueOf();
const timeFromNow = time.fromNow(); const timeFromNow = time.fromNow();
const timeLocal = time.format('YYYY-MM-DD HH:mm:ss'); const timeLocal = time.format('YYYY-MM-DD HH:mm:ss');
...@@ -135,7 +135,7 @@ export function processEntry( ...@@ -135,7 +135,7 @@ export function processEntry(
entry: line, entry: line,
labels: parsedLabels, labels: parsedLabels,
searchWords: search ? [search] : [], searchWords: search ? [search] : [],
timestamp: timestamp, timestamp: ts,
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment