parent
7194bef971
commit
231d9c4859
|
@ -32,6 +32,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
import javax.annotation.Resource;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -216,10 +217,10 @@ public class MetricQueryService {
|
|||
|
||||
private void getRequest(Monitor monitor, List<MetricDataRequest> list) {
|
||||
if (CollectionUtils.isNotEmpty(monitor.getMonitorConfig())) {
|
||||
monitor.getMonitorConfig().forEach(c -> {
|
||||
if (StringUtils.isBlank(c.getValue())) {
|
||||
return;
|
||||
}
|
||||
List<MonitorItem> collect = monitor.getMonitorConfig().stream()
|
||||
.filter(c -> StringUtils.isNotBlank(c.getValue())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(collect)) {
|
||||
collect.forEach(c -> {
|
||||
MetricDataRequest request = new MetricDataRequest();
|
||||
String promQL = c.getValue();
|
||||
request.setPromQL(promQL);
|
||||
|
@ -239,6 +240,18 @@ public class MetricQueryService {
|
|||
list.add(request);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Map<String, String> map = MetricQuery.getMetricQueryMap();
|
||||
Set<String> set = map.keySet();
|
||||
set.forEach(s -> {
|
||||
MetricDataRequest request = new MetricDataRequest();
|
||||
String promQL = map.get(s);
|
||||
request.setPromQL(promQL);
|
||||
request.setSeriesName(s);
|
||||
request.setInstance(monitor.getIp() + ":" + monitor.getPort());
|
||||
list.add(request);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public List<Monitor> queryReportResource(String reportId) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<el-col :span="4">
|
||||
<div>
|
||||
<el-select v-model="currentInstance" placeholder="" size="small" style="width: 100%"
|
||||
@change="handleChecked(currentInstance)">
|
||||
@change="getResource(currentInstance)">
|
||||
<el-option
|
||||
v-for="item in instances"
|
||||
:key="item.ip+item.port"
|
||||
|
@ -173,20 +173,22 @@ export default {
|
|||
this.getResource();
|
||||
},
|
||||
methods: {
|
||||
getResource() {
|
||||
getResource(currentInstance) {
|
||||
// this.init = true;
|
||||
if (this.planReportTemplate) {
|
||||
this.instances = this.planReportTemplate.reportResource;
|
||||
this.currentInstance = this.instances[0].ip + ":" + this.instances[0].port;
|
||||
this.currentInstance = currentInstance || this.instances[0].ip + ":" + this.instances[0].port;
|
||||
this.data = this.planReportTemplate.metricData;
|
||||
this.totalOption = this.getOption(this.currentInstance);
|
||||
} else if (this.isShare) {
|
||||
getSharePerformanceMetricQueryResource(this.shareId, this.id).then(response => {
|
||||
this.instances = response.data.data;
|
||||
if (!this.currentInstance) {
|
||||
this.currentInstance = this.instances[0].ip + ":" + this.instances[0].port;
|
||||
this.handleChecked(this.currentInstance);
|
||||
if (currentInstance) {
|
||||
this.currentInstance = currentInstance;
|
||||
} else {
|
||||
this.currentInstance = this.currentInstance || this.instances[0].ip + ":" + this.instances[0].port;
|
||||
}
|
||||
this.handleChecked(this.currentInstance);
|
||||
getSharePerformanceMetricQuery(this.shareId, this.id).then(result => {
|
||||
if (result) {
|
||||
this.data = result.data.data;
|
||||
|
@ -198,10 +200,12 @@ export default {
|
|||
} else {
|
||||
getPerformanceMetricQueryResource(this.id).then(response => {
|
||||
this.instances = response.data.data;
|
||||
if (!this.currentInstance) {
|
||||
this.currentInstance = this.instances[0].ip + ":" + this.instances[0].port;
|
||||
this.handleChecked(this.currentInstance);
|
||||
if (currentInstance) {
|
||||
this.currentInstance = currentInstance;
|
||||
} else {
|
||||
this.currentInstance = this.currentInstance || this.instances[0].ip + ":" + this.instances[0].port;
|
||||
}
|
||||
this.handleChecked(this.currentInstance);
|
||||
getPerformanceMetricQuery(this.id).then(result => {
|
||||
if (result) {
|
||||
this.data = result.data.data;
|
||||
|
@ -223,6 +227,10 @@ export default {
|
|||
this.checkList.push(mc.name);
|
||||
return {key: mc.name, label: mc.name,};
|
||||
});
|
||||
if (this.checkList.length === 0) {
|
||||
this.checkList = checkList;
|
||||
this.checkOptions = checkOptions;
|
||||
}
|
||||
} else {
|
||||
this.checkOptions = checkOptions;
|
||||
this.checkList = checkList;
|
||||
|
|
Loading…
Reference in New Issue