Ver Fonte

[manager,webapp] 指标历史数据API定义,去掉instance展示

tomsun28 há 4 anos atrás
pai
commit
01b47ca2a0

+ 0 - 3
manager/src/main/java/com/usthe/manager/component/alerter/DispatchAlarm.java

@@ -10,10 +10,7 @@ import com.usthe.manager.pojo.entity.NoticeReceiver;
 import com.usthe.manager.service.MonitorService;
 import com.usthe.manager.service.NoticeConfigService;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.mail.SimpleMailMessage;
 import org.springframework.mail.javamail.JavaMailSender;

+ 1 - 1
manager/src/main/resources/logback-spring.xml

@@ -70,7 +70,7 @@
 
     <!-- 开发环境配置 -->
     <springProfile name="dev">
-        <root level="DEBUG">
+        <root level="INFO">
             <appender-ref ref="ConsoleAppender"/>
             <appender-ref ref="SystemOutFileAppender"/>
             <appender-ref ref="ErrOutFileAppender"/>

+ 13 - 8
warehouse/src/main/java/com/usthe/warehouse/controller/MetricsDataController.java

@@ -36,14 +36,14 @@ public class MetricsDataController {
     @Autowired
     private RedisDataStorage redisDataStorage;
 
-    @GetMapping("/monitors/{monitorId}/metrics/{metric}")
+    @GetMapping("/monitors/{monitorId}/metrics/{metrics}")
     @ApiOperation(value = "查询监控指标组的指标数据", notes = "查询监控指标组的指标数据")
     public ResponseEntity<Message<MetricsData>> getMetricsData(
             @ApiParam(value = "监控ID", example = "343254354")
             @PathVariable Long monitorId,
             @ApiParam(value = "监控指标组", example = "cpu")
-            @PathVariable String metric) {
-        CollectRep.MetricsData redisData = redisDataStorage.getCurrentMetricsData(monitorId, metric);
+            @PathVariable String metrics) {
+        CollectRep.MetricsData redisData = redisDataStorage.getCurrentMetricsData(monitorId, metrics);
         if (redisData == null) {
             return ResponseEntity.ok().body(new Message<>("query metrics data is empty"));
         }
@@ -66,18 +66,23 @@ public class MetricsDataController {
         }
     }
 
-    @GetMapping("/monitors/{monitorId}/metrics/{metric}/fields/{field}")
+    @GetMapping("/monitors/{monitorId}/metrics/{metricFull}")
     @ApiOperation(value = "查询监控指标组的指定指标的历史数据", notes = "查询监控指标组下的指定指标的历史数据")
     public ResponseEntity<Message<Void>> getMetricHistoryData(
             @ApiParam(value = "监控ID", example = "343254354")
             @PathVariable Long monitorId,
-            @ApiParam(value = "监控指标组", example = "cpu")
-            @PathVariable String metric,
-            @ApiParam(value = "监控指标组指标", example = "343254354")
-            @PathVariable String field,
+            @ApiParam(value = "监控指标全路径", example = "linux.cpu.usage")
+            @PathVariable() String metricFull,
             @ApiParam(value = "查询历史时间段,默认6h-6小时:h-小时, d-天, m-月, y-年", example = "6h")
             @RequestParam(required = false) String history
             ) {
+        String[] names = metricFull.split(".");
+        if (names.length != 3) {
+            throw new IllegalArgumentException("metrics full name: " + metricFull + " is illegal.");
+        }
+        String app = names[0];
+        String metrics = names[1];
+        String metric = names[2];
         return ResponseEntity.ok().body(null);
     }
 }

+ 0 - 2
web-app/src/app/routes/monitor/monitor-data-chart/monitor-data-chart.component.html

@@ -3,13 +3,11 @@
   <nz-table #smallTable nzSize="small" nzNoResult="No Metrics Data" nzFrontPagination="false" [nzData]="valueRows">
     <thead>
     <tr>
-      <th style="text-align: center">instanceId</th>
       <th style="text-align: center" *ngFor="let field of fields">{{field.name}}</th>
     </tr>
     </thead>
     <tbody>
     <tr *ngFor="let valueRow of smallTable.data">
-      <td>{{valueRow.instance || ''}}</td>
       <td *ngFor="let value of valueRow.values">{{ value.origin}}</td>
     </tr>
     </tbody>

+ 0 - 20
web-app/src/app/routes/monitor/monitor-data-chart/monitor-data-chart.component.ts

@@ -1,6 +1,5 @@
 import {Component, Input, OnInit} from '@angular/core';
 import {MonitorService} from "../../../service/monitor.service";
-import {finalize} from "rxjs/operators";
 
 @Component({
   selector: 'app-monitor-data-chart',
@@ -49,23 +48,4 @@ export class MonitorDataChartComponent implements OnInit {
       })
   }
 
-
-  data = [
-    {
-      name: 'John Brown',
-      age: 32,
-      address: 'New York No. 1 Lake Park'
-    },
-    {
-      name: 'Jim Green',
-      age: 42,
-      address: 'London No. 1 Lake Park'
-    },
-    {
-      name: 'Joe Black',
-      age: 32,
-      address: 'Sidney No. 1 Lake Park'
-    }
-  ];
-
 }