feat: complete Loki query, insights, settings and deployment workflows

Add the Loki query UI, access policies, ingress insights, alert and registry settings, and their backend APIs. Include the related Kubernetes deployment and collector updates required by the integrated application.

Validated with go test ./..., npm run build, and npm run lint.
This commit is contained in:
logan committed 2026-10-25 21:28:32 +08:00
1 parent f9c6c1d826
commit 2d73661dd1
127 files changed
+8117 -2876

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
// 日志查询纯工具(与组件分离)
/** 从 LogQL 提取 {...} 选择器部分 */
export function extractSelector(query: string): string {
const i = query.indexOf('{')
const j = query.indexOf('}', i)
return i >= 0 && j > i ? query.slice(i, j + 1) : ''
}
/**
* 把 key="value" 合并进 LogQL 的 {...} 选择器(同名标签替换旧值);exclude=true 用 != 排除
*/
export function applyLabelFilter(query: string, key: string, value: string, exclude = false): string {
const op = exclude ? '!=' : '='
const frag = `${key}${op}"${value}"`
const i = query.indexOf('{')
if (i < 0) return `{${frag}}`
const j = query.indexOf('}', i)
if (j < 0) return query
const inner = query.slice(i + 1, j).trim()
// 同名标签(=、!=、=~、!~)替换,其余保留
const parts = inner ? inner.split(',').map((s) => s.trim()).filter(Boolean) : []
const kept = parts.filter((p) => !new RegExp(`^${key}(=|!=|=~|!~)`).test(p))
kept.push(frag)
return query.slice(0, i + 1) + kept.join(', ') + query.slice(j)
}
/** 提取 LogQL 管道中的字面过滤词(|= "x" 与 != "y"),用于结果行高亮 */
export function literalFilters(query: string): string[] {
const terms: string[] = []
const re = /\|=\s*"((?:[^"\\]|\\.)*)"/g
let m: RegExpExecArray | null
while ((m = re.exec(query)) !== null) {
if (m[1]) terms.push(m[1].replace(/\\"/g, '"'))
}
return terms
}