日志管理
This commit is contained in:
@@ -10,6 +10,19 @@ export const fetchAlertLevelList = (data?: {
|
||||
return request.get("/Alert/v1/severity/list", { params: data || {} });
|
||||
};
|
||||
|
||||
/** 获取告警级别下拉选项(不分页),默认仅返回 enabled=true */
|
||||
export const fetchAlertLevelOptions = (data?: {
|
||||
keyword?: string;
|
||||
enabled?: 'true' | 'false';
|
||||
}) => {
|
||||
return request.get("/Alert/v1/severity/options", {
|
||||
params: {
|
||||
keyword: data?.keyword || undefined,
|
||||
enabled: data?.enabled ?? 'true',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 获取告警级别详情 */
|
||||
export const fetchAlertLevelDetail = (id: number) => {
|
||||
return request.get(`/Alert/v1/severity/get/${id}`);
|
||||
|
||||
@@ -112,6 +112,18 @@ export const fetchSeverityList = (data: {
|
||||
enabled?: string;
|
||||
}) => request.get("/Alert/v1/severity/list", { params: data });
|
||||
|
||||
/** 获取告警级别下拉选项(不分页),支持 keyword 模糊搜索与 enabled=true 过滤 */
|
||||
export const fetchSeverityOptions = (data?: {
|
||||
keyword?: string;
|
||||
enabled?: 'true' | 'false';
|
||||
}) =>
|
||||
request.get("/Alert/v1/severity/options", {
|
||||
params: {
|
||||
keyword: data?.keyword || undefined,
|
||||
enabled: data?.enabled ?? 'true',
|
||||
},
|
||||
});
|
||||
|
||||
/** 获取工单模板下拉选项 */
|
||||
export const fetchFeedbackTemplateOptions = (data?: {
|
||||
status?: 'active' | 'inactive'
|
||||
|
||||
@@ -64,6 +64,12 @@ export interface AlertSeverity {
|
||||
name: string
|
||||
color?: string
|
||||
level?: number
|
||||
description?: string
|
||||
icon?: string
|
||||
priority?: number
|
||||
enabled?: boolean
|
||||
is_default?: boolean
|
||||
config?: any
|
||||
}
|
||||
|
||||
// 指标元数据
|
||||
@@ -188,6 +194,19 @@ export const fetchSeverityList = () => {
|
||||
return request.get('/Alert/v1/severity/list')
|
||||
}
|
||||
|
||||
/** 获取告警级别下拉选项(不分页),支持 keyword 模糊搜索与 enabled=true 过滤 */
|
||||
export const fetchSeverityOptions = (params?: {
|
||||
keyword?: string
|
||||
enabled?: 'true' | 'false'
|
||||
}) => {
|
||||
return request.get('/Alert/v1/severity/options', {
|
||||
params: {
|
||||
keyword: params?.keyword || undefined,
|
||||
enabled: params?.enabled ?? 'true',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 按 code 获取告警级别 */
|
||||
export const fetchSeverityByCode = (code: string) => {
|
||||
return request.get(`/Alert/v1/severity/get-by-code/${code}`)
|
||||
|
||||
157
src/api/ops/logs.ts
Normal file
157
src/api/ops/logs.ts
Normal file
@@ -0,0 +1,157 @@
|
||||
import { request } from '@/api/request'
|
||||
|
||||
const BASE = '/Logs/v1'
|
||||
|
||||
/** 解析 bsm-sdk 风格响应,取出业务 data */
|
||||
export function unwrapLogsPayload(res: any): any {
|
||||
if (res == null) return null
|
||||
if (typeof res.code === 'number' && res.code !== 0) return null
|
||||
return res.details ?? res.data ?? null
|
||||
}
|
||||
|
||||
export interface LogEvent {
|
||||
id: number
|
||||
created_at: string
|
||||
source_kind: string
|
||||
remote_addr: string
|
||||
raw_payload: string
|
||||
normalized_summary: string
|
||||
normalized_detail: string
|
||||
device_name: string
|
||||
severity_code: string
|
||||
trap_oid: string
|
||||
alert_sent: boolean
|
||||
}
|
||||
|
||||
export interface LogEntriesParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
source_kind?: string
|
||||
}
|
||||
|
||||
export interface LogEntriesResult {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
items: LogEvent[]
|
||||
}
|
||||
|
||||
export interface SyslogRule {
|
||||
id?: number
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
name: string
|
||||
enabled: boolean
|
||||
priority: number
|
||||
device_name_contains: string
|
||||
keyword_regex: string
|
||||
alert_name: string
|
||||
severity_code: string
|
||||
policy_id: number
|
||||
}
|
||||
|
||||
export interface TrapRule {
|
||||
id?: number
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
name: string
|
||||
enabled: boolean
|
||||
priority: number
|
||||
oid_prefix: string
|
||||
varbind_match_regex: string
|
||||
alert_name: string
|
||||
severity_code: string
|
||||
policy_id: number
|
||||
}
|
||||
|
||||
export interface TrapDictionaryEntry {
|
||||
id?: number
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
oid_prefix: string
|
||||
title: string
|
||||
description: string
|
||||
severity_code: string
|
||||
recovery_message: string
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export interface TrapShield {
|
||||
id?: number
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
name: string
|
||||
enabled: boolean
|
||||
source_ip_cidr: string
|
||||
oid_prefix: string
|
||||
interface_hint: string
|
||||
time_windows_json: string
|
||||
}
|
||||
|
||||
export function fetchLogEntries(params?: LogEntriesParams) {
|
||||
return request.get(`${BASE}/entries`, { params })
|
||||
}
|
||||
|
||||
export function fetchSyslogRules() {
|
||||
return request.get(`${BASE}/syslog-rules`)
|
||||
}
|
||||
|
||||
export function createSyslogRule(data: Partial<SyslogRule>) {
|
||||
return request.post(`${BASE}/syslog-rules`, data)
|
||||
}
|
||||
|
||||
export function updateSyslogRule(id: number, data: Partial<SyslogRule>) {
|
||||
return request.put(`${BASE}/syslog-rules/${id}`, data)
|
||||
}
|
||||
|
||||
export function deleteSyslogRule(id: number) {
|
||||
return request.delete(`${BASE}/syslog-rules/${id}`)
|
||||
}
|
||||
|
||||
export function fetchTrapRules() {
|
||||
return request.get(`${BASE}/trap-rules`)
|
||||
}
|
||||
|
||||
export function createTrapRule(data: Partial<TrapRule>) {
|
||||
return request.post(`${BASE}/trap-rules`, data)
|
||||
}
|
||||
|
||||
export function updateTrapRule(id: number, data: Partial<TrapRule>) {
|
||||
return request.put(`${BASE}/trap-rules/${id}`, data)
|
||||
}
|
||||
|
||||
export function deleteTrapRule(id: number) {
|
||||
return request.delete(`${BASE}/trap-rules/${id}`)
|
||||
}
|
||||
|
||||
export function fetchTrapDictionary() {
|
||||
return request.get(`${BASE}/trap-dictionary`)
|
||||
}
|
||||
|
||||
export function createTrapDictionary(data: Partial<TrapDictionaryEntry>) {
|
||||
return request.post(`${BASE}/trap-dictionary`, data)
|
||||
}
|
||||
|
||||
export function updateTrapDictionary(id: number, data: Partial<TrapDictionaryEntry>) {
|
||||
return request.put(`${BASE}/trap-dictionary/${id}`, data)
|
||||
}
|
||||
|
||||
export function deleteTrapDictionary(id: number) {
|
||||
return request.delete(`${BASE}/trap-dictionary/${id}`)
|
||||
}
|
||||
|
||||
export function fetchTrapSuppressions() {
|
||||
return request.get(`${BASE}/trap-suppressions`)
|
||||
}
|
||||
|
||||
export function createTrapSuppression(data: Partial<TrapShield>) {
|
||||
return request.post(`${BASE}/trap-suppressions`, data)
|
||||
}
|
||||
|
||||
export function updateTrapSuppression(id: number, data: Partial<TrapShield>) {
|
||||
return request.put(`${BASE}/trap-suppressions/${id}`, data)
|
||||
}
|
||||
|
||||
export function deleteTrapSuppression(id: number) {
|
||||
return request.delete(`${BASE}/trap-suppressions/${id}`)
|
||||
}
|
||||
Reference in New Issue
Block a user