Commit 16c25102 by Ivana Huckova Committed by GitHub

LogsPanel: Add deduplication option for logs (#31019)

* WIP: Add dedup functionality to logs panel

* Simplify, clean up

* Change ordering of customizations based on how it is in Explore

* Update public/app/plugins/panel/logs/LogsPanel.tsx

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>

* Update public/app/plugins/panel/logs/LogsPanel.tsx

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>
parent 595a4795
import React from 'react';
import { LogRows, CustomScrollbar } from '@grafana/ui';
import { LogsDedupStrategy, PanelProps } from '@grafana/data';
import { PanelProps } from '@grafana/data';
import { Options } from './types';
import { dataFrameToLogsModel } from 'app/core/logs_model';
import { dataFrameToLogsModel, dedupLogRows } from 'app/core/logs_model';
interface LogsPanelProps extends PanelProps<Options> {}
export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
data,
timeZone,
options: { showLabels, showTime, wrapLogMessage, sortOrder },
width,
options: { showLabels, showTime, wrapLogMessage, sortOrder, dedupStrategy },
}) => {
if (!data) {
return (
......@@ -21,12 +20,15 @@ export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
}
const newResults = data ? dataFrameToLogsModel(data.series, data.request?.intervalMs, timeZone) : null;
const logRows = newResults?.rows || [];
const deduplicatedRows = dedupLogRows(logRows, dedupStrategy);
return (
<CustomScrollbar autoHide>
<LogRows
logRows={newResults?.rows || []}
dedupStrategy={LogsDedupStrategy.none}
logRows={logRows}
deduplicatedRows={deduplicatedRows}
dedupStrategy={dedupStrategy}
highlighterExpressions={[]}
showLabels={showLabels}
showTime={showTime}
......
import { PanelPlugin, LogsSortOrder } from '@grafana/data';
import { PanelPlugin, LogsSortOrder, LogsDedupStrategy, LogsDedupDescription } from '@grafana/data';
import { Options } from './types';
import { LogsPanel } from './LogsPanel';
......@@ -23,6 +23,32 @@ export const plugin = new PanelPlugin<Options>(LogsPanel).setPanelOptions((build
defaultValue: false,
})
.addRadio({
path: 'dedupStrategy',
name: 'Deduplication',
description: '',
settings: {
options: [
{ value: LogsDedupStrategy.none, label: 'None', description: LogsDedupDescription[LogsDedupStrategy.none] },
{
value: LogsDedupStrategy.exact,
label: 'Exact',
description: LogsDedupDescription[LogsDedupStrategy.exact],
},
{
value: LogsDedupStrategy.numbers,
label: 'Numbers',
description: LogsDedupDescription[LogsDedupStrategy.numbers],
},
{
value: LogsDedupStrategy.signature,
label: 'Signature',
description: LogsDedupDescription[LogsDedupStrategy.signature],
},
],
},
defaultValue: LogsDedupStrategy.none,
})
.addRadio({
path: 'sortOrder',
name: 'Order',
description: '',
......
import { LogsSortOrder } from '@grafana/data';
import { LogsSortOrder, LogsDedupStrategy } from '@grafana/data';
export interface Options {
showLabels: boolean;
showTime: boolean;
wrapLogMessage: boolean;
sortOrder: LogsSortOrder;
dedupStrategy: LogsDedupStrategy;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment