diff --git a/apps/correlations/kinds/correlations.cue b/apps/correlations/kinds/correlations.cue index 4089057859f..defd0bacc1e 100644 --- a/apps/correlations/kinds/correlations.cue +++ b/apps/correlations/kinds/correlations.cue @@ -31,6 +31,14 @@ ConfigSpec: { transformations?: [...TransformationSpec] } +/*todo this is incorrect - target needs to be an object with any sort of key/value combination +inside of it +for external correlations, this is just `target: { url: 'google.com' }` , +but for query correlations, target is the json for populating the query editor, which is different +for every datasource + +right now this is resolving to require an object of objects, like item.spec.config.target.url is expecting an object +instead of a string. how do i fix this? */ TargetSpec: [string]: _ TransformationSpec: { diff --git a/packages/grafana-api-clients/src/clients/rtkq/correlations/v0alpha1/endpoints.gen.ts b/packages/grafana-api-clients/src/clients/rtkq/correlations/v0alpha1/endpoints.gen.ts index ef81f37a246..c5351dbfafb 100644 --- a/packages/grafana-api-clients/src/clients/rtkq/correlations/v0alpha1/endpoints.gen.ts +++ b/packages/grafana-api-clients/src/clients/rtkq/correlations/v0alpha1/endpoints.gen.ts @@ -407,6 +407,12 @@ export type ObjectMeta = { Populated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids */ uid?: string; }; + +/* +this needs to be + [key: string]: any; + }; +*/ export type CorrelationTargetSpec = { [key: string]: { [key: string]: any; diff --git a/public/app/features/correlations/useCorrelations.ts b/public/app/features/correlations/useCorrelations.ts index d058732c1d1..d5601754120 100644 --- a/public/app/features/correlations/useCorrelations.ts +++ b/public/app/features/correlations/useCorrelations.ts @@ -3,6 +3,7 @@ import { lastValueFrom } from 'rxjs'; import { generatedAPI as correlationAPIv0alpha1, + CorrelationCorrelationType, Correlation as CorrelationK8s, CorrelationList, } from '@grafana/api-clients/rtkq/correlations/v0alpha1'; @@ -88,17 +89,31 @@ const toEnrichedCorrelationDataK8s = (item: CorrelationK8s): CorrelationData | u label: item.spec.label, description: item.spec.description, provisioned: false, // todo - type: item.spec.type, }; if (item.spec.type === 'external') { const extCorr: CorrelationExternal = { ...baseCor, + type: 'external', + config: { + field: item.spec.config.field, + target: { + url: item.spec.config.target.url.url || '', // todo this is wrong, fix in spec + }, + transformations: [], // todo fix + }, }; return toEnrichedCorrelationData(extCorr); } else { const queryCorr: CorrelationQuery = { ...baseCor, + type: 'query', + targetUID: item.spec.target?.name || '', // todo + config: { + field: item.spec.config.field, + target: item.spec.config.target, // todo + transformations: [], // todo fix + }, }; return toEnrichedCorrelationData(queryCorr); } @@ -116,13 +131,6 @@ export const toEnrichedCorrelationsData = (correlationsResponse: CorrelationsRes }; }; -export const toEnrichedCorrelationDataK8s = (correlationsResponse: CorrelationList): CorrelationsData => { - return { - ...correlationsResponse, - correlations: correlationsResponse.items.map(toEnrichedCorrelationDataK8s).filter(validSourceFilter), - }; -}; - export function getData(response: FetchResponse) { return response.data; }