mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 20:42:41 +08:00

* Create basic prototype for Loki integration * Simplify importing queries * Code clean-up * Add test coverage and info box * Remove test data script * Update help * Use less space for mappings info * Make help screen dismissable * Make mappings help more generic * Convert learn more to a link * Remove unused param * Use a link Button for help section * Add an extra line for better formatting * Update public/app/plugins/datasource/graphite/configuration/MappingsHelp.tsx Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update public/app/plugins/datasource/graphite/configuration/MappingsHelp.tsx Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Re-arrange lines Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
32 lines
911 B
TypeScript
32 lines
911 B
TypeScript
import { GraphiteLokiMapping } from '../types';
|
|
|
|
/**
|
|
* Converts a simple string used in LokiLogsMappings component (e.g. "servers.(name).*")
|
|
* to data model saved in data source configuration.
|
|
*/
|
|
export function fromString(text: string): GraphiteLokiMapping {
|
|
return {
|
|
matchers: text.split('.').map((metricNode) => {
|
|
if (metricNode.startsWith('(') && metricNode.endsWith(')')) {
|
|
return {
|
|
value: '*',
|
|
labelName: metricNode.slice(1, -1),
|
|
};
|
|
} else {
|
|
return { value: metricNode };
|
|
}
|
|
}),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Coverts configuration stored in data source configuration into a string displayed in LokiLogsMappings component.
|
|
*/
|
|
export function toString(mapping: GraphiteLokiMapping): string {
|
|
return mapping.matchers
|
|
.map((matcher) => {
|
|
return matcher.labelName ? `(${matcher.labelName})` : `${matcher.value}`;
|
|
})
|
|
.join('.');
|
|
}
|