Logs: Move components to dedicated directory (#65936)
* move log-context components to dedicated directory * fix any * add right format of lerna.json
This commit is contained in:
+1
-4
@@ -2948,15 +2948,12 @@ exports[`better eslint`] = {
|
|||||||
"public/app/features/live/index.ts:5381": [
|
"public/app/features/live/index.ts:5381": [
|
||||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||||
],
|
],
|
||||||
"public/app/features/logs/components/LogRowContextProvider.tsx:5381": [
|
"public/app/features/logs/components/log-context/LogRowContextProvider.tsx:5381": [
|
||||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||||
[0, 0, 0, "Do not use any type assertions.", "3"]
|
[0, 0, 0, "Do not use any type assertions.", "3"]
|
||||||
],
|
],
|
||||||
"public/app/features/logs/components/LogRows.tsx:5381": [
|
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
|
||||||
],
|
|
||||||
"public/app/features/logs/utils.ts:5381": [
|
"public/app/features/logs/utils.ts:5381": [
|
||||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ import { dedupLogRows, filterLogLevels } from 'app/core/logsModel';
|
|||||||
import store from 'app/core/store';
|
import store from 'app/core/store';
|
||||||
import { ExploreId } from 'app/types/explore';
|
import { ExploreId } from 'app/types/explore';
|
||||||
|
|
||||||
import { RowContextOptions } from '../logs/components/LogRowContextProvider';
|
|
||||||
import { LogRows } from '../logs/components/LogRows';
|
import { LogRows } from '../logs/components/LogRows';
|
||||||
|
import { RowContextOptions } from '../logs/components/log-context/types';
|
||||||
|
|
||||||
import { LogsMetaRow } from './LogsMetaRow';
|
import { LogsMetaRow } from './LogsMetaRow';
|
||||||
import LogsNavigation from './LogsNavigation';
|
import LogsNavigation from './LogsNavigation';
|
||||||
|
|||||||
@@ -20,16 +20,16 @@ import { checkLogsError, escapeUnescapedString } from '../utils';
|
|||||||
|
|
||||||
import { LogDetails } from './LogDetails';
|
import { LogDetails } from './LogDetails';
|
||||||
import { LogLabels } from './LogLabels';
|
import { LogLabels } from './LogLabels';
|
||||||
|
import { LogRowMessage } from './LogRowMessage';
|
||||||
|
import { LogRowMessageDisplayedFields } from './LogRowMessageDisplayedFields';
|
||||||
|
import { getLogLevelStyles, LogRowStyles } from './getLogRowStyles';
|
||||||
import {
|
import {
|
||||||
LogRowContextRows,
|
LogRowContextRows,
|
||||||
LogRowContextQueryErrors,
|
LogRowContextQueryErrors,
|
||||||
HasMoreContextRows,
|
HasMoreContextRows,
|
||||||
LogRowContextProvider,
|
LogRowContextProvider,
|
||||||
RowContextOptions,
|
} from './log-context/LogRowContextProvider';
|
||||||
} from './LogRowContextProvider';
|
import { RowContextOptions } from './log-context/types';
|
||||||
import { LogRowMessage } from './LogRowMessage';
|
|
||||||
import { LogRowMessageDisplayedFields } from './LogRowMessageDisplayedFields';
|
|
||||||
import { getLogLevelStyles, LogRowStyles } from './getLogRowStyles';
|
|
||||||
|
|
||||||
interface Props extends Themeable2 {
|
interface Props extends Themeable2 {
|
||||||
row: LogRowModel;
|
row: LogRowModel;
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import {
|
|||||||
import { IconButton, Tooltip } from '@grafana/ui';
|
import { IconButton, Tooltip } from '@grafana/ui';
|
||||||
|
|
||||||
import { LogMessageAnsi } from './LogMessageAnsi';
|
import { LogMessageAnsi } from './LogMessageAnsi';
|
||||||
import { LogRowContext } from './LogRowContext';
|
|
||||||
import { LogRowContextQueryErrors, HasMoreContextRows, LogRowContextRows } from './LogRowContextProvider';
|
|
||||||
import { LogRowStyles } from './getLogRowStyles';
|
import { LogRowStyles } from './getLogRowStyles';
|
||||||
|
import { LogRowContext } from './log-context/LogRowContext';
|
||||||
|
import { LogRowContextQueryErrors, HasMoreContextRows, LogRowContextRows } from './log-context/LogRowContextProvider';
|
||||||
|
|
||||||
export const MAX_CHARACTERS = 100000;
|
export const MAX_CHARACTERS = 100000;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
CoreApp,
|
CoreApp,
|
||||||
DataFrame,
|
DataFrame,
|
||||||
DataSourceWithLogsContextSupport,
|
DataSourceWithLogsContextSupport,
|
||||||
|
DataQueryResponse,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { withTheme2, Themeable2 } from '@grafana/ui';
|
import { withTheme2, Themeable2 } from '@grafana/ui';
|
||||||
|
|
||||||
@@ -18,8 +19,8 @@ import { sortLogRows } from '../utils';
|
|||||||
|
|
||||||
//Components
|
//Components
|
||||||
import { LogRow } from './LogRow';
|
import { LogRow } from './LogRow';
|
||||||
import { RowContextOptions } from './LogRowContextProvider';
|
|
||||||
import { getLogRowStyles } from './getLogRowStyles';
|
import { getLogRowStyles } from './getLogRowStyles';
|
||||||
|
import { RowContextOptions } from './log-context/types';
|
||||||
|
|
||||||
export const PREVIEW_LIMIT = 100;
|
export const PREVIEW_LIMIT = 100;
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ export interface Props extends Themeable2 {
|
|||||||
showContextToggle?: (row?: LogRowModel) => boolean;
|
showContextToggle?: (row?: LogRowModel) => boolean;
|
||||||
onClickFilterLabel?: (key: string, value: string) => void;
|
onClickFilterLabel?: (key: string, value: string) => void;
|
||||||
onClickFilterOutLabel?: (key: string, value: string) => void;
|
onClickFilterOutLabel?: (key: string, value: string) => void;
|
||||||
getRowContext?: (row: LogRowModel, options?: RowContextOptions) => Promise<any>;
|
getRowContext?: (row: LogRowModel, options?: RowContextOptions) => Promise<DataQueryResponse>;
|
||||||
getLogRowContextUi?: DataSourceWithLogsContextSupport['getLogRowContextUi'];
|
getLogRowContextUi?: DataSourceWithLogsContextSupport['getLogRowContextUi'];
|
||||||
getFieldLinks?: (field: Field, rowIndex: number, dataFrame: DataFrame) => Array<LinkModel<Field>>;
|
getFieldLinks?: (field: Field, rowIndex: number, dataFrame: DataFrame) => Array<LinkModel<Field>>;
|
||||||
onClickShowField?: (key: string) => void;
|
onClickShowField?: (key: string) => void;
|
||||||
@@ -148,7 +149,7 @@ class UnThemedLogRows extends PureComponent<Props, State> {
|
|||||||
|
|
||||||
// React profiler becomes unusable if we pass all rows to all rows and their labels, using getter instead
|
// React profiler becomes unusable if we pass all rows to all rows and their labels, using getter instead
|
||||||
const getRows = this.makeGetRows(orderedRows);
|
const getRows = this.makeGetRows(orderedRows);
|
||||||
const getRowContext = this.props.getRowContext ? this.props.getRowContext : () => Promise.resolve([]);
|
const getRowContext = this.props.getRowContext ? this.props.getRowContext : () => Promise.resolve({ data: [] });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table className={styles.logsRowsTable}>
|
<table className={styles.logsRowsTable}>
|
||||||
|
|||||||
+2
-1
@@ -22,7 +22,8 @@ import {
|
|||||||
useTheme2,
|
useTheme2,
|
||||||
} from '@grafana/ui';
|
} from '@grafana/ui';
|
||||||
|
|
||||||
import { LogMessageAnsi } from './LogMessageAnsi';
|
import { LogMessageAnsi } from '../LogMessageAnsi';
|
||||||
|
|
||||||
import { HasMoreContextRows, LogRowContextQueryErrors, LogRowContextRows } from './LogRowContextProvider';
|
import { HasMoreContextRows, LogRowContextQueryErrors, LogRowContextRows } from './LogRowContextProvider';
|
||||||
|
|
||||||
export enum LogGroupPosition {
|
export enum LogGroupPosition {
|
||||||
+4
-2
@@ -3,8 +3,10 @@ import React from 'react';
|
|||||||
|
|
||||||
import { FieldType, LogRowModel, MutableDataFrame, DataQueryResponse } from '@grafana/data';
|
import { FieldType, LogRowModel, MutableDataFrame, DataQueryResponse } from '@grafana/data';
|
||||||
|
|
||||||
import { getRowContexts, LogRowContextProvider, RowContextOptions } from './LogRowContextProvider';
|
import { createLogRow } from '../__mocks__/logRow';
|
||||||
import { createLogRow } from './__mocks__/logRow';
|
|
||||||
|
import { getRowContexts, LogRowContextProvider } from './LogRowContextProvider';
|
||||||
|
import { RowContextOptions } from './types';
|
||||||
|
|
||||||
const row = createLogRow({ entry: '4', timeEpochMs: 4 });
|
const row = createLogRow({ entry: '4', timeEpochMs: 4 });
|
||||||
|
|
||||||
+1
-4
@@ -12,10 +12,7 @@ import {
|
|||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { reportInteraction } from '@grafana/runtime';
|
import { reportInteraction } from '@grafana/runtime';
|
||||||
|
|
||||||
export interface RowContextOptions {
|
import { RowContextOptions } from './types';
|
||||||
direction?: 'BACKWARD' | 'FORWARD';
|
|
||||||
limit?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogRowContextRows {
|
export interface LogRowContextRows {
|
||||||
before?: string[];
|
before?: string[];
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export interface RowContextOptions {
|
||||||
|
direction?: 'BACKWARD' | 'FORWARD';
|
||||||
|
limit?: number;
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ import { DataSourceWithBackend } from '@grafana/runtime';
|
|||||||
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||||
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { RowContextOptions } from '../../../features/logs/components/LogRowContextProvider';
|
import { RowContextOptions } from '../../../features/logs/components/log-context/types';
|
||||||
|
|
||||||
import { CloudWatchAnnotationSupport } from './annotationSupport';
|
import { CloudWatchAnnotationSupport } from './annotationSupport';
|
||||||
import { DEFAULT_METRICS_QUERY, getDefaultLogsQuery } from './defaultQueries';
|
import { DEFAULT_METRICS_QUERY, getDefaultLogsQuery } from './defaultQueries';
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import { BackendDataSourceResponse, config, FetchError, FetchResponse, toDataQue
|
|||||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { RowContextOptions } from '../../../../features/logs/components/LogRowContextProvider';
|
import { RowContextOptions } from '../../../../features/logs/components/log-context/types';
|
||||||
import {
|
import {
|
||||||
CloudWatchJsonData,
|
CloudWatchJsonData,
|
||||||
CloudWatchLogsQuery,
|
CloudWatchLogsQuery,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import { queryLogsVolume } from 'app/core/logsModel';
|
|||||||
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||||
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { RowContextOptions } from '../../../features/logs/components/LogRowContextProvider';
|
import { RowContextOptions } from '../../../features/logs/components/log-context/types';
|
||||||
import { getLogLevelFromKey } from '../../../features/logs/utils';
|
import { getLogLevelFromKey } from '../../../features/logs/utils';
|
||||||
|
|
||||||
import { ElasticResponse } from './ElasticResponse';
|
import { ElasticResponse } from './ElasticResponse';
|
||||||
@@ -561,7 +561,7 @@ export class ElasticDatasource
|
|||||||
return { data: [] };
|
return { data: [] };
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The LogRowContextProvider requires there is a field in the dataFrame.fields
|
* The LogRowContext requires there is a field in the dataFrame.fields
|
||||||
* named `ts` for timestamp and `line` for the actual log line to display.
|
* named `ts` for timestamp and `line` for the actual log line to display.
|
||||||
* Unfortunatly these fields are hardcoded and are required for the lines to
|
* Unfortunatly these fields are hardcoded and are required for the lines to
|
||||||
* be properly displayed. This code just copies the fields based on this.timeField
|
* be properly displayed. This code just copies the fields based on this.timeField
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|||||||
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { serializeParams } from '../../../core/utils/fetch';
|
import { serializeParams } from '../../../core/utils/fetch';
|
||||||
import { RowContextOptions } from '../../../features/logs/components/LogRowContextProvider';
|
import { RowContextOptions } from '../../../features/logs/components/log-context/types';
|
||||||
import { getLogLevelFromKey } from '../../../features/logs/utils';
|
import { getLogLevelFromKey } from '../../../features/logs/utils';
|
||||||
import { renderLegendFormat } from '../prometheus/legend';
|
import { renderLegendFormat } from '../prometheus/legend';
|
||||||
import { replaceVariables, returnVariables } from '../prometheus/querybuilder/shared/parsingUtils';
|
import { replaceVariables, returnVariables } from '../prometheus/querybuilder/shared/parsingUtils';
|
||||||
|
|||||||
Reference in New Issue
Block a user