GrafanaData: Deprecate the LogsParser type (#56242)

* added copy of code to main-grafana

* grafana-data: add depreceted-notice
This commit is contained in:
Gábor Farkas 2022-10-04 11:25:22 +02:00 committed by GitHub
parent 462ca50512
commit 3c1de8750c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -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.

View File

@ -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\\.]+|[^"]*)"?`),