mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
- adds a custom label renderer to Logs viewer in Explore
- labels are no longer treated as strings, they are passed as parsed objects to the log row
- label renderer supports onClick handler for an action
- renamed Explore's `onClickTableCell` to `onClickLabel` and wired up log label renderers
- reuse Prometheus `addLabelToSelector` to modify Logging queries via click on label
- added tests to `addLabelToSelector`, changed to include the surrounding `{}`
- use label render also for common labels in the controls panel
- logging meta data section has now a custom renderer that can render numbers, strings, and labels
- style adjustments
18 lines
420 B
TypeScript
18 lines
420 B
TypeScript
const selectorRegexp = /{[^{]*}/g;
|
|
export function parseQuery(input: string) {
|
|
const match = input.match(selectorRegexp);
|
|
let query = '';
|
|
let regexp = input;
|
|
|
|
if (match) {
|
|
query = match[0];
|
|
regexp = input.replace(selectorRegexp, '').trim();
|
|
}
|
|
|
|
return { query, regexp };
|
|
}
|
|
|
|
export function formatQuery(selector: string, search: string): string {
|
|
return `${selector || ''} ${search || ''}`.trim();
|
|
}
|