feat(db): 支持 VictoriaMetrics 数据库
* feat(victoriametrics): support native MetricsQL queries * fix(victoriametrics): 完善指标浏览和结果导出 * fix(victoriametrics): 修复指标对象通用操作入口 * fix(victoriametrics): 修正指标注释和截断提示 * fix(i18n): 补齐 VictoriaMetrics 连接配置翻译 --------- Co-authored-by: zipg <4047349+zipg@users.noreply.github.com>
This commit is contained in:
1 parent
930aa48c20
commit
2ede64f1cb
64 files changed
+1293
-64
No files matched your search
+2
-1
@@ -2,10 +2,11 @@ import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const dialogSource = readFileSync(new URL("../../../components/connection/ConnectionDialog.vue", import.meta.url), "utf8");
|
||||
const tlsCapableDatabaseTypesSource = dialogSource.match(/const tlsCapableDatabaseTypes = new Set<DatabaseType>\(\[([\s\S]*?)\]\);/)?.[1] ?? "";
|
||||
|
||||
describe("Dameng SSL connection form", () => {
|
||||
it("shows Dameng in the TLS tab with certificate directory and password fields", () => {
|
||||
expect(dialogSource).toContain('"questdb", "dameng", "redis"');
|
||||
expect(tlsCapableDatabaseTypesSource).toContain('"dameng"');
|
||||
expect(dialogSource).toContain("<template v-if=\"form.db_type === 'dameng'\">");
|
||||
expect(dialogSource).toContain('v-model="damengSslFilesPath"');
|
||||
expect(dialogSource).toContain('v-model="damengSslKeystorePassword"');
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyParsedConnectionUrl, parseConnectionUrl } from "@/lib/connection/connectionUrl";
|
||||
import type { ConnectionConfig } from "@/types/database";
|
||||
|
||||
describe("VictoriaMetrics connection URL", () => {
|
||||
it("parses single-node HTTP URLs with Basic Auth", () => {
|
||||
expect(parseConnectionUrl("http://vm_user:secret@vm.example.com:8428/prometheus", "victoriametrics")).toMatchObject({
|
||||
dbType: "victoriametrics",
|
||||
host: "vm.example.com",
|
||||
port: 8428,
|
||||
username: "vm_user",
|
||||
password: "secret",
|
||||
database: "metrics",
|
||||
apiPath: "/prometheus",
|
||||
ssl: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves cluster tenant API paths in external config", () => {
|
||||
const parsed = parseConnectionUrl("https://vm.example.com/select/42/prometheus", "victoriametrics");
|
||||
const config = applyParsedConnectionUrl(
|
||||
{
|
||||
db_type: "victoriametrics",
|
||||
name: "VictoriaMetrics",
|
||||
host: "",
|
||||
port: 8428,
|
||||
username: "",
|
||||
password: "",
|
||||
ssl: false,
|
||||
external_config: { lookback: "7d" },
|
||||
} as Omit<ConnectionConfig, "id">,
|
||||
parsed,
|
||||
);
|
||||
|
||||
expect(config.ssl).toBe(true);
|
||||
expect(config.external_config).toEqual({ lookback: "7d", apiPath: "/select/42/prometheus" });
|
||||
});
|
||||
});
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { filterModeIsSupportedForDatabase } from "@/lib/dataGrid/dataGridColumnFilter";
|
||||
import type { DataGridContextFilterMode } from "@/lib/dataGrid/dataGridSql";
|
||||
|
||||
describe("VictoriaMetrics data grid filters", () => {
|
||||
it("does not expose SQL filter modes for MetricsQL results", () => {
|
||||
const modes: DataGridContextFilterMode[] = ["equals", "not-equals", "is-null", "is-not-null", "like", "not-like", "less-than", "greater-than", "in", "not-in", "between", "not-between"];
|
||||
|
||||
expect(modes.every((mode) => !filterModeIsSupportedForDatabase(mode, "victoriametrics"))).toBe(true);
|
||||
expect(filterModeIsSupportedForDatabase("equals", "postgres")).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -169,6 +169,10 @@ describe("resolveNewQueryTable", () => {
|
||||
});
|
||||
|
||||
describe("buildSelectAllSql", () => {
|
||||
it("builds a MetricsQL range query for VictoriaMetrics metrics", () => {
|
||||
expect(buildSelectAllSql("victoriametrics", { tableName: "flag" })).toBe('{__name__="flag"}[1h]');
|
||||
});
|
||||
|
||||
it("quotes a MySQL table with backticks", () => {
|
||||
expect(buildSelectAllSql("mysql", { tableName: "users" })).toBe("SELECT * FROM `users`");
|
||||
});
|
||||
|
||||
@@ -1276,6 +1276,7 @@ describe("supportsExecutionTargetPicker", () => {
|
||||
expect(supportsExecutionTargetPicker("zookeeper")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker("mq")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker("neo4j")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker("victoriametrics")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user