mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
- add second query field to logging datasource query component - second field manages search term, first field manages stream selectors - improved logging cheat sheet to get started
19 lines
458 B
TypeScript
19 lines
458 B
TypeScript
const selectorRegexp = /(?:^|\s){[^{]*}/g;
|
|
export function parseQuery(input: string) {
|
|
input = input || '';
|
|
const match = input.match(selectorRegexp);
|
|
let query = '';
|
|
let regexp = input;
|
|
|
|
if (match) {
|
|
query = match[0].trim();
|
|
regexp = input.replace(selectorRegexp, '').trim();
|
|
}
|
|
|
|
return { query, regexp };
|
|
}
|
|
|
|
export function formatQuery(selector: string, search: string): string {
|
|
return `${selector || ''} ${search || ''}`.trim();
|
|
}
|