mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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 React from 'react';
|
||||||
import { LogRows, CustomScrollbar } from '@grafana/ui';
|
import { LogRows, CustomScrollbar } from '@grafana/ui';
|
||||||
import { LogsDedupStrategy, PanelProps } from '@grafana/data';
|
import { PanelProps } from '@grafana/data';
|
||||||
import { Options } from './types';
|
import { Options } from './types';
|
||||||
import { dataFrameToLogsModel } from 'app/core/logs_model';
|
import { dataFrameToLogsModel, dedupLogRows } from 'app/core/logs_model';
|
||||||
|
|
||||||
interface LogsPanelProps extends PanelProps<Options> {}
|
interface LogsPanelProps extends PanelProps<Options> {}
|
||||||
|
|
||||||
export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
|
export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
|
||||||
data,
|
data,
|
||||||
timeZone,
|
timeZone,
|
||||||
options: { showLabels, showTime, wrapLogMessage, sortOrder },
|
options: { showLabels, showTime, wrapLogMessage, sortOrder, dedupStrategy },
|
||||||
width,
|
|
||||||
}) => {
|
}) => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return (
|
return (
|
||||||
@ -21,12 +20,15 @@ export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newResults = data ? dataFrameToLogsModel(data.series, data.request?.intervalMs, timeZone) : null;
|
const newResults = data ? dataFrameToLogsModel(data.series, data.request?.intervalMs, timeZone) : null;
|
||||||
|
const logRows = newResults?.rows || [];
|
||||||
|
const deduplicatedRows = dedupLogRows(logRows, dedupStrategy);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CustomScrollbar autoHide>
|
<CustomScrollbar autoHide>
|
||||||
<LogRows
|
<LogRows
|
||||||
logRows={newResults?.rows || []}
|
logRows={logRows}
|
||||||
dedupStrategy={LogsDedupStrategy.none}
|
deduplicatedRows={deduplicatedRows}
|
||||||
|
dedupStrategy={dedupStrategy}
|
||||||
highlighterExpressions={[]}
|
highlighterExpressions={[]}
|
||||||
showLabels={showLabels}
|
showLabels={showLabels}
|
||||||
showTime={showTime}
|
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 { Options } from './types';
|
||||||
import { LogsPanel } from './LogsPanel';
|
import { LogsPanel } from './LogsPanel';
|
||||||
|
|
||||||
@ -22,6 +22,32 @@ export const plugin = new PanelPlugin<Options>(LogsPanel).setPanelOptions((build
|
|||||||
description: '',
|
description: '',
|
||||||
defaultValue: false,
|
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({
|
.addRadio({
|
||||||
path: 'sortOrder',
|
path: 'sortOrder',
|
||||||
name: 'Order',
|
name: 'Order',
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { LogsSortOrder } from '@grafana/data';
|
import { LogsSortOrder, LogsDedupStrategy } from '@grafana/data';
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
showLabels: boolean;
|
showLabels: boolean;
|
||||||
showTime: boolean;
|
showTime: boolean;
|
||||||
wrapLogMessage: boolean;
|
wrapLogMessage: boolean;
|
||||||
sortOrder: LogsSortOrder;
|
sortOrder: LogsSortOrder;
|
||||||
|
dedupStrategy: LogsDedupStrategy;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user