mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
this is a fix-up PR that cleans up Explore Logging after the recent restructuring. - log results need to be merged since query transactions have been introduced - logging DS has its own language provider, query field, and start page (some of them based on prometheus components) - added loader animation to log viewer - removed logging logic from prometheus components
44 lines
861 B
TypeScript
44 lines
861 B
TypeScript
import _ from 'lodash';
|
|
|
|
export enum LogLevel {
|
|
crit = 'crit',
|
|
warn = 'warn',
|
|
err = 'error',
|
|
error = 'error',
|
|
info = 'info',
|
|
debug = 'debug',
|
|
trace = 'trace',
|
|
}
|
|
|
|
export interface LogSearchMatch {
|
|
start: number;
|
|
length: number;
|
|
text: string;
|
|
}
|
|
|
|
export interface LogRow {
|
|
key: string;
|
|
entry: string;
|
|
logLevel: LogLevel;
|
|
timestamp: string;
|
|
timeFromNow: string;
|
|
timeLocal: string;
|
|
searchWords?: string[];
|
|
}
|
|
|
|
export interface LogsModel {
|
|
rows: LogRow[];
|
|
}
|
|
|
|
export function mergeStreams(streams: LogsModel[], limit?: number): LogsModel {
|
|
const combinedEntries = streams.reduce((acc, stream) => {
|
|
return [...acc, ...stream.rows];
|
|
}, []);
|
|
const sortedEntries = _.chain(combinedEntries)
|
|
.sortBy('timestamp')
|
|
.reverse()
|
|
.slice(0, limit || combinedEntries.length)
|
|
.value();
|
|
return { rows: sortedEntries };
|
|
}
|