mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
8 lines
342 B
TypeScript
8 lines
342 B
TypeScript
import { Labels } from '@grafana/data';
|
|
|
|
/** replace labels in a string. Used for loki+prometheus legend formats */
|
|
export function renderLegendFormat(aliasPattern: string, aliasData: Labels): string {
|
|
const aliasRegex = /\{\{\s*(.+?)\s*\}\}/g;
|
|
return aliasPattern.replace(aliasRegex, (_, g1) => (aliasData[g1] ? aliasData[g1] : g1));
|
|
}
|