From 6f3b1b5921f68ee8a995321f2b1516b7bebb97ba Mon Sep 17 00:00:00 2001 From: Wangjunqi123 Date: Tue, 14 Nov 2023 16:07:51 +0800 Subject: [PATCH] add prometheus api --- .gitignore | 4 ++-- web/src/api/prometheus.ts | 34 ++++++++++++++++++++++++++++++++++ web/tsconfig.app.json | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 web/src/api/prometheus.ts diff --git a/.gitignore b/.gitignore index 3c06bbf..3827d59 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,8 @@ server/handler/assets/ server/handler/index.html web/node_modules web/dist/ -web/public/cluster.json -web/public/single.json +web/src/assets/cluster.json +web/src/assets/single.json docs/time-series.json go.work* \ No newline at end of file diff --git a/web/src/api/prometheus.ts b/web/src/api/prometheus.ts new file mode 100644 index 0000000..d43f935 --- /dev/null +++ b/web/src/api/prometheus.ts @@ -0,0 +1,34 @@ +import request from './request' +// 获取指标列表 +export function getPromRules() { + return request({ + url: '/plugin/prometheus/api/v1/targets', + method: 'get', + }) +} + +// 获取prome某一时间点的数据 +export function getPromeCurrent(data: object) { + return request({ + url: '/plugin/prometheus/api/v1/query', + method: 'get', + params: data + }) +} + +// 获取prome某一时间段的数据 +export function getPromeRange(data: object) { + return request({ + url: '/plugin/prometheus/api/v1/query_range', + method: 'get', + params: data + }) +} + +// 获取监控主机ip +export function getMacIp() { + return request({ + url: '/plugin_manage/info', + method: 'get', + }) +} \ No newline at end of file diff --git a/web/tsconfig.app.json b/web/tsconfig.app.json index 3e5b621..b426851 100755 --- a/web/tsconfig.app.json +++ b/web/tsconfig.app.json @@ -1,6 +1,6 @@ { "extends": "@vue/tsconfig/tsconfig.dom.json", - "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], + "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/assets/*.json"], "exclude": ["src/**/__tests__/*"], "compilerOptions": { "composite": true, -- Gitee