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:
@@ -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\\.]+|[^"]*)"?`),
|
||||
|
||||
Reference in New Issue
Block a user