Refactor: Move LogLevel and Labels utils to @grafana/ui (#16285)

* rename Tags to Labels in SeriesData

* move some logs stuff to grafana/ui

* add roundtrip tests
This commit is contained in:
Ryan McKinley
2019-03-29 01:41:37 -07:00
committed by Torkel Ödegaard
parent d0d5b38572
commit bfba47c6c4
16 changed files with 330 additions and 238 deletions

View File

@@ -1,30 +1,8 @@
import _ from 'lodash';
import { colors, TimeSeries } from '@grafana/ui';
import { colors, TimeSeries, Labels, LogLevel } from '@grafana/ui';
import { getThemeColor } from 'app/core/utils/colors';
/**
* Mapping of log level abbreviation to canonical log level.
* Supported levels are reduce to limit color variation.
*/
export enum LogLevel {
emerg = 'critical',
alert = 'critical',
crit = 'critical',
critical = 'critical',
warn = 'warning',
warning = 'warning',
err = 'error',
eror = 'error',
error = 'error',
info = 'info',
notice = 'info',
dbug = 'debug',
debug = 'debug',
trace = 'trace',
unknown = 'unknown',
}
export const LogLevelColor = {
[LogLevel.critical]: colors[7],
[LogLevel.warning]: colors[1],
@@ -46,7 +24,7 @@ export interface LogRowModel {
entry: string;
hasAnsi: boolean;
key: string; // timestamp + labels
labels: LogsStreamLabels;
labels: Labels;
logLevel: LogLevel;
raw: string;
searchWords?: string[];
@@ -54,7 +32,7 @@ export interface LogRowModel {
timeFromNow: string;
timeEpochMs: number;
timeLocal: string;
uniqueLabels?: LogsStreamLabels;
uniqueLabels?: Labels;
}
export interface LogLabelStatsModel {
@@ -72,7 +50,7 @@ export enum LogsMetaKind {
export interface LogsMetaItem {
label: string;
value: string | number | LogsStreamLabels;
value: string | number | Labels;
kind: LogsMetaKind;
}
@@ -88,8 +66,8 @@ export interface LogsStream {
labels: string;
entries: LogsStreamEntry[];
search?: string;
parsedLabels?: LogsStreamLabels;
uniqueLabels?: LogsStreamLabels;
parsedLabels?: Labels;
uniqueLabels?: Labels;
}
export interface LogsStreamEntry {
@@ -99,10 +77,6 @@ export interface LogsStreamEntry {
timestamp?: string;
}
export interface LogsStreamLabels {
[key: string]: string;
}
export enum LogsDedupDescription {
none = 'No de-duplication',
exact = 'De-duplication of successive lines that are identical, ignoring ISO datetimes.',