mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
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>
This commit is contained in:
parent
595a47959b
commit
16c25102bc
@ -1,16 +1,15 @@
|
||||
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}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { PanelPlugin, LogsSortOrder } from '@grafana/data';
|
||||
import { PanelPlugin, LogsSortOrder, LogsDedupStrategy, LogsDedupDescription } from '@grafana/data';
|
||||
import { Options } from './types';
|
||||
import { LogsPanel } from './LogsPanel';
|
||||
|
||||
@ -22,6 +22,32 @@ export const plugin = new PanelPlugin<Options>(LogsPanel).setPanelOptions((build
|
||||
description: '',
|
||||
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',
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { LogsSortOrder } from '@grafana/data';
|
||||
import { LogsSortOrder, LogsDedupStrategy } from '@grafana/data';
|
||||
|
||||
export interface Options {
|
||||
showLabels: boolean;
|
||||
showTime: boolean;
|
||||
wrapLogMessage: boolean;
|
||||
sortOrder: LogsSortOrder;
|
||||
dedupStrategy: LogsDedupStrategy;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user