mirror of
https://github.com/dromara/hertzbeat.git
synced 2026-09-17 09:40:58 +00:00
[bugfix] Remove broken Push Style Monitor (app-push) support (#4339)
Co-authored-by: aias00 <liuhongyu@apache.org>
This commit is contained in:
co-authored by
aias00
parent
6671f4603b
commit
dffb38b4c5
-8
@@ -69,14 +69,6 @@ public class AppController {
|
||||
return ResponseUtil.handle(() -> appService.getAppParamDefines(app.toLowerCase()));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{monitorId}/pushdefine")
|
||||
@Operation(summary = "The definition structure of the specified monitoring type according to the push query",
|
||||
description = "The definition structure of the specified monitoring type according to the push query")
|
||||
public ResponseEntity<Message<Job>> queryPushDefine(
|
||||
@Parameter(description = "en: Monitoring type name", example = "api") @PathVariable("monitorId") final Long monitorId) {
|
||||
return ResponseUtil.handle(() -> appService.getPushDefine(monitorId));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{monitorId}/define/dynamic")
|
||||
@Operation(summary = "The definition structure of the specified monitoring type according to the push query",
|
||||
description = "The definition structure of the specified monitoring type according to the push query")
|
||||
|
||||
@@ -37,8 +37,6 @@ public interface AppService {
|
||||
*/
|
||||
List<ParamDefineInfo> getAppParamDefines(String app);
|
||||
|
||||
Job getPushDefine(Long monitorId);
|
||||
|
||||
/**
|
||||
* get auto generate dynamic template define
|
||||
* for prometheus and more type
|
||||
|
||||
-31
@@ -22,14 +22,11 @@ import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hertzbeat.collector.dispatch.DispatchConstants;
|
||||
import org.apache.hertzbeat.collector.util.CollectUtil;
|
||||
import org.apache.hertzbeat.common.entity.job.Configmap;
|
||||
import org.apache.hertzbeat.common.entity.job.Job;
|
||||
import org.apache.hertzbeat.common.entity.job.Metrics;
|
||||
import org.apache.hertzbeat.common.entity.job.RuntimeParamDefine;
|
||||
import org.apache.hertzbeat.common.entity.manager.Define;
|
||||
import org.apache.hertzbeat.common.entity.manager.Monitor;
|
||||
import org.apache.hertzbeat.common.entity.manager.Param;
|
||||
import org.apache.hertzbeat.common.entity.message.CollectRep;
|
||||
import org.apache.hertzbeat.common.util.CommonUtil;
|
||||
import org.apache.hertzbeat.common.util.HertzBeatKeywordsUtil;
|
||||
@@ -87,8 +84,6 @@ import static java.util.Objects.isNull;
|
||||
@Slf4j
|
||||
public class AppServiceImpl implements AppService, InitializingBean {
|
||||
|
||||
private static final String PUSH_PROTOCOL_METRICS_NAME = "metrics";
|
||||
|
||||
private final MonitorDao monitorDao;
|
||||
private final ObjectStoreConfigServiceImpl objectStoreConfigService;
|
||||
private final ParamDao paramDao;
|
||||
@@ -131,29 +126,6 @@ public class AppServiceImpl implements AppService, InitializingBean {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Job getPushDefine(Long monitorId) throws IllegalArgumentException {
|
||||
Job appDefine = appDefines.get(DispatchConstants.PROTOCOL_PUSH);
|
||||
if (appDefine == null) {
|
||||
throw new IllegalArgumentException("The push collector not support.");
|
||||
}
|
||||
List<Metrics> metrics = appDefine.getMetrics();
|
||||
List<Metrics> metricsTmp = new ArrayList<>();
|
||||
for (Metrics metric : metrics) {
|
||||
if (PUSH_PROTOCOL_METRICS_NAME.equals(metric.getName())) {
|
||||
List<Param> params = paramDao.findParamsByMonitorId(monitorId);
|
||||
List<Configmap> configmaps = params.stream()
|
||||
.map(param -> new Configmap(param.getField(), param.getParamValue(),
|
||||
param.getType())).toList();
|
||||
Map<String, Configmap> configmap = configmaps.stream().collect(Collectors.toMap(Configmap::getKey, item -> item, (key1, key2) -> key1));
|
||||
CollectUtil.replaceFieldsForPushStyleMonitor(metric, configmap);
|
||||
metricsTmp.add(metric);
|
||||
}
|
||||
}
|
||||
appDefine.setMetrics(metricsTmp);
|
||||
return appDefine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Job getAutoGenerateDynamicDefine(Long monitorId) {
|
||||
Job job = getAppDefine(DispatchConstants.PROTOCOL_PROMETHEUS);
|
||||
@@ -293,9 +265,6 @@ public class AppServiceImpl implements AppService, InitializingBean {
|
||||
public List<Hierarchy> getAppHierarchy(String app, String lang) {
|
||||
LinkedList<Hierarchy> hierarchies = new LinkedList<>();
|
||||
Job job = appDefines.get(app.toLowerCase());
|
||||
if (DispatchConstants.PROTOCOL_PUSH.equalsIgnoreCase(job.getApp())) {
|
||||
return hierarchies;
|
||||
}
|
||||
queryAppHierarchy(lang, hierarchies, job);
|
||||
return hierarchies;
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
|
||||
category: __system__
|
||||
# Monitoring application type name (consistent with file name) eg: linux windows tomcat mysql aws...
|
||||
app: push
|
||||
# The app api i18n name
|
||||
name:
|
||||
zh-CN: 推送方式监控
|
||||
en-US: Push Style Monitor
|
||||
ja-JP: プッシュ方法のモニター
|
||||
# Input params define for app api(render web ui by the definition)
|
||||
params:
|
||||
# field-param field key
|
||||
- field: host
|
||||
# name-param field display i18n name
|
||||
name:
|
||||
zh-CN: 推送模块Host
|
||||
en-US: Push Module Host
|
||||
ja-JP: プッシュモジュールのホスト
|
||||
# type-param field type(most mapping the html input type)
|
||||
type: host
|
||||
# required-true or false
|
||||
required: true
|
||||
# field-param field key
|
||||
defaultValue: 127.0.0.1
|
||||
- field: port
|
||||
# name-param field display i18n name
|
||||
name:
|
||||
zh-CN: 端口
|
||||
en-US: Port
|
||||
ja-JP: ポート
|
||||
# type-param field type(most mapping the html input type)
|
||||
type: number
|
||||
# when type is number, range is required
|
||||
range: '[0,65535]'
|
||||
# required-true or false
|
||||
required: true
|
||||
# default value
|
||||
defaultValue: 1157
|
||||
- field: fields
|
||||
# name-param field display i18n name
|
||||
name:
|
||||
zh-CN: 监控数据字段
|
||||
en-US: Metrics fields
|
||||
ja-JP: メトリクスフィールド
|
||||
# type-param field type(most mapping the html input type)
|
||||
type: metrics-field
|
||||
# required-true or false
|
||||
required: true
|
||||
|
||||
# collect metrics config list
|
||||
metrics:
|
||||
# metrics - all
|
||||
- name: metrics
|
||||
i18n:
|
||||
zh-CN: 指标
|
||||
en-US: Metrics
|
||||
ja-JP: メトリクス
|
||||
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
|
||||
# priority 0's metrics is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
|
||||
priority: 0
|
||||
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
|
||||
protocol: push
|
||||
# the config content when protocol is http
|
||||
push:
|
||||
# http host: ipv4 ipv6 domain
|
||||
host: ^_^host^_^
|
||||
# http port
|
||||
port: ^_^port^_^
|
||||
# http uri
|
||||
uri: /api/push
|
||||
-24
@@ -87,30 +87,6 @@ class AppControllerTest {
|
||||
.andReturn();
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryPushDefine() throws Exception {
|
||||
// Data to make
|
||||
Job mockJob = new Job();
|
||||
mockJob.setId(1L);
|
||||
mockJob.setMonitorId(1L);
|
||||
mockJob.setCategory("os");
|
||||
mockJob.setApp("mac");
|
||||
mockJob.setName(new HashMap<>());
|
||||
mockJob.setMetrics(new ArrayList<>());
|
||||
mockJob.setConfigmap(new ArrayList<>());
|
||||
|
||||
|
||||
// The interface is called to return manufactured data
|
||||
Mockito.when(appService.getPushDefine(1L)).thenReturn(mockJob);
|
||||
|
||||
// Request interface
|
||||
this.mockMvc.perform(MockMvcRequestBuilders.get("/api/apps/{monitorId}/pushdefine", 1L))
|
||||
.andExpect(jsonPath("$.code").value((int) CommonConstants.SUCCESS_CODE))
|
||||
.andExpect(jsonPath("$.data.id").value(1))
|
||||
.andExpect(jsonPath("$.data.app").value("mac"))
|
||||
.andReturn();
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryAutoGenerateDynamicAppDefine() throws Exception {
|
||||
// Data to make
|
||||
|
||||
Reference in New Issue
Block a user