mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
GrafanaData: Deprecate the LogsParser type (#56242)
* added copy of code to main-grafana * grafana-data: add depreceted-notice
This commit is contained in:
parent
462ca50512
commit
3c1de8750c
@ -110,6 +110,7 @@ export enum LogsDedupStrategy {
|
||||
signature = 'signature',
|
||||
}
|
||||
|
||||
/** @deprecated will be removed in the next major version */
|
||||
export interface LogsParser {
|
||||
/**
|
||||
* Value-agnostic matcher for a field label.
|
||||
|
@ -7,7 +7,6 @@ import {
|
||||
LogLevel,
|
||||
LogRowModel,
|
||||
LogLabelStatsModel,
|
||||
LogsParser,
|
||||
LogsModel,
|
||||
LogsSortOrder,
|
||||
} from '@grafana/data';
|
||||
@ -76,6 +75,34 @@ export function addLogLevelToSeries(series: DataFrame, lineIndex: number): DataF
|
||||
};
|
||||
}
|
||||
|
||||
interface LogsParser {
|
||||
/**
|
||||
* Value-agnostic matcher for a field label.
|
||||
* Used to filter rows, and first capture group contains the value.
|
||||
*/
|
||||
buildMatcher: (label: string) => RegExp;
|
||||
|
||||
/**
|
||||
* Returns all parsable substrings from a line, used for highlighting
|
||||
*/
|
||||
getFields: (line: string) => string[];
|
||||
|
||||
/**
|
||||
* Gets the label name from a parsable substring of a line
|
||||
*/
|
||||
getLabelFromField: (field: string) => string;
|
||||
|
||||
/**
|
||||
* Gets the label value from a parsable substring of a line
|
||||
*/
|
||||
getValueFromField: (field: string) => string;
|
||||
/**
|
||||
* Function to verify if this is a valid parser for the given line.
|
||||
* The parser accepts the line if it returns true.
|
||||
*/
|
||||
test: (line: string) => boolean;
|
||||
}
|
||||
|
||||
export const LogsParsers: { [name: string]: LogsParser } = {
|
||||
JSON: {
|
||||
buildMatcher: (label) => new RegExp(`(?:{|,)\\s*"${label}"\\s*:\\s*"?([\\d\\.]+|[^"]*)"?`),
|
||||
|
Loading…
Reference in New Issue
Block a user