From c39bc2cbddb74e2cb0adcebc38bd38d2098cd2ec Mon Sep 17 00:00:00 2001 From: Abhay Padamani <141122205+ktx-abhay@users.noreply.github.com> Date: Fri, 19 Dec 2025 18:46:23 +0530 Subject: [PATCH] fix: promql query legend config suggestion issue for dashboard (#9691) ### **PR Type** Enhancement ___ ### **Description** - Dynamic PromQL field suggestions from groupedFields schema - Added `watch` import for additional reactivity ___

File Walkthrough

Relevant files
Enhancement
ConfigPanel.vue
Refactor PromQL suggestion logic                                                 

web/src/components/dashboards/addPanel/ConfigPanel.vue
  • Imported watch alongside markRaw and watchEffect
  • Removed static meta.stream.selectedStreamFields mapping
  • Computed dashboardSelectfieldPromQlList from groupedFields.schema
  • Added null checks for current stream and schema
+26/-11 
___ --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- .../dashboards/addPanel/ConfigPanel.vue | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/web/src/components/dashboards/addPanel/ConfigPanel.vue b/web/src/components/dashboards/addPanel/ConfigPanel.vue index 20a788868e..6145f6dc84 100644 --- a/web/src/components/dashboards/addPanel/ConfigPanel.vue +++ b/web/src/components/dashboards/addPanel/ConfigPanel.vue @@ -2180,16 +2180,31 @@ export default defineComponent({ } }; - const dashboardSelectfieldPromQlList = computed(() => - props.dashboardPanelData.meta.stream.selectedStreamFields.map( - (it: any) => { - return { - label: it.name, - value: it.name, - }; - }, - ), - ); + const dashboardSelectfieldPromQlList = computed(() => { + // Get fields from groupedFields based on current query's stream + const currentQuery = + props.dashboardPanelData.data.queries[ + props.dashboardPanelData.layout.currentQueryIndex + ]; + const currentStream = currentQuery?.fields?.stream; + + if (!currentStream) return []; + + // Find the current stream in groupedFields + const streamFields = + props.dashboardPanelData.meta.streamFields.groupedFields.find( + (group: any) => group.name === currentStream, + ); + + if (!streamFields?.schema) return []; + + return streamFields.schema.map((it: any) => { + return { + label: it.name, + value: it.name, + }; + }); + }); const timeShifts = [];