logs: send more info to getLogRowContext (#52130)

pull/52343/head
Gábor Farkas 3 years ago committed by GitHub
parent 57273d4846
commit 1d3cd0103e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/grafana-data/src/types/logs.ts
  2. 9
      public/app/features/explore/LogsContainer.tsx

@ -149,13 +149,14 @@ export enum LogsDedupDescription {
* Data sources that allow showing context rows around the provided LowRowModel should implement this method. * Data sources that allow showing context rows around the provided LowRowModel should implement this method.
* This will enable "context" button in Logs Panel. * This will enable "context" button in Logs Panel.
*/ */
export interface DataSourceWithLogsContextSupport { export interface DataSourceWithLogsContextSupport<TQuery extends DataQuery = DataQuery> {
/** /**
* Retrieve context for a given log row * Retrieve context for a given log row
*/ */
getLogRowContext: <TContextQueryOptions extends {}>( getLogRowContext: <TContextQueryOptions extends {}>(
row: LogRowModel, row: LogRowModel,
options?: TContextQueryOptions options?: TContextQueryOptions,
query?: TQuery
) => Promise<DataQueryResponse>; ) => Promise<DataQueryResponse>;
/** /**

@ -44,10 +44,15 @@ class LogsContainer extends PureComponent<LogsContainerProps> {
}; };
getLogRowContext = async (row: LogRowModel, options?: any): Promise<any> => { getLogRowContext = async (row: LogRowModel, options?: any): Promise<any> => {
const { datasourceInstance } = this.props; const { datasourceInstance, logsQueries } = this.props;
if (hasLogsContextSupport(datasourceInstance)) { if (hasLogsContextSupport(datasourceInstance)) {
return datasourceInstance.getLogRowContext(row, options); // we need to find the query, and we need to be very sure that
// it's a query from this datasource
const query = (logsQueries ?? []).find(
(q) => q.refId === row.dataFrame.refId && q.datasource != null && q.datasource.type === datasourceInstance.type
);
return datasourceInstance.getLogRowContext(row, options, query);
} }
return []; return [];

Loading…
Cancel
Save