mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Explore/Logs: Clarify phrasing of newline escape fix tooltip Rewrite the tooltip for the smart feature in PR #31352 that replaces incorrectly escaped newlines in log lines. - Clarify the functionality of the feature to emphasize its interactivity. - Remove language suggesting that the feature is experimental, when we intended to suggest reviewing the results manually for correctness. * Docs: Document escape newlines feature Describe and provide steps for using the "Escape newlines" feature in Explore added in PR #31352. * Rewrite topic lead to clarify conditional behavior * Describe reversion of replacements as a standalone task Reverting the replacements is a separate action, so it should have its own task. This also describes the option's transformation and tightens the task language. * Remove Grafana 7 version qualifier * Clarify escape sequence detection lede on task Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> * Clarify "Remove escaping" state change Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> * Clarify confidence of tooltip content Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
117 lines
3.3 KiB
TypeScript
117 lines
3.3 KiB
TypeScript
import React from 'react';
|
|
import { LogsDedupStrategy, LogsMetaItem, LogsMetaKind, LogRowModel } from '@grafana/data';
|
|
import { Button, Tooltip, Icon, LogLabels } from '@grafana/ui';
|
|
import { MAX_CHARACTERS } from '@grafana/ui/src/components/Logs/LogRowMessage';
|
|
import { MetaInfoText, MetaItemProps } from './MetaInfoText';
|
|
|
|
export type Props = {
|
|
meta: LogsMetaItem[];
|
|
dedupStrategy: LogsDedupStrategy;
|
|
dedupCount: number;
|
|
showDetectedFields: string[];
|
|
hasUnescapedContent: boolean;
|
|
forceEscape: boolean;
|
|
logRows: LogRowModel[];
|
|
onEscapeNewlines: () => void;
|
|
clearDetectedFields: () => void;
|
|
};
|
|
|
|
export const LogsMetaRow: React.FC<Props> = React.memo(
|
|
({
|
|
meta,
|
|
dedupStrategy,
|
|
dedupCount,
|
|
showDetectedFields,
|
|
clearDetectedFields,
|
|
hasUnescapedContent,
|
|
forceEscape,
|
|
onEscapeNewlines,
|
|
logRows,
|
|
}) => {
|
|
const logsMetaItem: Array<LogsMetaItem | MetaItemProps> = [...meta];
|
|
|
|
// Add deduplication info
|
|
if (dedupStrategy !== LogsDedupStrategy.none) {
|
|
logsMetaItem.push({
|
|
label: 'Dedup count',
|
|
value: dedupCount,
|
|
kind: LogsMetaKind.Number,
|
|
});
|
|
}
|
|
// Add info about limit for highlighting
|
|
if (logRows.some((r) => r.entry.length > MAX_CHARACTERS)) {
|
|
logsMetaItem.push({
|
|
label: 'Info',
|
|
value: 'Logs with more than 100,000 characters could not be parsed and highlighted',
|
|
kind: LogsMetaKind.String,
|
|
});
|
|
}
|
|
|
|
// Add detected fields info
|
|
if (showDetectedFields?.length > 0) {
|
|
logsMetaItem.push(
|
|
{
|
|
label: 'Showing only detected fields',
|
|
value: renderMetaItem(showDetectedFields, LogsMetaKind.LabelsMap),
|
|
},
|
|
{
|
|
label: '',
|
|
value: (
|
|
<Button variant="secondary" size="sm" onClick={clearDetectedFields}>
|
|
Show all detected fields
|
|
</Button>
|
|
),
|
|
}
|
|
);
|
|
}
|
|
|
|
// Add unescaped content info
|
|
if (hasUnescapedContent) {
|
|
logsMetaItem.push({
|
|
label: 'Your logs might have incorrectly escaped content',
|
|
value: (
|
|
<Tooltip
|
|
content="Fix incorrectly escaped newline and tab sequences in log lines. Manually review the results to confirm that the replacements are correct."
|
|
placement="right"
|
|
>
|
|
<Button variant="secondary" size="sm" onClick={onEscapeNewlines}>
|
|
<span>{forceEscape ? 'Remove escaping' : 'Escape newlines'} </span>
|
|
<Icon name="exclamation-triangle" className="muted" size="sm" />
|
|
</Button>
|
|
</Tooltip>
|
|
),
|
|
});
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{logsMetaItem && (
|
|
<MetaInfoText
|
|
metaItems={logsMetaItem.map((item) => {
|
|
return {
|
|
label: item.label,
|
|
value: 'kind' in item ? renderMetaItem(item.value, item.kind) : item.value,
|
|
};
|
|
})}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
);
|
|
|
|
LogsMetaRow.displayName = 'LogsMetaRow';
|
|
|
|
function renderMetaItem(value: any, kind: LogsMetaKind) {
|
|
if (kind === LogsMetaKind.LabelsMap) {
|
|
return (
|
|
<span className="logs-meta-item__labels">
|
|
<LogLabels labels={value} />
|
|
</span>
|
|
);
|
|
} else if (kind === LogsMetaKind.Error) {
|
|
return <span className="logs-meta-item__error">{value}</span>;
|
|
}
|
|
return value;
|
|
}
|