@cloudbase/manager-node 5.5.5 → 5.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/env/index.js +29 -2
- package/lib/environment.js +5 -0
- package/lib/index.js +3 -0
- package/lib/monitor/index.js +105 -0
- package/lib/monitor/types.js +2 -0
- package/lib/permission/index.js +1 -3
- package/package.json +1 -1
- package/types/env/index.d.ts +7 -0
- package/types/environment.d.ts +3 -0
- package/types/index.d.ts +2 -0
- package/types/interfaces/tcb.interface.d.ts +142 -37
- package/types/monitor/index.d.ts +37 -0
- package/types/monitor/types.d.ts +68 -0
- package/types/permission/index.d.ts +0 -1
package/lib/env/index.js
CHANGED
|
@@ -146,7 +146,7 @@ class EnvService {
|
|
|
146
146
|
};
|
|
147
147
|
const response = await this.describeEnvInfo(params);
|
|
148
148
|
const envBaseInfo = (_a = response === null || response === void 0 ? void 0 : response.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo;
|
|
149
|
-
//
|
|
149
|
+
// 将 EnvBaseInfo 完整映射到 EnvInfo 类型,避免新增字段被丢弃
|
|
150
150
|
const envInfo = {
|
|
151
151
|
EnvId: envBaseInfo.EnvId,
|
|
152
152
|
Alias: envBaseInfo.Alias,
|
|
@@ -161,7 +161,22 @@ class EnvService {
|
|
|
161
161
|
Region: envBaseInfo.Region || '',
|
|
162
162
|
Source: envBaseInfo.Source,
|
|
163
163
|
CreateTime: envBaseInfo.CreateTime,
|
|
164
|
-
UpdateTime: envBaseInfo.UpdateTime
|
|
164
|
+
UpdateTime: envBaseInfo.UpdateTime,
|
|
165
|
+
StaticStorages: envBaseInfo.StaticStorages,
|
|
166
|
+
IsAutoDegrade: envBaseInfo.IsAutoDegrade,
|
|
167
|
+
EnvChannel: envBaseInfo.EnvChannel,
|
|
168
|
+
PayMode: envBaseInfo.PayMode,
|
|
169
|
+
IsDefault: envBaseInfo.IsDefault,
|
|
170
|
+
Tags: envBaseInfo.Tags,
|
|
171
|
+
EnvType: envBaseInfo.EnvType,
|
|
172
|
+
IsDauPackage: envBaseInfo.IsDauPackage,
|
|
173
|
+
PackageType: envBaseInfo.PackageType,
|
|
174
|
+
ArchitectureType: envBaseInfo.ArchitectureType,
|
|
175
|
+
Recycle: envBaseInfo.Recycle,
|
|
176
|
+
EnvPreferences: envBaseInfo.EnvPreferences,
|
|
177
|
+
Meta: envBaseInfo.Meta,
|
|
178
|
+
PostgreSQL: envBaseInfo.PostgreSQL,
|
|
179
|
+
EnvStatus: envBaseInfo.EnvStatus
|
|
165
180
|
};
|
|
166
181
|
return {
|
|
167
182
|
EnvInfo: envInfo,
|
|
@@ -186,6 +201,18 @@ class EnvService {
|
|
|
186
201
|
async describeEnvInfo(params) {
|
|
187
202
|
return this.cloudService.request('DescribeEnvInfo', params);
|
|
188
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* 判断当前环境是否为 PostgreSQL 环境
|
|
206
|
+
* PostgreSQL 字段为数组且长度 > 0 时视为 PG 环境
|
|
207
|
+
*
|
|
208
|
+
* @returns 是否为 PG 环境
|
|
209
|
+
*/
|
|
210
|
+
async isPostgresqlEnv() {
|
|
211
|
+
var _a, _b;
|
|
212
|
+
const response = await this.describeEnvInfo({ EnvId: this.envId });
|
|
213
|
+
const postgresql = (_b = (_a = response === null || response === void 0 ? void 0 : response.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo) === null || _b === void 0 ? void 0 : _b.PostgreSQL;
|
|
214
|
+
return Array.isArray(postgresql) && postgresql.length > 0;
|
|
215
|
+
}
|
|
189
216
|
/**
|
|
190
217
|
* 修改环境名称
|
|
191
218
|
* @param {string} alias 环境名称
|
package/lib/environment.js
CHANGED
|
@@ -22,6 +22,7 @@ const cloudApp_1 = require("./cloudApp");
|
|
|
22
22
|
const permission_1 = require("./permission");
|
|
23
23
|
const sandbox_1 = require("./sandbox");
|
|
24
24
|
const aiModel_1 = require("./aiModel");
|
|
25
|
+
const monitor_1 = require("./monitor");
|
|
25
26
|
class Environment {
|
|
26
27
|
constructor(context, envId) {
|
|
27
28
|
this.inited = false;
|
|
@@ -47,6 +48,7 @@ class Environment {
|
|
|
47
48
|
this.cloudAppService = new cloudApp_1.CloudAppService(this);
|
|
48
49
|
this.sandboxService = new sandbox_1.SandboxService(this);
|
|
49
50
|
this.aiModelService = new aiModel_1.AiModelService(this);
|
|
51
|
+
this.monitorService = new monitor_1.MonitorService(this);
|
|
50
52
|
}
|
|
51
53
|
async lazyInit() {
|
|
52
54
|
if (!this.inited) {
|
|
@@ -121,6 +123,9 @@ class Environment {
|
|
|
121
123
|
getAiModelService() {
|
|
122
124
|
return this.aiModelService;
|
|
123
125
|
}
|
|
126
|
+
getMonitorService() {
|
|
127
|
+
return this.monitorService;
|
|
128
|
+
}
|
|
124
129
|
getCommonService(serviceType = 'tcb', serviceVersion) {
|
|
125
130
|
return new common_1.CommonService(this, serviceType, serviceVersion);
|
|
126
131
|
}
|
package/lib/index.js
CHANGED
|
@@ -122,6 +122,9 @@ class CloudBase {
|
|
|
122
122
|
get aiModel() {
|
|
123
123
|
return this.currentEnvironment().getAiModelService();
|
|
124
124
|
}
|
|
125
|
+
get monitor() {
|
|
126
|
+
return this.currentEnvironment().getMonitorService();
|
|
127
|
+
}
|
|
125
128
|
get docs() {
|
|
126
129
|
if (!this.docsService) {
|
|
127
130
|
this.docsService = new docs_1.DocsService();
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.MonitorService = void 0;
|
|
18
|
+
const error_1 = require("../error");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
// Period 与时间范围的约束规则
|
|
22
|
+
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
|
|
23
|
+
const THREE_DAYS_MS = 3 * ONE_DAY_MS;
|
|
24
|
+
const PERIOD_RULES = [
|
|
25
|
+
{ maxRangeMs: ONE_DAY_MS, allowed: [300, 3600] },
|
|
26
|
+
{ maxRangeMs: THREE_DAYS_MS, allowed: [300, 3600, 86400] },
|
|
27
|
+
// 超过3天
|
|
28
|
+
{ maxRangeMs: Infinity, allowed: [3600, 86400] }
|
|
29
|
+
];
|
|
30
|
+
function validatePeriod(startStr, endStr, period) {
|
|
31
|
+
if (period === undefined)
|
|
32
|
+
return;
|
|
33
|
+
const startMs = new Date(startStr).getTime();
|
|
34
|
+
const endMs = new Date(endStr).getTime();
|
|
35
|
+
if (isNaN(startMs) || isNaN(endMs))
|
|
36
|
+
return;
|
|
37
|
+
const rangeMs = endMs - startMs;
|
|
38
|
+
const rule = PERIOD_RULES.find(r => rangeMs <= r.maxRangeMs);
|
|
39
|
+
if (rule && !rule.allowed.includes(period)) {
|
|
40
|
+
throw new error_1.CloudBaseError(`Period=${period} 不适用于当前时间范围。` +
|
|
41
|
+
`时间范围 ${startStr} ~ ${endStr}(约 ${(rangeMs / ONE_DAY_MS).toFixed(1)} 天)` +
|
|
42
|
+
`仅支持 Period: [${rule.allowed.join(', ')}]`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class MonitorService {
|
|
46
|
+
constructor(environment) {
|
|
47
|
+
this.envId = environment.getEnvId();
|
|
48
|
+
this.cloudService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 查询环境监控数据
|
|
52
|
+
*
|
|
53
|
+
* 根据指定指标名称,查询当前环境在指定时间范围内的监控数据,
|
|
54
|
+
* 返回按统计粒度聚合后的时序数据。
|
|
55
|
+
*
|
|
56
|
+
* @param params 查询参数
|
|
57
|
+
* @returns 时序监控数据
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // 查询静态网站存储容量
|
|
61
|
+
* const res = await monitor.describeCurveData({
|
|
62
|
+
* MetricName: 'StaticFsSizePkg',
|
|
63
|
+
* StartTime: '2026-02-05 00:00:00',
|
|
64
|
+
* EndTime: '2026-02-06 23:59:59',
|
|
65
|
+
* Period: 3600
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // 查询云托管某服务某版本的错误响应
|
|
70
|
+
* const res = await monitor.describeCurveData({
|
|
71
|
+
* MetricName: 'TkeHttpErrorService',
|
|
72
|
+
* StartTime: '2026-03-13 00:00:00',
|
|
73
|
+
* EndTime: '2026-03-16 23:59:59',
|
|
74
|
+
* ResourceID: 'my-service',
|
|
75
|
+
* SubresourceID: 'my-service-001'
|
|
76
|
+
* })
|
|
77
|
+
*/
|
|
78
|
+
async describeCurveData(params) {
|
|
79
|
+
// 校验 Period 与时间范围的约束关系
|
|
80
|
+
validatePeriod(params.StartTime, params.EndTime, params.Period);
|
|
81
|
+
const requestParams = {
|
|
82
|
+
EnvId: this.envId,
|
|
83
|
+
MetricName: params.MetricName,
|
|
84
|
+
StartTime: params.StartTime,
|
|
85
|
+
EndTime: params.EndTime
|
|
86
|
+
};
|
|
87
|
+
if (params.ResourceID !== undefined) {
|
|
88
|
+
requestParams.ResourceID = params.ResourceID;
|
|
89
|
+
}
|
|
90
|
+
if (params.WxAppId !== undefined) {
|
|
91
|
+
requestParams.WxAppId = params.WxAppId;
|
|
92
|
+
}
|
|
93
|
+
if (params.SubresourceID !== undefined) {
|
|
94
|
+
requestParams.SubresourceID = params.SubresourceID;
|
|
95
|
+
}
|
|
96
|
+
if (params.ThirdResource !== undefined) {
|
|
97
|
+
requestParams.ThirdResource = params.ThirdResource;
|
|
98
|
+
}
|
|
99
|
+
if (params.Period !== undefined) {
|
|
100
|
+
requestParams.Period = params.Period;
|
|
101
|
+
}
|
|
102
|
+
return this.cloudService.request('DescribeCurveData', requestParams);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.MonitorService = MonitorService;
|
package/lib/permission/index.js
CHANGED
|
@@ -374,11 +374,9 @@ class PermissionService {
|
|
|
374
374
|
}
|
|
375
375
|
/**
|
|
376
376
|
* 判断当前环境是否为 PostgreSQL 环境
|
|
377
|
-
* PostgreSQL 是数组且长度 > 0 时为 PG 环境
|
|
378
377
|
*/
|
|
379
378
|
async isPostgresqlEnv() {
|
|
380
|
-
|
|
381
|
-
return Array.isArray(envBaseInfo.PostgreSQL) && envBaseInfo.PostgreSQL.length > 0;
|
|
379
|
+
return this.environment.getEnvService().isPostgresqlEnv();
|
|
382
380
|
}
|
|
383
381
|
/**
|
|
384
382
|
* 判断当前环境的 authz_engine 是否为 opa
|
package/package.json
CHANGED
package/types/env/index.d.ts
CHANGED
|
@@ -640,6 +640,13 @@ export declare class EnvService {
|
|
|
640
640
|
* @returns 环境信息响应
|
|
641
641
|
*/
|
|
642
642
|
describeEnvInfo(params: DescribeEnvInfoParams): Promise<DescribeEnvInfoResponse>;
|
|
643
|
+
/**
|
|
644
|
+
* 判断当前环境是否为 PostgreSQL 环境
|
|
645
|
+
* PostgreSQL 字段为数组且长度 > 0 时视为 PG 环境
|
|
646
|
+
*
|
|
647
|
+
* @returns 是否为 PG 环境
|
|
648
|
+
*/
|
|
649
|
+
isPostgresqlEnv(): Promise<boolean>;
|
|
643
650
|
/**
|
|
644
651
|
* 修改环境名称
|
|
645
652
|
* @param {string} alias 环境名称
|
package/types/environment.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { EnvInfo } from './interfaces';
|
|
|
18
18
|
import { PermissionService } from './permission';
|
|
19
19
|
import { SandboxService } from './sandbox';
|
|
20
20
|
import { AiModelService } from './aiModel';
|
|
21
|
+
import { MonitorService } from './monitor';
|
|
21
22
|
export declare class Environment {
|
|
22
23
|
inited: boolean;
|
|
23
24
|
cloudBaseContext: CloudBaseContext;
|
|
@@ -41,6 +42,7 @@ export declare class Environment {
|
|
|
41
42
|
private cloudAppService;
|
|
42
43
|
private sandboxService;
|
|
43
44
|
private aiModelService;
|
|
45
|
+
private monitorService;
|
|
44
46
|
constructor(context: CloudBaseContext, envId: string);
|
|
45
47
|
lazyInit(): Promise<any>;
|
|
46
48
|
getEnvId(): string;
|
|
@@ -62,6 +64,7 @@ export declare class Environment {
|
|
|
62
64
|
getPermissionService(): PermissionService;
|
|
63
65
|
getSandboxService(): SandboxService;
|
|
64
66
|
getAiModelService(): AiModelService;
|
|
67
|
+
getMonitorService(): MonitorService;
|
|
65
68
|
getCommonService(serviceType: string, serviceVersion: any): CommonService;
|
|
66
69
|
getServicesEnvInfo(): Promise<any>;
|
|
67
70
|
getAuthConfig(): {
|
package/types/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { PermissionService } from './permission';
|
|
|
19
19
|
import { SandboxService } from './sandbox';
|
|
20
20
|
import { CloudAppService } from './cloudApp';
|
|
21
21
|
import { AiModelService } from './aiModel';
|
|
22
|
+
import { MonitorService } from './monitor';
|
|
22
23
|
interface CloudBaseConfig {
|
|
23
24
|
secretId?: string;
|
|
24
25
|
secretKey?: string;
|
|
@@ -84,6 +85,7 @@ declare class CloudBase {
|
|
|
84
85
|
get permission(): PermissionService;
|
|
85
86
|
get sandbox(): SandboxService;
|
|
86
87
|
get aiModel(): AiModelService;
|
|
88
|
+
get monitor(): MonitorService;
|
|
87
89
|
get docs(): DocsService;
|
|
88
90
|
getEnvironmentManager(): EnvironmentManager;
|
|
89
91
|
getManagerConfig(): CloudBaseConfig;
|
|
@@ -120,12 +120,36 @@ export interface EnvInfo {
|
|
|
120
120
|
PackageName: string;
|
|
121
121
|
LogServices: LogServiceInfo[];
|
|
122
122
|
CustomLogServices: {
|
|
123
|
-
CreateTime
|
|
124
|
-
ClsLogsetId
|
|
125
|
-
ClsTopicId
|
|
126
|
-
ClsRegion
|
|
123
|
+
CreateTime?: string;
|
|
124
|
+
ClsLogsetId?: string;
|
|
125
|
+
ClsTopicId?: string;
|
|
126
|
+
ClsRegion?: string;
|
|
127
127
|
}[];
|
|
128
128
|
Region: string;
|
|
129
|
+
StaticStorages?: StaticStorageInfo[];
|
|
130
|
+
IsAutoDegrade?: boolean;
|
|
131
|
+
EnvChannel?: string;
|
|
132
|
+
PayMode?: string;
|
|
133
|
+
IsDefault?: boolean;
|
|
134
|
+
Tags?: Array<{
|
|
135
|
+
Key: string;
|
|
136
|
+
Value: string;
|
|
137
|
+
}>;
|
|
138
|
+
EnvType?: string;
|
|
139
|
+
IsDauPackage?: boolean;
|
|
140
|
+
PackageType?: string;
|
|
141
|
+
ArchitectureType?: string;
|
|
142
|
+
Recycle?: string;
|
|
143
|
+
EnvPreferences?: Array<{
|
|
144
|
+
Key?: string;
|
|
145
|
+
Value?: string;
|
|
146
|
+
}> | Record<string, any>;
|
|
147
|
+
Meta?: Array<{
|
|
148
|
+
Key: string;
|
|
149
|
+
Value: string;
|
|
150
|
+
}>;
|
|
151
|
+
PostgreSQL?: PostgreSQLInfo[] | Record<string, any>;
|
|
152
|
+
EnvStatus?: string;
|
|
129
153
|
}
|
|
130
154
|
export interface FunctionInfo {
|
|
131
155
|
Namespace?: string;
|
|
@@ -135,12 +159,38 @@ export interface DatabasesInfo {
|
|
|
135
159
|
InstanceId?: string;
|
|
136
160
|
Status?: string;
|
|
137
161
|
Region?: string;
|
|
162
|
+
UpdateTime?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface ExternalStorage {
|
|
165
|
+
BucketName?: string;
|
|
166
|
+
Region?: string;
|
|
167
|
+
BasePath?: string;
|
|
168
|
+
Enabled?: boolean;
|
|
169
|
+
Provider?: string;
|
|
138
170
|
}
|
|
139
171
|
export interface StorageInfo {
|
|
140
172
|
Region?: string;
|
|
141
173
|
Bucket?: string;
|
|
142
174
|
CdnDomain?: string;
|
|
143
175
|
AppId?: string;
|
|
176
|
+
DomainType?: string;
|
|
177
|
+
AccessAutoDisable?: boolean;
|
|
178
|
+
AccessExpire?: number;
|
|
179
|
+
ExternalStorage?: ExternalStorage;
|
|
180
|
+
CustomDomain?: string;
|
|
181
|
+
Status?: string;
|
|
182
|
+
}
|
|
183
|
+
export interface StaticStorageInfo {
|
|
184
|
+
StaticDomain?: string;
|
|
185
|
+
DefaultDirName?: string;
|
|
186
|
+
Status?: string;
|
|
187
|
+
Region?: string;
|
|
188
|
+
Bucket?: string;
|
|
189
|
+
EnvId?: string;
|
|
190
|
+
DomainType?: string;
|
|
191
|
+
AccessAutoDisable?: boolean;
|
|
192
|
+
AccessExpire?: number;
|
|
193
|
+
ExternalStorage?: ExternalStorage;
|
|
144
194
|
}
|
|
145
195
|
export interface LogServiceInfo {
|
|
146
196
|
LogsetName?: string;
|
|
@@ -148,6 +198,15 @@ export interface LogServiceInfo {
|
|
|
148
198
|
TopicName?: string;
|
|
149
199
|
TopicId?: string;
|
|
150
200
|
Region?: string;
|
|
201
|
+
Period?: number;
|
|
202
|
+
BillingMode?: string;
|
|
203
|
+
}
|
|
204
|
+
export interface PostgreSQLInfo {
|
|
205
|
+
Name?: string;
|
|
206
|
+
InstanceName?: string;
|
|
207
|
+
Status?: number;
|
|
208
|
+
Region?: string;
|
|
209
|
+
Version?: string;
|
|
151
210
|
}
|
|
152
211
|
export interface VoucherUseHistory {
|
|
153
212
|
VoucherId?: string;
|
|
@@ -171,6 +230,27 @@ export interface PackageInfo {
|
|
|
171
230
|
Desc?: string;
|
|
172
231
|
Detail?: string;
|
|
173
232
|
}
|
|
233
|
+
export interface CodeNumPair {
|
|
234
|
+
Code: string;
|
|
235
|
+
Num: number;
|
|
236
|
+
}
|
|
237
|
+
export interface QpsConfig {
|
|
238
|
+
QpsQuota?: number;
|
|
239
|
+
QpsCustomLimit?: number;
|
|
240
|
+
}
|
|
241
|
+
export interface OrderInfo {
|
|
242
|
+
TranId?: string;
|
|
243
|
+
PackageId?: string;
|
|
244
|
+
TranType?: string;
|
|
245
|
+
TranStatus?: string;
|
|
246
|
+
UpdateTime?: string;
|
|
247
|
+
CreateTime?: string;
|
|
248
|
+
PayMode?: string;
|
|
249
|
+
ExtensionId?: string;
|
|
250
|
+
ResourceReady?: string;
|
|
251
|
+
Flag?: string;
|
|
252
|
+
ReqBody?: string;
|
|
253
|
+
}
|
|
174
254
|
export interface EnvBillingInfoItem {
|
|
175
255
|
EnvId?: string;
|
|
176
256
|
PackageId?: string;
|
|
@@ -183,11 +263,25 @@ export interface EnvBillingInfoItem {
|
|
|
183
263
|
UpdateTime?: string;
|
|
184
264
|
IsAlwaysFree?: boolean;
|
|
185
265
|
PaymentChannel?: string;
|
|
266
|
+
OrderInfo?: OrderInfo;
|
|
267
|
+
FreeQuota?: string;
|
|
268
|
+
EnableOverrun?: boolean;
|
|
269
|
+
ExtPackageType?: string;
|
|
270
|
+
EnvCharged?: string;
|
|
271
|
+
EnvActivated?: string;
|
|
272
|
+
EnvPaid?: string;
|
|
273
|
+
EnvOrigin?: string;
|
|
274
|
+
ResourceId?: string;
|
|
275
|
+
BillTime?: string;
|
|
276
|
+
EnvAutoId?: number;
|
|
186
277
|
PackageName?: string;
|
|
187
|
-
ExtPackageCode?:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
278
|
+
ExtPackageCode?: CodeNumPair[];
|
|
279
|
+
TipList?: string;
|
|
280
|
+
EnvDeductionMode?: string;
|
|
281
|
+
PointsTime?: string;
|
|
282
|
+
QpsQuota?: number;
|
|
283
|
+
QpsCustomLimit?: number;
|
|
284
|
+
EnvQps?: QpsConfig;
|
|
191
285
|
}
|
|
192
286
|
export interface InvoiceVATGeneral {
|
|
193
287
|
TaxPayerType?: string;
|
|
@@ -469,62 +563,73 @@ export interface DescribeEnvInfoParams {
|
|
|
469
563
|
}
|
|
470
564
|
export interface EnvBaseInfo {
|
|
471
565
|
EnvId?: string;
|
|
566
|
+
Source?: string;
|
|
472
567
|
Alias?: string;
|
|
568
|
+
CreateTime?: string;
|
|
569
|
+
UpdateTime?: string;
|
|
473
570
|
Status?: string;
|
|
474
|
-
EnvType?: string;
|
|
475
|
-
Region?: string;
|
|
476
|
-
PackageId?: string;
|
|
477
|
-
PackageName?: string;
|
|
478
571
|
Databases?: DatabasesInfo[];
|
|
479
572
|
Storages?: StorageInfo[];
|
|
480
573
|
Functions?: FunctionInfo[];
|
|
574
|
+
PackageId?: string;
|
|
575
|
+
PackageName?: string;
|
|
576
|
+
LogServices?: LogServiceInfo[] | null;
|
|
577
|
+
StaticStorages?: StaticStorageInfo[];
|
|
578
|
+
IsAutoDegrade?: boolean;
|
|
579
|
+
EnvChannel?: string;
|
|
481
580
|
PayMode?: string;
|
|
482
|
-
|
|
581
|
+
IsDefault?: boolean;
|
|
582
|
+
Region?: string;
|
|
483
583
|
Tags?: Array<{
|
|
484
584
|
Key: string;
|
|
485
585
|
Value: string;
|
|
486
586
|
}>;
|
|
587
|
+
CustomLogServices?: Array<{
|
|
588
|
+
ClsRegion?: string;
|
|
589
|
+
ClsLogsetId?: string;
|
|
590
|
+
ClsTopicId?: string;
|
|
591
|
+
CreateTime?: string;
|
|
592
|
+
}> | null;
|
|
593
|
+
EnvType?: string;
|
|
594
|
+
IsDauPackage?: boolean;
|
|
595
|
+
PackageType?: string;
|
|
596
|
+
ArchitectureType?: string;
|
|
597
|
+
Recycle?: string;
|
|
598
|
+
EnvPreferences?: Array<{
|
|
599
|
+
Key?: string;
|
|
600
|
+
Value?: string;
|
|
601
|
+
}> | Record<string, any>;
|
|
487
602
|
Meta?: Array<{
|
|
488
603
|
Key: string;
|
|
489
604
|
Value: string;
|
|
490
605
|
}>;
|
|
606
|
+
PostgreSQL?: PostgreSQLInfo[] | Record<string, any>;
|
|
607
|
+
EnvStatus?: string;
|
|
608
|
+
}
|
|
609
|
+
export interface AccountInfoInner {
|
|
610
|
+
Uin?: number | string;
|
|
611
|
+
AppId?: number | string;
|
|
612
|
+
WxAppId?: string;
|
|
613
|
+
OpenAppId?: string;
|
|
491
614
|
CreateTime?: string;
|
|
492
615
|
UpdateTime?: string;
|
|
493
|
-
EnvPreferences?: Record<string, any>;
|
|
494
|
-
IsAutoDegrade?: boolean;
|
|
495
|
-
IsDauPackage?: boolean;
|
|
496
|
-
PostgreSQL?: Record<string, any>;
|
|
497
|
-
LogServices?: Array<{
|
|
498
|
-
LogsetId?: string;
|
|
499
|
-
TopicId?: string;
|
|
500
|
-
TopicName?: string;
|
|
501
|
-
Region?: string;
|
|
502
|
-
}> | null;
|
|
503
|
-
CustomLogServices?: Array<{
|
|
504
|
-
CreateTime: string;
|
|
505
|
-
ClsLogsetId: string;
|
|
506
|
-
ClsTopicId: string;
|
|
507
|
-
ClsRegion: string;
|
|
508
|
-
}> | null;
|
|
509
616
|
}
|
|
617
|
+
/**
|
|
618
|
+
* 计费信息(保留 BillingInfo 用于向后兼容;DescribeEnvInfo 接口的 BillingInfo 实际为 EnvBillingInfoItem)
|
|
619
|
+
*/
|
|
510
620
|
export interface BillingInfo {
|
|
511
621
|
StartTime?: string;
|
|
512
622
|
EndTime?: string;
|
|
513
623
|
Status?: string;
|
|
514
624
|
}
|
|
515
|
-
export interface UserInfo {
|
|
516
|
-
AppId?: string;
|
|
517
|
-
Uin?: string;
|
|
518
|
-
WxAppId?: string;
|
|
519
|
-
}
|
|
520
625
|
export interface DescribeEnvInfoResponse extends IResponseInfo {
|
|
521
626
|
EnvInfo?: {
|
|
522
627
|
EnvBaseInfo?: EnvBaseInfo;
|
|
523
|
-
BillingInfo?:
|
|
524
|
-
UserInfo?:
|
|
628
|
+
BillingInfo?: EnvBillingInfoItem;
|
|
629
|
+
UserInfo?: AccountInfoInner;
|
|
525
630
|
Eid?: number;
|
|
631
|
+
SiteFlag?: string;
|
|
526
632
|
CircleStartTime?: string;
|
|
527
633
|
CircleEndTime?: string;
|
|
528
|
-
SiteFlag?: number;
|
|
529
634
|
};
|
|
530
635
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Environment } from '../environment';
|
|
2
|
+
import { IDescribeCurveDataParams, IDescribeCurveDataResponse } from './types';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export declare class MonitorService {
|
|
5
|
+
private envId;
|
|
6
|
+
private cloudService;
|
|
7
|
+
constructor(environment: Environment);
|
|
8
|
+
/**
|
|
9
|
+
* 查询环境监控数据
|
|
10
|
+
*
|
|
11
|
+
* 根据指定指标名称,查询当前环境在指定时间范围内的监控数据,
|
|
12
|
+
* 返回按统计粒度聚合后的时序数据。
|
|
13
|
+
*
|
|
14
|
+
* @param params 查询参数
|
|
15
|
+
* @returns 时序监控数据
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // 查询静态网站存储容量
|
|
19
|
+
* const res = await monitor.describeCurveData({
|
|
20
|
+
* MetricName: 'StaticFsSizePkg',
|
|
21
|
+
* StartTime: '2026-02-05 00:00:00',
|
|
22
|
+
* EndTime: '2026-02-06 23:59:59',
|
|
23
|
+
* Period: 3600
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // 查询云托管某服务某版本的错误响应
|
|
28
|
+
* const res = await monitor.describeCurveData({
|
|
29
|
+
* MetricName: 'TkeHttpErrorService',
|
|
30
|
+
* StartTime: '2026-03-13 00:00:00',
|
|
31
|
+
* EndTime: '2026-03-16 23:59:59',
|
|
32
|
+
* ResourceID: 'my-service',
|
|
33
|
+
* SubresourceID: 'my-service-001'
|
|
34
|
+
* })
|
|
35
|
+
*/
|
|
36
|
+
describeCurveData(params: IDescribeCurveDataParams): Promise<IDescribeCurveDataResponse>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 监控指标名称
|
|
3
|
+
*
|
|
4
|
+
* 文档型数据库 / SQL型数据库 / 云函数 / 云托管 / 静态网站 / 身份认证 / API调用 / HTTP网关 / 大模型 / 知识库 / 用户登录 / 环境QPS / 数据库连接器 / 网关
|
|
5
|
+
*/
|
|
6
|
+
export type MetricName = 'DbRead' | 'DbWrite' | 'DbCostTime10ms' | 'DbCostTime50ms' | 'DbCostTime100ms' | 'DbSizepkg' | 'MysqlStorageUsage' | 'MysqlCCU' | 'MysqlCpuUsageRate' | 'MysqlDbConnections' | 'MysqlMemoryUse' | 'MysqlSlowQueries' | 'MysqlTps' | 'MysqlQps' | 'FunctionCU' | 'FunctionInvocation' | 'FunctionFlux' | 'FunctionThrottle' | 'FunctionConcurrentExecutions' | 'FunctionTimeout' | 'FunctionGBs' | 'FunctionError' | 'FunctionDuration' | 'FunctionConcurrencyMemoryMB' | 'FunctionMemOverFlow' | 'FunctionIdleProvisioned' | 'FunctionProvisionedConcurrency' | 'TkeRspTimeService' | 'TkeCpuUsedService' | 'TkeMemUsedService' | 'TkeQPSService' | 'TkePodNumService' | 'TkeHttpServiceNatPkg' | 'TkeCUUsedService' | 'TkeInvokeNumService' | 'TkeHttpErrorService' | 'StaticFsFluxPkg' | 'StaticFsSizePkg' | 'AuthInvocationNumPkg' | 'GwCloudDevelopmentSecureCallsInvocation' | 'GwWXInvocation' | 'GwCloudDevelopmentStandardCallsInvocation' | 'AIPromptTokenNumPkg' | 'AICompletionTokenNumPkg' | 'AITotalTokenNumPkg' | 'KnowledgeBaseCapacity' | 'DayActiveLoginAnonymousUser' | 'DayActiveLoginAllUser' | 'DayActiveLoginExternalUser' | 'DayActiveLoginInternalUser' | 'EnvQPSAll' | 'MongoConnectorRead' | 'MongoConnectorWrite' | 'MongoConnectorCostTime10ms' | 'MongoConnectorCostTime50ms' | 'MongoConnectorCostTime100ms' | 'MongoConnectorInvokeNum' | 'GatewayTraceEnvQPS' | 'GatewayShowAPIInvokeNum' | 'GatewayShowAPICostTotal' | 'GatewayShowAPIHTTP2XX' | 'GatewayShowAPIHTTPError' | 'GatewayTraceAccessSourceQPS' | 'GatewayShowHttpInvokeNum' | 'GatewayShowHttpCostTotal' | 'GatewayShowHttpHTTP2XX' | 'GatewayShowHttpHTTPError' | 'GatewayTraceResourceQPS' | (string & {});
|
|
7
|
+
/** 统计周期(秒) */
|
|
8
|
+
export type MetricPeriod = 300 | 3600 | 86400;
|
|
9
|
+
/** DescribeCurveData 请求参数 */
|
|
10
|
+
export interface IDescribeCurveDataParams {
|
|
11
|
+
/** 指标名称 */
|
|
12
|
+
MetricName: MetricName;
|
|
13
|
+
/** 开始时间,格式 'YYYY-MM-DD HH:mm:ss',需早于结束时间至少5分钟 */
|
|
14
|
+
StartTime: string;
|
|
15
|
+
/** 结束时间,格式 'YYYY-MM-DD HH:mm:ss',需晚于开始时间至少5分钟 */
|
|
16
|
+
EndTime: string;
|
|
17
|
+
/**
|
|
18
|
+
* 资源ID(可选)
|
|
19
|
+
* - 文档型数据库:集合名称
|
|
20
|
+
* - 云函数:函数名称
|
|
21
|
+
* - 云托管:服务名称(必传)
|
|
22
|
+
* - 数据库连接器:实例id(必传)
|
|
23
|
+
* - 网关-调用链路维度:小程序API传'wx',云开发API传'http_openapi'(必传)
|
|
24
|
+
* - 网关-环境/资源维度:必传
|
|
25
|
+
* - 留空则查询整个 namespace 的指标
|
|
26
|
+
*/
|
|
27
|
+
ResourceID?: string;
|
|
28
|
+
/** 微信AppId,微信场景必传 */
|
|
29
|
+
WxAppId?: string;
|
|
30
|
+
/** 子资源信息,查询云托管相关指标的具体版本的监控数据,需传入 */
|
|
31
|
+
SubresourceID?: string;
|
|
32
|
+
/** 网关路由 */
|
|
33
|
+
ThirdResource?: string;
|
|
34
|
+
/**
|
|
35
|
+
* 统计周期(秒),仅支持 300 / 3600 / 86400
|
|
36
|
+
* 不传则根据时间范围自动选择:
|
|
37
|
+
* - 1天内:300
|
|
38
|
+
* - 1天~15天:3600
|
|
39
|
+
* - 15天~180天:86400
|
|
40
|
+
*
|
|
41
|
+
* 传入时需遵循以下约束:
|
|
42
|
+
* - 时间范围 ≤ 1天:可取 300 或 3600
|
|
43
|
+
* - 时间范围 > 1天且 ≤ 3天:可取 300、3600 或 86400
|
|
44
|
+
* - 时间范围 > 3天:可取 3600 或 86400
|
|
45
|
+
*/
|
|
46
|
+
Period?: MetricPeriod;
|
|
47
|
+
}
|
|
48
|
+
/** DescribeCurveData 响应结果 */
|
|
49
|
+
export interface IDescribeCurveDataResponse {
|
|
50
|
+
/** 开始时间(会根据统计周期取整) */
|
|
51
|
+
StartTime: string;
|
|
52
|
+
/** 结束时间(会根据统计周期取整) */
|
|
53
|
+
EndTime: string;
|
|
54
|
+
/** 指标名 */
|
|
55
|
+
MetricName: string;
|
|
56
|
+
/** 统计周期(秒) */
|
|
57
|
+
Period: number;
|
|
58
|
+
/** 监控数据(整数),与 Time 一一对应 */
|
|
59
|
+
Values: number[];
|
|
60
|
+
/** 时间戳数组(Unix 时间戳,秒级),与 Values 一一对应 */
|
|
61
|
+
Time: number[];
|
|
62
|
+
/** 监控数据(浮点数),与 Time 一一对应 */
|
|
63
|
+
NewValues: number[];
|
|
64
|
+
/** 聚合方式:'last' | 'max' | 'avg' | 'sum' */
|
|
65
|
+
Statistics: string;
|
|
66
|
+
/** 请求ID */
|
|
67
|
+
RequestId: string;
|
|
68
|
+
}
|