Explore: Add transformations to correlation data links (#61799)

* bring in source from database

* bring in transformations from database

* add regex transformations to scopevar

* Consolidate types, add better example, cleanup

* Add var only if match

* Change ScopedVar to not require text, do not leak transformation-made variables between links

* Add mappings and start implementing logfmt

* Add mappings and start implementing logfmt

* Remove mappings, turn off global regex

* Add example yaml and omit transformations if empty

* Fix the yaml

* Add logfmt transformation

* Cleanup transformations and yaml

* add transformation field to FE types and use it, safeStringify logfmt values

* Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value

* Add test for transformation field

* Do not add null transformations object

* Break out transformation logic, add tests to backend code

* Fix lint errors I understand 😅

* Fix the backend lint error

* Remove unnecessary code and mark new Transformations object as internal

* Add support for named capture groups

* Remove type assertion

* Remove variable name from transformation

* Add test for overriding regexes

* Add back variable name field, but change to mapValue

* fix go api test

* Change transformation types to enum, add better provisioning checks for bad type name and format

* Check for expression with regex transformations
This commit is contained in:
Kristina
2023-02-22 06:53:03 -06:00
committed by GitHub
parent f64b7fe8a7
commit 06dfe2156f
17 changed files with 377 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
export interface ScopedVar<T = any> {
text: any;
text?: any;
value: T;
[key: string]: any;
}

View File

@@ -40,12 +40,27 @@ export interface DataLink<T extends DataQuery = any> {
internal?: InternalDataLink<T>;
}
/** @internal */
export enum SupportedTransformationTypes {
Regex = 'regex',
Logfmt = 'logfmt',
}
/** @internal */
export interface DataLinkTransformationConfig {
type: SupportedTransformationTypes;
field?: string;
expression?: string;
mapValue?: string;
}
/** @internal */
export interface InternalDataLink<T extends DataQuery = any> {
query: T;
datasourceUid: string;
datasourceName: string; // used as a title if `DataLink.title` is empty
panelsState?: ExplorePanelsState;
transformations?: DataLinkTransformationConfig[];
}
export type LinkTarget = '_blank' | '_self' | undefined;