Explore/Loki: Remove regex parsing errors for huge logs (#26405)

* Remove hihglihting for logs with more than 5000 characters

* Update limitt, include also parsing for details

* Update
This commit is contained in:
Ivana Huckova 2020-08-04 14:37:07 +02:00 committed by GitHub
parent 6a86e66d76
commit 150778df1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import { selectThemeVariant } from '../../themes/selectThemeVariant';
//Components
import { LogDetailsRow } from './LogDetailsRow';
import { MAX_CHARACTERS } from './LogRowMessage';
type FieldDef = {
key: string;
@ -64,6 +65,9 @@ class UnThemedLogDetails extends PureComponent<Props> {
getParser = memoizeOne(getParser);
parseMessage = memoizeOne((rowEntry): FieldDef[] => {
if (rowEntry.length > MAX_CHARACTERS) {
return [];
}
const parser = this.getParser(rowEntry);
if (!parser) {
return [];

View File

@ -17,6 +17,8 @@ import { stylesFactory } from '../../themes/stylesFactory';
import { LogRowContext } from './LogRowContext';
import { LogMessageAnsi } from './LogMessageAnsi';
export const MAX_CHARACTERS = 100000;
interface Props extends Themeable {
row: LogRowModel;
hasMoreContextRows?: HasMoreContextRows;
@ -86,7 +88,8 @@ class UnThemedLogRowMessage extends PureComponent<Props> {
const previewHighlights = highlighterExpressions && !_.isEqual(highlighterExpressions, row.searchWords);
const highlights = previewHighlights ? highlighterExpressions : row.searchWords;
const needsHighlighter = highlights && highlights.length > 0 && highlights[0] && highlights[0].length > 0;
const needsHighlighter =
highlights && highlights.length > 0 && highlights[0] && highlights[0].length > 0 && entry.length < MAX_CHARACTERS;
const highlightClassName = previewHighlights
? cx([style.logsRowMatchHighLight, style.logsRowMatchHighLightPreview])
: cx([style.logsRowMatchHighLight]);

View File

@ -22,6 +22,7 @@ import store from 'app/core/store';
import { ExploreGraphPanel } from './ExploreGraphPanel';
import { MetaInfoText } from './MetaInfoText';
import { RowContextOptions } from '@grafana/ui/src/components/Logs/LogRowContextProvider';
import { MAX_CHARACTERS } from '@grafana/ui/src/components/Logs/LogRowMessage';
const SETTINGS_KEYS = {
showLabels: 'grafana.explore.logs.showLabels',
@ -181,6 +182,14 @@ export class Logs extends PureComponent<Props, State> {
});
}
if (logRows.some(r => r.entry.length > MAX_CHARACTERS)) {
meta.push({
label: 'Info',
value: 'Logs with more than 100,000 characters could not be parsed and highlighted',
kind: LogsMetaKind.String,
});
}
const scanText = scanRange ? `Scanning ${rangeUtil.describeTimeRange(scanRange)}` : 'Scanning...';
const series = logsSeries ? logsSeries : [];