From 1d3cd0103ea7a7d9eab900aa6af86b6dadfd035c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Fri, 15 Jul 2022 16:02:43 +0200 Subject: [PATCH] logs: send more info to getLogRowContext (#52130) --- packages/grafana-data/src/types/logs.ts | 5 +++-- public/app/features/explore/LogsContainer.tsx | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/grafana-data/src/types/logs.ts b/packages/grafana-data/src/types/logs.ts index e79a8b25e3e..1af4caf3ee0 100644 --- a/packages/grafana-data/src/types/logs.ts +++ b/packages/grafana-data/src/types/logs.ts @@ -149,13 +149,14 @@ export enum LogsDedupDescription { * Data sources that allow showing context rows around the provided LowRowModel should implement this method. * This will enable "context" button in Logs Panel. */ -export interface DataSourceWithLogsContextSupport { +export interface DataSourceWithLogsContextSupport { /** * Retrieve context for a given log row */ getLogRowContext: ( row: LogRowModel, - options?: TContextQueryOptions + options?: TContextQueryOptions, + query?: TQuery ) => Promise; /** diff --git a/public/app/features/explore/LogsContainer.tsx b/public/app/features/explore/LogsContainer.tsx index be59ff37e36..7cb00b56c4d 100644 --- a/public/app/features/explore/LogsContainer.tsx +++ b/public/app/features/explore/LogsContainer.tsx @@ -44,10 +44,15 @@ class LogsContainer extends PureComponent { }; getLogRowContext = async (row: LogRowModel, options?: any): Promise => { - const { datasourceInstance } = this.props; + const { datasourceInstance, logsQueries } = this.props; 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 [];