🔨 修改标签查询逻辑.
This commit is contained in:
@@ -28,7 +28,7 @@ export interface MonitorHostSwitchUpdateRequest {
|
||||
* 监控主机查询请求
|
||||
*/
|
||||
export interface MonitorHostQueryRequest extends Pagination {
|
||||
agentKeyList?: Array<string>;
|
||||
agentKeys?: Array<string>;
|
||||
searchValue?: string;
|
||||
alarmSwitch?: number;
|
||||
policyId?: number;
|
||||
@@ -43,6 +43,15 @@ export interface MonitorHostQueryRequest extends Pagination {
|
||||
tags?: Array<number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控主机标签查询请求
|
||||
*/
|
||||
export interface MonitorHostQueryTagRequest {
|
||||
measurement?: string;
|
||||
policyId?: number;
|
||||
agentKeys?: Array<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控主机图表查询请求
|
||||
*/
|
||||
@@ -147,12 +156,12 @@ export interface MonitorHostMetricsData {
|
||||
/**
|
||||
* 查询监控主机指标
|
||||
*/
|
||||
export function getMonitorHostMetrics(agentKeyList: Array<string>) {
|
||||
export function getMonitorHostMetrics(agentKeys: Array<string>) {
|
||||
return axios.post<Array<MonitorHostMetricsData>>('/monitor/monitor-host/metrics', {
|
||||
agentKeyList
|
||||
agentKeys
|
||||
}, {
|
||||
promptBizErrorMessage: false,
|
||||
promptRequestErrorMessage: false,
|
||||
promptRequestErrorMessage: false
|
||||
});
|
||||
}
|
||||
|
||||
@@ -178,10 +187,10 @@ export function getMonitorHostPage(request: MonitorHostQueryRequest) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询监控告警标签
|
||||
* 查询监控主机标签
|
||||
*/
|
||||
export function getMonitorHostPolicyRuleTags(policyId: number, measurement: string = '') {
|
||||
return axios.get<Array<string>>('/monitor/monitor-host/host-tags', { params: { policyId, measurement } });
|
||||
export function getMonitorHostTags(request: MonitorHostQueryTagRequest) {
|
||||
return axios.post<Array<string>>('/monitor/monitor-host/host-tags', request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ export interface TimeSeriesColor {
|
||||
export interface TimeSeriesOption {
|
||||
name: string;
|
||||
type: TimeSeriesType;
|
||||
smooth: boolean;
|
||||
area: boolean;
|
||||
lineColor: string;
|
||||
itemBorderColor: string;
|
||||
@@ -126,7 +127,7 @@ export const createTimeSeries = (option: Partial<TimeSeriesOption>): LineSeriesO
|
||||
name: option.name,
|
||||
data: option.data || [],
|
||||
type: option.type || 'line',
|
||||
smooth: true,
|
||||
smooth: option.smooth ?? true,
|
||||
symbol: 'circle',
|
||||
symbolSize: 10,
|
||||
itemStyle: {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
class="tag-values"
|
||||
style="width: 260px"
|
||||
:max-tag-count="2"
|
||||
:options="[measurement] || []"
|
||||
:options="measurementTags[measurement] || []"
|
||||
placeholder="输入或选择标签值"
|
||||
multiple
|
||||
allow-create>
|
||||
@@ -207,7 +207,7 @@
|
||||
import { createAlarmRule, updateAlarmRule } from '@/api/monitor/alarm-rule';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { useDictStore, useCacheStore } from '@/store';
|
||||
import { getMonitorHostPolicyRuleTags } from '@/api/monitor/monitor-host';
|
||||
import { getMonitorHostTags } from '@/api/monitor/monitor-host';
|
||||
import MonitorMetricsSelector from '@/components/monitor/metrics/selector/index.vue';
|
||||
|
||||
const emits = defineEmits(['added', 'updated']);
|
||||
@@ -224,7 +224,7 @@
|
||||
const tags = ref<Array<RuleTag>>([]);
|
||||
const hasTags = ref(false);
|
||||
const measurement = ref('');
|
||||
const = ref<Record<string, string[]>>({});
|
||||
const measurementTags = ref<Record<string, string[]>>({});
|
||||
|
||||
const defaultForm = (): AlarmRuleUpdateRequest => {
|
||||
return {
|
||||
@@ -330,13 +330,16 @@
|
||||
|
||||
// 加载全部标签
|
||||
const loadTags = () => {
|
||||
const tags = .value[measurement.value];
|
||||
const tags = measurementTags.value[measurement.value];
|
||||
if (tags) {
|
||||
return;
|
||||
}
|
||||
// 加载标签
|
||||
getMonitorHostPolicyRuleTags(formModel.value.policyId as number, measurement.value).then(({ data }) => {
|
||||
.value[measurement.value as any] = data;
|
||||
getMonitorHostTags({
|
||||
measurement: measurement.value,
|
||||
policyId: formModel.value.policyId,
|
||||
}).then(({ data }) => {
|
||||
measurementTags.value[measurement.value as any] = data;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -189,6 +189,7 @@
|
||||
return createTimeSeries({
|
||||
name: s.name,
|
||||
type: props.option.type,
|
||||
smooth: props.option.smooth,
|
||||
area: props.option.background,
|
||||
lineColor: colors?.[0],
|
||||
itemBorderColor: colors?.[1],
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface MetricsChartOption {
|
||||
span?: number;
|
||||
legend?: boolean;
|
||||
background?: boolean;
|
||||
smooth?: boolean;
|
||||
colors: Array<[string, string]>;
|
||||
aggregate: string;
|
||||
unit: MetricUnitType;
|
||||
|
||||
Reference in New Issue
Block a user