diff --git a/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts b/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts index b79cceeeda..2411102712 100644 --- a/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts +++ b/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts @@ -73,9 +73,18 @@ export class NewRelicDashboardClient implements NewRelicDashboardApi { const DashboardEntityList = await this.callApi( getDashboardParentGuidQuery, { - query: `parentId ='${guid}'`, + query: `id ='${guid}' OR parentId ='${guid}'`, }, ); + if ( + DashboardEntityList && + DashboardEntityList?.data?.actor.entitySearch.results.entities?.length > 1 + ) { + DashboardEntityList.data.actor.entitySearch.results.entities = + DashboardEntityList?.data.actor.entitySearch.results.entities.filter( + entity => entity?.dashboardParentGuid !== null, + ); + } return { getDashboardEntity: DashboardEntityList!, }; diff --git a/plugins/newrelic-dashboard/src/queries/getDashboardParentGuidQuery.ts b/plugins/newrelic-dashboard/src/queries/getDashboardParentGuidQuery.ts index 3a06384539..bc7c0b072b 100644 --- a/plugins/newrelic-dashboard/src/queries/getDashboardParentGuidQuery.ts +++ b/plugins/newrelic-dashboard/src/queries/getDashboardParentGuidQuery.ts @@ -14,4 +14,4 @@ * limitations under the License. */ export const getDashboardParentGuidQuery = - 'query ($query: String) {\n actor {\n entitySearch(query: $query) {\n results {\n entities {\n name\n ... on DashboardEntityOutline {\n name\n guid\n }\n permalink\n }\n }\n }\n }\n}\n'; + 'query ($query: String) {\n actor {\n entitySearch(query: $query) {\n results {\n entities {\n name\n ... on DashboardEntityOutline {\n name\n dashboardParentGuid\n guid\n }\n permalink\n }\n }\n }\n }\n}\n'; diff --git a/plugins/newrelic-dashboard/src/types/DashboardEntity.ts b/plugins/newrelic-dashboard/src/types/DashboardEntity.ts index 78a1b7913d..0c4fbb7a90 100644 --- a/plugins/newrelic-dashboard/src/types/DashboardEntity.ts +++ b/plugins/newrelic-dashboard/src/types/DashboardEntity.ts @@ -27,6 +27,7 @@ export type DashboardEntity = { }; export type ResultEntity = { + dashboardParentGuid: string; guid: string; permalink: string; name: string;