Compare commits

..
Author SHA1 Message Date
Calvin a22023a663 Merge branch 'master' into theme-update 2025-08-22 22:06:39 +08:00
tomsun28 d40d130dc6 Merge branch 'master' into theme-update 2025-08-20 00:24:23 +08:00
tomsun28 65a522ea9b [webapp] update ui
Signed-off-by: tomsun28 <tomsun28@outlook.com>
2025-08-20 00:23:57 +08:00
Calvin 3ef635c977 Merge branch 'master' into theme-update 2025-08-19 23:27:34 +08:00
tomsun28 14b53fc1f4 [webapp] update ui
Signed-off-by: tomsun28 <tomsun28@outlook.com>
2025-08-19 23:22:14 +08:00
tomsun28 330387734f [webapp] update ui
Signed-off-by: tomsun28 <tomsun28@outlook.com>
2025-08-19 21:52:50 +08:00
tomsun28 7af77c9b86 [webapp] update ui
Signed-off-by: tomsun28 <tomsun28@outlook.com>
2025-08-19 21:43:12 +08:00
tomsun28 0be1f2d1ef [webapp] update ui
Signed-off-by: tomsun28 <tomsun28@outlook.com>
2025-08-19 21:26:21 +08:00
tomsun28 87e6dae115 [webapp] update ui
Signed-off-by: tomsun28 <tomsun28@outlook.com>
2025-08-17 19:25:10 +08:00
tomsun28 1c45cfe14e [webapp] update ui
Signed-off-by: tomsun28 <tomsun28@outlook.com>
2025-08-17 18:53:03 +08:00
337 changed files with 1989 additions and 9899 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
#
github:
description: Real-time observability system with agentless, performance cluster, prometheus-compatible, custom monitoring and status page building capabilities.
description: Real-time monitoring system with agentless, performance cluster, prometheus-compatible, custom monitoring and status page building capabilities.
homepage: https://hertzbeat.apache.org/
labels:
- monitoring
-1
View File
@@ -67,7 +67,6 @@ header:
- 'karma.conf.js'
- 'proxy.conf.js'
- '.helmignore'
- 'script/helm/**'
- 'web-app/src/app/core/**'
- 'web-app/src/app/layout/**'
- 'web-app/src/app/routes/exception/**'
+1 -1
View File
@@ -1,4 +1,4 @@
Apache HertzBeat
Apache HertzBeat
Copyright 2024-2025 The Apache Software Foundation
This product includes software developed at
+4 -4
View File
@@ -9,7 +9,7 @@
<b><a href="README.md">English</a></b> | <a href="README_CN.md">中文</a> | <a href="README_JP.md">日本語</a>
</p>
> A real-time observability system with agentless, performance cluster, prometheus-compatible, custom monitoring and status page building capabilities.
> A real-time monitoring system with agentless, performance cluster, prometheus-compatible, custom monitoring and status page building capabilities.
[![Discord](https://img.shields.io/badge/Chat-Discord-7289DA?logo=discord)](https://discord.gg/Fb6M73htGr)
[![Reddit](https://img.shields.io/badge/Reddit-Community-7289DA?logo=reddit)](https://www.reddit.com/r/hertzbeat/)
@@ -28,7 +28,7 @@
## 🎡 <font color="green">Introduction</font>
[Apache HertzBeat](https://github.com/apache/hertzbeat) is an easy-to-use, open source, real-time observability system with agentless, high performance cluster, prometheus-compatible, offers powerful custom monitoring and status page building capabilities.
[Apache HertzBeat](https://github.com/apache/hertzbeat) is an easy-to-use, open source, real-time monitoring system with agentless, high performance cluster, prometheus-compatible, offers powerful custom monitoring and status page building capabilities.
### Features
@@ -572,8 +572,8 @@ HertzBeat is built on so many great open source projects, thanks to them!
<p align="left">
<img src="./home/static/img/home/cncf-landscape-left-logo.svg" width="300">&nbsp;&nbsp;<img src="./home/static/img/home/cncf-right-logo.svg" width="345" />
<br /><br />
HertzBeat has been included in the <a href="https://landscape.cncf.io/?item=observability-and-analysis--observability--hertzbeat">
CNCF Observability And Analysis - Observability Landscape.</a>
HertzBeat has been included in the <a href="https://landscape.cncf.io/guide?item=observability-and-analysis--monitoring--hertzbeat#observability-and-analysis--monitoring">
CNCF Observability And Analysis - Monitoring Landscape.</a>
</p>
## 🛡️ License
+4 -4
View File
@@ -9,7 +9,7 @@
<a href="README.md">English</a> | <b><a href="README_CN.md">中文</a></b> | <a href="README_JP.md">日本語</a>
</p>
> 实时观测系统,无需 Agent,性能集群,兼容 Prometheus,自定义监控和状态页构建能力。
> 实时监控系统,无需 Agent,性能集群,兼容 Prometheus,自定义监控和状态页构建能力。
[![Discord](https://img.shields.io/badge/Chat-Discord-7289DA?logo=discord)](https://discord.gg/Fb6M73htGr)
[![Reddit](https://img.shields.io/badge/Reddit-Community-7289DA?logo=reddit)](https://www.reddit.com/r/hertzbeat/)
@@ -28,7 +28,7 @@
## 🎡 <font color="green">介绍</font>
[Apache HertzBeat](https://github.com/apache/hertzbeat) 是一个易用友好的开源实时监控告警系统,无需 Agent,高性能集群,兼容 Prometheus,提供强大的自定义监控和状态页构建能力。
[Apache HertzBeat](https://github.com/apache/hertzbeat) 是一个易用友好的开源实时监控告警系统,无需 Agent,高性能集群,兼容 Prometheus,提供强大的自定义监控和状态页构建能力。
### 特点
@@ -572,8 +572,8 @@ HertzBeat is built on so many great open source projects, thanks to them!
<p align="left">
<img src="./home/static/img/home/cncf-landscape-left-logo.svg" width="300">&nbsp;&nbsp;<img src="./home/static/img/home/cncf-right-logo.svg" width="345" />
<br /><br />
HertzBeat has been included in the <a href="https://landscape.cncf.io/?item=observability-and-analysis--observability--hertzbeat">
CNCF Observability And Analysis - Observability Landscape.</a>
HertzBeat has been included in the <a href="https://landscape.cncf.io/guide?item=observability-and-analysis--monitoring--hertzbeat#observability-and-analysis--monitoring">
CNCF Observability And Analysis - Monitoring Landscape.</a>
</p>
## 🛡️ License
+2 -2
View File
@@ -576,8 +576,8 @@ HertzBeat is built on so many great open source projects, thanks to them!
<p align="left">
<img src="./home/static/img/home/cncf-landscape-left-logo.svg" width="300">&nbsp;&nbsp;<img src="./home/static/img/home/cncf-right-logo.svg" width="345" />
<br /><br />
HertzBeat has been included in the <a href="https://landscape.cncf.io/?item=observability-and-analysis--observability--hertzbeat">
CNCF Observability And Analysis - Observability Landscape.</a>
HertzBeat has been included in the <a href="https://landscape.cncf.io/guide?item=observability-and-analysis--monitoring--hertzbeat#observability-and-analysis--monitoring">
CNCF Observability And Analysis - Monitoring Landscape.</a>
</p>
## 🛡️ License
+3 -3
View File
@@ -1,6 +1,6 @@
# Security Policy
Apache HertzBeat follows the [ASF vulnerability handling process](https://apache.org/security/#vulnerability-handling)
Apache HertzBeat follows the [ASF vulnerability handling process](https://apache.org/security/#vulnerability-handling)
## Supported Versions
@@ -17,6 +17,6 @@ To report a new vulnerability you have discovered please follow the [ASF vulnera
## Extra Information
- [Apache HertzBeat Security Model](https://hertzbeat.apache.org/docs/help/security_model)
- [Apache HertzBeat Security Model](https://hertzbeat.apache.org/docs/help/security_model)
- [ASF Security](https://www.apache.org/security/)
- [Apache HertzBeat Document](https://hertzbeat.apache.org/docs/)
- [Apache HertzBeat Document](https://hertzbeat.apache.org/docs/)
@@ -60,7 +60,7 @@ public class ServerChanAlertNotifyHandlerImpl extends AbstractAlertNotifyHandler
String webHookUrl = String.format(alerterProperties.getServerChanWebhookUrl(), sanitizedToken);
// Validate the constructed URL against a whitelist
List<String> allowedBaseUrls = List.of("https://api.serverchan.com", "https://serverchan.example.com", "https://sctapi.ftqq.com");
List<String> allowedBaseUrls = List.of("https://api.serverchan.com", "https://serverchan.example.com");
boolean isValidUrl = allowedBaseUrls.stream().anyMatch(webHookUrl::startsWith);
if (!isValidUrl) {
throw new AlertNoticeException("Invalid webhook URL: " + webHookUrl);
@@ -640,13 +640,11 @@ public class HttpCollectImpl extends AbstractCollect {
.collect(Collectors.toMap(MetricFamily.Label::getName, MetricFamily.Label::getValue));
CollectRep.ValueRow.Builder valueRowBuilder = CollectRep.ValueRow.newBuilder();
for (String aliasField : aliasFields) {
String columnValue = labelMap.get(aliasField);
if (columnValue != null) {
valueRowBuilder.addColumn(columnValue);
} else if (CommonConstants.PROM_VALUE.equals(aliasField) || CommonConstants.PROM_METRIC_VALUE.equals(aliasField)) {
if ("value".equals(aliasField)) {
valueRowBuilder.addColumn(String.valueOf(metric.getValue()));
} else {
valueRowBuilder.addColumn(CommonConstants.NULL_VALUE);
String columnValue = labelMap.get(aliasField);
valueRowBuilder.addColumn(columnValue == null ? CommonConstants.NULL_VALUE : columnValue);
}
}
builder.addValueRow(valueRowBuilder.build());
@@ -60,7 +60,7 @@ public class PrometheusMatrixParser extends AbstractPrometheusParse {
boolean setValueFlag = false;
CollectRep.ValueRow.Builder valueRowBuilder = CollectRep.ValueRow.newBuilder();
for (String aliasField : aliasFields) {
if (!CollectUtil.assertPromRequireField(aliasField) || CollectUtil.isValueAsLabel(aliasField, r.getMetric())) {
if (!CollectUtil.assertPromRequireField(aliasField)) {
JsonElement jsonElement = r.getMetric().get(aliasField);
if (jsonElement != null) {
valueRowBuilder.addColumn(jsonElement.getAsString());
@@ -93,6 +93,7 @@ public class PrometheusMatrixParser extends AbstractPrometheusParse {
}
builder.addValueRow(valueRowBuilder.build());
}
}
}
}
@@ -59,7 +59,7 @@ public class PrometheusVectorParser extends AbstractPrometheusParse {
for (PromVectorOrMatrix.Result r : result) {
CollectRep.ValueRow.Builder valueRowBuilder = CollectRep.ValueRow.newBuilder();
for (String aliasField : aliasFields) {
if (!CollectUtil.assertPromRequireField(aliasField) || CollectUtil.isValueAsLabel(aliasField, r.getMetric())) {
if (!CollectUtil.assertPromRequireField(aliasField)) {
JsonElement jsonElement = r.getMetric().get(aliasField);
if (jsonElement != null) {
valueRowBuilder.addColumn(jsonElement.getAsString());
@@ -0,0 +1,308 @@
/*
* 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.
*/
package org.apache.hertzbeat.collector.collect.prometheus;
import lombok.extern.slf4j.Slf4j;
import org.apache.hertzbeat.collector.collect.common.http.CommonHttpClient;
import org.apache.hertzbeat.collector.dispatch.DispatchConstants;
import org.apache.hertzbeat.collector.util.CollectUtil;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.constants.NetworkConstants;
import org.apache.hertzbeat.common.constants.SignConstants;
import org.apache.hertzbeat.common.entity.job.Metrics;
import org.apache.hertzbeat.common.entity.job.protocol.PrometheusProtocol;
import org.apache.hertzbeat.common.entity.message.CollectRep;
import org.apache.hertzbeat.common.util.Base64Util;
import org.apache.hertzbeat.common.util.CommonUtil;
import org.apache.hertzbeat.common.util.IpDomainUtil;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpHost;
import org.apache.http.HttpStatus;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.auth.DigestScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ConnectException;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.net.ssl.SSLException;
import static org.apache.hertzbeat.common.constants.SignConstants.RIGHT_DASH;
@Slf4j
public class PrometheusProxyCollectImpl implements PrometheusCollect {
private final Set<Integer> defaultSuccessStatusCodes = Stream.of(HttpStatus.SC_OK, HttpStatus.SC_CREATED,
HttpStatus.SC_ACCEPTED, HttpStatus.SC_MULTIPLE_CHOICES, HttpStatus.SC_MOVED_PERMANENTLY,
HttpStatus.SC_MOVED_TEMPORARILY).collect(Collectors.toSet());
public static final String RAW_TEXT_CONTENT_FIELD_NAME = "raw_text_content";
@Override
public List<CollectRep.MetricsData> collect(CollectRep.MetricsData.Builder builder, Metrics metrics) {
PrometheusProtocol prometheusProtocol = metrics.getPrometheus();
HttpUriRequest request;
try {
validateParams(metrics);
} catch (Exception e) {
builder.setCode(CollectRep.Code.FAIL);
builder.setMsg(e.getMessage());
return Collections.singletonList(builder.build());
}
HttpContext httpContext = createHttpContext(prometheusProtocol);
request = createHttpRequest(prometheusProtocol);
try (CloseableHttpResponse response = CommonHttpClient.getHttpClient().execute(request, httpContext)) {
int statusCode = response.getStatusLine().getStatusCode();
log.debug("Prometheus proxy collect, response status: {}", statusCode);
if (!defaultSuccessStatusCodes.contains(statusCode)) {
builder.setCode(CollectRep.Code.FAIL);
builder.setMsg(NetworkConstants.STATUS_CODE + SignConstants.BLANK + statusCode);
return Collections.singletonList(builder.build());
}
String rawTextContent = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
builder.clearFields();
builder.clearValues();
CollectRep.Field rawDataField = CollectRep.Field.newBuilder()
.setName(RAW_TEXT_CONTENT_FIELD_NAME)
.setType(CommonConstants.TYPE_STRING)
.build();
builder.addField(rawDataField);
CollectRep.ValueRow.Builder valueRowBuilder = CollectRep.ValueRow.newBuilder();
valueRowBuilder.addColumn(rawTextContent);
builder.addValueRow(valueRowBuilder.build());
builder.setCode(CollectRep.Code.SUCCESS);
} catch (ClientProtocolException e1) {
String errorMsg = CommonUtil.getMessageFromThrowable(e1);
log.error("Prometheus proxy collect error: {}. Host: {}, Port: {}", errorMsg, prometheusProtocol.getHost(), prometheusProtocol.getPort(), e1);
builder.setCode(CollectRep.Code.UN_CONNECTABLE);
builder.setMsg(errorMsg);
} catch (UnknownHostException e2) {
String errorMsg = CommonUtil.getMessageFromThrowable(e2);
log.info("Prometheus proxy collect unknown host: {}. Host: {}", errorMsg, prometheusProtocol.getHost(), e2);
builder.setCode(CollectRep.Code.UN_REACHABLE);
builder.setMsg("unknown host:" + errorMsg);
} catch (InterruptedIOException | ConnectException | SSLException e3) {
String errorMsg = CommonUtil.getMessageFromThrowable(e3);
log.info("Prometheus proxy collect connect error: {}. Host: {}, Port: {}", errorMsg, prometheusProtocol.getHost(), prometheusProtocol.getPort(), e3);
builder.setCode(CollectRep.Code.UN_CONNECTABLE);
builder.setMsg(errorMsg);
} catch (IOException e4) {
String errorMsg = CommonUtil.getMessageFromThrowable(e4);
log.info("Prometheus proxy collect IO error: {}. Host: {}, Port: {}", errorMsg, prometheusProtocol.getHost(), prometheusProtocol.getPort(), e4);
builder.setCode(CollectRep.Code.FAIL);
builder.setMsg(errorMsg);
} catch (Exception e) {
String errorMsg = CommonUtil.getMessageFromThrowable(e);
log.error("Prometheus proxy collect unknown error: {}. Host: {}, Port: {}", errorMsg, prometheusProtocol.getHost(), prometheusProtocol.getPort(), e);
builder.setCode(CollectRep.Code.FAIL);
builder.setMsg(errorMsg);
} finally {
if (request != null) {
request.abort();
}
}
return Collections.singletonList(builder.build());
}
@Override
public String supportProtocol() {
return DispatchConstants.PROTOCOL_PROMETHEUS;
}
private void validateParams(Metrics metrics) throws Exception {
if (metrics == null || metrics.getPrometheus() == null) {
throw new Exception("Prometheus collect must has prometheus params");
}
PrometheusProtocol protocol = metrics.getPrometheus();
if (!StringUtils.hasText(protocol.getHost())
|| !StringUtils.hasText(protocol.getPort())) {
throw new Exception("Prometheus collect must has host and port params");
}
if (protocol.getPath() == null
|| !StringUtils.hasText(protocol.getPath())
|| !protocol.getPath().startsWith(RIGHT_DASH)) {
protocol.setPath(protocol.getPath() == null ? RIGHT_DASH : RIGHT_DASH + protocol.getPath().trim());
}
}
/**
* create httpContext
* This method is adapted from PrometheusAutoCollectImpl
* @param protocol prometheus protocol
* @return context
*/
public HttpContext createHttpContext(PrometheusProtocol protocol) {
PrometheusProtocol.Authorization auth = protocol.getAuthorization();
if (auth != null && DispatchConstants.DIGEST_AUTH.equals(auth.getType())) {
HttpClientContext clientContext = new HttpClientContext();
if (StringUtils.hasText(auth.getDigestAuthUsername())
&& StringUtils.hasText(auth.getDigestAuthPassword())) {
CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials =
new UsernamePasswordCredentials(auth.getDigestAuthUsername(), auth.getDigestAuthPassword());
provider.setCredentials(AuthScope.ANY, credentials);
AuthCache authCache = new BasicAuthCache();
HttpHost targetHost = new HttpHost(protocol.getHost(), Integer.parseInt(protocol.getPort()));
authCache.put(targetHost, new DigestScheme());
clientContext.setCredentialsProvider(provider);
clientContext.setAuthCache(authCache);
return clientContext;
}
}
return null;
}
/**
* create http request
* This method is adapted from PrometheusAutoCollectImpl
* @param protocol http params
* @return http uri request
*/
public HttpUriRequest createHttpRequest(PrometheusProtocol protocol) {
RequestBuilder requestBuilder = RequestBuilder.get();
// params
Map<String, String> params = protocol.getParams();
if (params != null && !params.isEmpty()) {
for (Map.Entry<String, String> param : params.entrySet()) {
if (StringUtils.hasText(param.getValue())) {
requestBuilder.addParameter(param.getKey(), param.getValue());
}
}
}
requestBuilder.addHeader(HttpHeaders.CONNECTION, NetworkConstants.KEEP_ALIVE);
requestBuilder.addHeader(HttpHeaders.USER_AGENT, NetworkConstants.USER_AGENT);
// headers The custom request header is overwritten here
Map<String, String> headers = protocol.getHeaders();
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> header : headers.entrySet()) {
if (StringUtils.hasText(header.getValue())) {
requestBuilder.addHeader(CollectUtil.replaceUriSpecialChar(header.getKey()),
CollectUtil.replaceUriSpecialChar(header.getValue()));
}
}
}
if (headers == null || headers.keySet().stream().noneMatch(HttpHeaders.ACCEPT::equalsIgnoreCase)) {
requestBuilder.addHeader(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN_VALUE + ";version=0.0.4,*/*;q=0.1");
}
if (protocol.getAuthorization() != null) {
PrometheusProtocol.Authorization authorization = protocol.getAuthorization();
if (DispatchConstants.BEARER_TOKEN.equalsIgnoreCase(authorization.getType())) {
if (StringUtils.hasText(authorization.getBearerTokenToken())) {
String value = DispatchConstants.BEARER + " " + authorization.getBearerTokenToken();
requestBuilder.addHeader(HttpHeaders.AUTHORIZATION, value);
}
} else if (DispatchConstants.BASIC_AUTH.equals(authorization.getType())) {
if (StringUtils.hasText(authorization.getBasicAuthUsername())
&& StringUtils.hasText(authorization.getBasicAuthPassword())) {
String authStr = authorization.getBasicAuthUsername() + ":" + authorization.getBasicAuthPassword();
String encodedAuth = Base64Util.encode(authStr);
requestBuilder.addHeader(HttpHeaders.AUTHORIZATION, DispatchConstants.BASIC + " " + encodedAuth);
}
}
}
if (StringUtils.hasLength(protocol.getPayload())) {
requestBuilder.setEntity(new StringEntity(protocol.getPayload(), StandardCharsets.UTF_8));
if (headers == null || headers.keySet().stream().noneMatch(HttpHeaders.CONTENT_TYPE::equalsIgnoreCase)) {
requestBuilder.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE);
}
}
String uriPath = CollectUtil.replaceUriSpecialChar(protocol.getPath());
if (IpDomainUtil.isHasSchema(protocol.getHost())) {
requestBuilder.setUri(protocol.getHost() + SignConstants.DOUBLE_MARK + protocol.getPort() + uriPath);
} else {
String ipAddressType = IpDomainUtil.checkIpAddressType(protocol.getHost());
String baseUri = NetworkConstants.IPV6.equals(ipAddressType)
? String.format("[%s]:%s%s", protocol.getHost(), protocol.getPort(), uriPath)
: String.format("%s:%s%s", protocol.getHost(), protocol.getPort(), uriPath);
boolean ssl = Boolean.parseBoolean(protocol.getSsl());
if (ssl) {
requestBuilder.setUri(NetworkConstants.HTTPS_HEADER + baseUri);
} else {
requestBuilder.setUri(NetworkConstants.HTTP_HEADER + baseUri);
}
}
// custom timeout
int timeout = CollectUtil.getTimeout(protocol.getTimeout());
if (timeout > 0) {
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(timeout)
.setSocketTimeout(timeout)
.setConnectionRequestTimeout(timeout)
.setRedirectsEnabled(true)
.build();
requestBuilder.setConfig(requestConfig);
} else {
RequestConfig requestConfig = RequestConfig.custom()
.setRedirectsEnabled(true)
.build();
requestBuilder.setConfig(requestConfig);
}
return requestBuilder.build();
}
/**
* get collect instance
* @return instance
*/
public static PrometheusProxyCollectImpl getInstance() {
return PrometheusProxyCollectImpl.SingleInstance.INSTANCE;
}
/**
* static instance
*/
private static class SingleInstance {
private static final PrometheusProxyCollectImpl INSTANCE = new PrometheusProxyCollectImpl();
}
}
@@ -185,10 +185,6 @@ public class OnlineParser {
stringBuilder.append((char) i);
i = getChar(inputStream);
}
// Skip \r character to handle Windows line endings
if (i == '\r') {
i = getChar(inputStream);
}
return new CharChecker(i);
}
@@ -197,10 +193,6 @@ public class OnlineParser {
while (i >= '0' && i <= '9') {
i = getChar(inputStream);
}
// Skip \r character to handle Windows line endings
if (i == '\r') {
i = getChar(inputStream);
}
return new CharChecker(i);
}
@@ -25,10 +25,7 @@ import org.apache.hertzbeat.common.entity.message.CollectRep;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -292,253 +289,4 @@ class HttpCollectImplTest {
firstRow = capturedRows.get(0);
assertEquals("0.268751364291017", firstRow.getColumns(0));
}
@Test
void testParsePromQlLabelValue() throws Exception {
// Create Prometheus format test data
String prometheusData = """
{
"status": "success",
"data": {
"resultType": "vector",
"result": [
{
"metric": {
"__name__": "taos_cluster_info_first_ep",
"cluster_id": "590779086215866783",
"instance": "host.docker.internal:6043",
"job": "tdengine",
"value": "localhost:6030"
},
"value": [
1756233177.048,
"1"
]
}
]
}
}""";
List<CollectRep.ValueRow> capturedRows = new ArrayList<>();
CollectRep.MetricsData.Builder builder = new CollectRep.MetricsData.Builder() {
@Override
public CollectRep.MetricsData.Builder addValueRow(CollectRep.ValueRow valueRow) {
capturedRows.add(valueRow);
return super.addValueRow(valueRow);
}
@Override
public String getMetrics() {
return "jvm_memory_used_bytes";
}
};
Method parseMethod = HttpCollectImpl.class.getDeclaredMethod(
"parseResponseByPromQl",
String.class,
List.class,
HttpProtocol.class,
CollectRep.MetricsData.Builder.class);
parseMethod.setAccessible(true);
parseMethod.invoke(httpCollectImpl, prometheusData, Lists.newArrayList("cluster_id", "value"), new HttpProtocol(), builder);
// Verify the results
assertEquals(1, capturedRows.size());
CollectRep.ValueRow firstRow = capturedRows.get(0);
assertEquals("590779086215866783", firstRow.getColumns(0));
assertEquals("localhost:6030", firstRow.getColumns(1));
}
@Test
void testParsePromQlMetricValue() throws Exception {
// Create Prometheus format test data
String prometheusData = """
{
"status": "success",
"data": {
"resultType": "vector",
"result": [
{
"metric": {
"__name__": "taos_cluster_info_first_ep",
"cluster_id": "590779086215866783",
"instance": "host.docker.internal:6043",
"job": "tdengine",
"value": "localhost:6030"
},
"value": [
1756233177.048,
"1"
]
}
]
}
}""";
List<CollectRep.ValueRow> capturedRows = new ArrayList<>();
CollectRep.MetricsData.Builder builder = new CollectRep.MetricsData.Builder() {
@Override
public CollectRep.MetricsData.Builder addValueRow(CollectRep.ValueRow valueRow) {
capturedRows.add(valueRow);
return super.addValueRow(valueRow);
}
@Override
public String getMetrics() {
return "jvm_memory_used_bytes";
}
};
Method parseMethod = HttpCollectImpl.class.getDeclaredMethod(
"parseResponseByPromQl",
String.class,
List.class,
HttpProtocol.class,
CollectRep.MetricsData.Builder.class);
parseMethod.setAccessible(true);
parseMethod.invoke(httpCollectImpl, prometheusData, Lists.newArrayList("cluster_id", "value", "metric_value"), new HttpProtocol(), builder);
// Verify the results
assertEquals(1, capturedRows.size());
CollectRep.ValueRow firstRow = capturedRows.get(0);
assertEquals("590779086215866783", firstRow.getColumns(0));
assertEquals("localhost:6030", firstRow.getColumns(1));
assertEquals("1", firstRow.getColumns(2));
}
@Test
void testParsePromQlValue() throws Exception {
// Create Prometheus format test data
String prometheusData = """
{
"status": "success",
"data": {
"resultType": "vector",
"result": [
{
"metric": {
"__name__": "taos_cluster_info_first_ep",
"cluster_id": "590779086215866783",
"instance": "host.docker.internal:6043",
"job": "tdengine"
},
"value": [
1756233177.048,
"1"
]
}
]
}
}""";
List<CollectRep.ValueRow> capturedRows = new ArrayList<>();
CollectRep.MetricsData.Builder builder = new CollectRep.MetricsData.Builder() {
@Override
public CollectRep.MetricsData.Builder addValueRow(CollectRep.ValueRow valueRow) {
capturedRows.add(valueRow);
return super.addValueRow(valueRow);
}
@Override
public String getMetrics() {
return "jvm_memory_used_bytes";
}
};
Method parseMethod = HttpCollectImpl.class.getDeclaredMethod(
"parseResponseByPromQl",
String.class,
List.class,
HttpProtocol.class,
CollectRep.MetricsData.Builder.class);
parseMethod.setAccessible(true);
parseMethod.invoke(httpCollectImpl, prometheusData, Lists.newArrayList("cluster_id", "value"), new HttpProtocol(), builder);
// Verify the results
assertEquals(1, capturedRows.size());
CollectRep.ValueRow firstRow = capturedRows.get(0);
assertEquals("590779086215866783", firstRow.getColumns(0));
assertEquals("1", firstRow.getColumns(1));
}
@Test
void testParsePrometheusLabelValue() throws Exception {
// Create Prometheus format test data
String prometheusData = """
# HELP jvm_memory_used_bytes The amount of used memory in bytes
# TYPE jvm_memory_used_bytes gauge
jvm_memory_used_bytes{area="heap",value="G1 Survivor Space"} 1048576
""";
InputStream inputStream = new ByteArrayInputStream(prometheusData.getBytes(StandardCharsets.UTF_8));
List<CollectRep.ValueRow> capturedRows = new ArrayList<>();
CollectRep.MetricsData.Builder builder = new CollectRep.MetricsData.Builder() {
@Override
public CollectRep.MetricsData.Builder addValueRow(CollectRep.ValueRow valueRow) {
capturedRows.add(valueRow);
return super.addValueRow(valueRow);
}
@Override
public String getMetrics() {
return "jvm_memory_used_bytes";
}
};
Method parseMethod = HttpCollectImpl.class.getDeclaredMethod(
"parseResponseByPrometheusExporter",
InputStream.class,
List.class,
CollectRep.MetricsData.Builder.class);
parseMethod.setAccessible(true);
parseMethod.invoke(httpCollectImpl, inputStream, Lists.newArrayList("area", "value"), builder);
// Verify the results
assertEquals(1, capturedRows.size());
CollectRep.ValueRow firstRow = capturedRows.get(0);
assertEquals("heap", firstRow.getColumns(0));
assertEquals("G1 Survivor Space", firstRow.getColumns(1));
}
@Test
void testParsePrometheus() throws Exception {
// Create Prometheus format test data
String prometheusData = """
# HELP jvm_memory_used_bytes The amount of used memory
# TYPE jvm_memory_used_bytes gauge
jvm_memory_used_bytes{area="heap",id="G1 Eden Space"} 1.63577856E8
jvm_memory_used_bytes{area="heap",id="G1 Old Gen"} 2.7874304E7
jvm_memory_used_bytes{area="heap",id="G1 Survivor Space"} 512032.0
jvm_memory_used_bytes{area="nonheap",id="CodeCache"} 1.460288E7
jvm_memory_used_bytes{area="nonheap",id="Compressed Class Space"} 5844504.0
jvm_memory_used_bytes{area="nonheap",id="Metaspace"} 4.1576344E7
""";
InputStream inputStream = new ByteArrayInputStream(prometheusData.getBytes(StandardCharsets.UTF_8));
List<CollectRep.ValueRow> capturedRows = new ArrayList<>();
CollectRep.MetricsData.Builder builder = new CollectRep.MetricsData.Builder() {
@Override
public CollectRep.MetricsData.Builder addValueRow(CollectRep.ValueRow valueRow) {
capturedRows.add(valueRow);
return super.addValueRow(valueRow);
}
@Override
public String getMetrics() {
return "jvm_memory_used_bytes";
}
};
Method parseMethod = HttpCollectImpl.class.getDeclaredMethod(
"parseResponseByPrometheusExporter",
InputStream.class,
List.class,
CollectRep.MetricsData.Builder.class);
parseMethod.setAccessible(true);
parseMethod.invoke(httpCollectImpl, inputStream, Lists.newArrayList("area", "id"), builder);
// Verify the results
assertEquals(6, capturedRows.size());
CollectRep.ValueRow firstRow = capturedRows.get(0);
assertEquals("heap", firstRow.getColumns(0));
assertEquals("G1 Eden Space", firstRow.getColumns(1));
capturedRows.forEach(t -> assertEquals(2, t.getColumnsList().size()));
}
}
@@ -105,186 +105,4 @@ class OnlineParserTest {
});
});
}
@Test
void testParseMetricsWithCrLf() throws Exception {
String str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\r\n"
+ "# TYPE go_gc_duration_seconds summary\r\n"
+ "jvm_gc_pause_seconds_count{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 1.0\r\n"
+ "jvm_gc_pause_seconds_sum{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 0.139\r\n";
InputStream inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
Map<String, MetricFamily> metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
MetricFamily metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
MetricFamily metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\r\n"
+ "# TYPE go_gc_duration_seconds summary\r\n"
+ "jvm_gc_pause_seconds_count{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 1.0 1234567890\r\n"
+ "jvm_gc_pause_seconds_sum{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 0.139 1234567890\r\n";
inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
}
@Test
void testParseMetricsWithLf() throws Exception {
String str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\n"
+ "# TYPE go_gc_duration_seconds summary\n"
+ "jvm_gc_pause_seconds_count{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 1.0\n"
+ "jvm_gc_pause_seconds_sum{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 0.139\n";
InputStream inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
Map<String, MetricFamily> metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
MetricFamily metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
MetricFamily metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\n"
+ "# TYPE go_gc_duration_seconds summary\n"
+ "jvm_gc_pause_seconds_count{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 1.0 1234567890\n"
+ "jvm_gc_pause_seconds_sum{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 0.139 1234567890\n";
inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
}
@Test
void testParseMetricsWithoutFinalNewline() throws Exception {
String str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\r\n"
+ "# TYPE go_gc_duration_seconds summary\r\n"
+ "jvm_gc_pause_seconds_count{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 1.0\r\n"
+ "jvm_gc_pause_seconds_sum{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 0.139";
InputStream inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
Map<String, MetricFamily> metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
MetricFamily metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
MetricFamily metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\n"
+ "# TYPE go_gc_duration_seconds summary\n"
+ "jvm_gc_pause_seconds_count{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 1.0\n"
+ "jvm_gc_pause_seconds_sum{action=\"end of major GC\",cause=\"Metadata GC Threshold\",} 0.139";
inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
}
@Test
void testParseMetricsWithEmptyLabelsAndCrLf() throws Exception {
String str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\r\n"
+ "# TYPE go_gc_duration_seconds summary\r\n"
+ "jvm_gc_pause_seconds_count 1.0\r\n"
+ "jvm_gc_pause_seconds_sum{} 0.139";
InputStream inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
Map<String, MetricFamily> metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
MetricFamily metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
MetricFamily metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
}
@Test
void testParseMetricsWithEmptyLabelsAndLf() throws Exception {
String str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\n"
+ "# TYPE go_gc_duration_seconds summary\n"
+ "jvm_gc_pause_seconds_count 1.0\n"
+ "jvm_gc_pause_seconds_sum{} 0.139";
InputStream inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
Map<String, MetricFamily> metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
MetricFamily metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
MetricFamily metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
}
@Test
void testParseMetricsWithMixedLineEndings() throws Exception {
String str = "# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\r\n"
+ "# TYPE go_gc_duration_seconds summary\n"
+ "jvm_gc_pause_seconds_count 1.0\n"
+ "jvm_gc_pause_seconds_sum{} 0.139\r\n";
InputStream inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
Map<String, MetricFamily> metricFamilyMap = OnlineParser.parseMetrics(inputStream);
assertNotNull(metricFamilyMap);
assertEquals(2, metricFamilyMap.values().size());
MetricFamily metricFamily = metricFamilyMap.get("jvm_gc_pause_seconds_count");
assertEquals("jvm_gc_pause_seconds_count", metricFamily.getName());
assertEquals(1.0, metricFamily.getMetricList().get(0).getValue());
MetricFamily metricFamily1 = metricFamilyMap.get("jvm_gc_pause_seconds_sum");
assertEquals("jvm_gc_pause_seconds_sum", metricFamily1.getName());
assertEquals(0.139, metricFamily1.getMetricList().get(0).getValue());
}
}
@@ -345,4 +345,4 @@
</build>
</profile>
</profiles>
</project>
</project>
@@ -1,133 +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.
*/
package org.apache.hertzbeat.collector.dispatch;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.hertzbeat.collector.metrics.HertzBeatMetricsCollector;
import org.apache.hertzbeat.collector.timer.WheelTimerTask;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.job.Job;
import org.apache.hertzbeat.common.entity.job.Metrics;
import org.apache.hertzbeat.common.entity.message.CollectRep;
import org.apache.hertzbeat.common.timer.Timeout;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
/**
*
*/
@Slf4j
@Component
public class CollectTaskTimeoutMonitor {
/**
* Collection task timeout value
*/
private static final long DURATION_TIME = 240_000L;
/**
* Metrics task and start time mapping map
*/
private final Map<String, MetricsTime> metricsTimeoutMonitorMap = new ConcurrentHashMap<>(16);
@Autowired
private HertzBeatMetricsCollector metricsCollector;
private CommonDispatcher commonDispatcher;
public void start(CommonDispatcher commonDispatcher) {
this.commonDispatcher = commonDispatcher;
// monitoring metrics collection task execution timeout
ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setNameFormat("metrics-task-timeout-monitor-%d")
.setDaemon(true)
.build();
ScheduledThreadPoolExecutor scheduledExecutor = new ScheduledThreadPoolExecutor(1, threadFactory);
scheduledExecutor.scheduleWithFixedDelay(this::monitorCollectTaskTimeout, 2, 20, TimeUnit.SECONDS);
}
public void putMetrics(String key, MetricsTime value) {
this.metricsTimeoutMonitorMap.put(key, value);
}
public MetricsTime removeMetrics(String key) {
return this.metricsTimeoutMonitorMap.remove(key);
}
private void monitorCollectTaskTimeout() {
try {
// Detect whether the collection unit of each metrics has timed out for 4 minutes,
// and if it times out, it will be discarded and an exception will be returned.
long deadline = System.currentTimeMillis() - DURATION_TIME;
for (Map.Entry<String, MetricsTime> entry : metricsTimeoutMonitorMap.entrySet()) {
MetricsTime metricsTime = entry.getValue();
if (metricsTime.getStartTime() < deadline) {
// Metrics collection timeout
MetricsTime removedMetricsTime = metricsTimeoutMonitorMap.remove(entry.getKey());
if (removedMetricsTime == null) {
continue;
}
WheelTimerTask timerJob = (WheelTimerTask) metricsTime.getTimeout().task();
Job job = timerJob.getJob();
// timeout metrics
if (metricsCollector != null) {
long duration = System.currentTimeMillis() - removedMetricsTime.getStartTime();
metricsCollector.recordCollectMetrics(job, duration, "timeout");
}
CollectRep.MetricsData metricsData = CollectRep.MetricsData.newBuilder()
.setId(job.getMonitorId())
.setTenantId(job.getTenantId())
.setApp(job.getApp())
.setMetrics(metricsTime.getMetrics().getName())
.setPriority(metricsTime.getMetrics().getPriority())
.setTime(System.currentTimeMillis())
.setCode(CollectRep.Code.TIMEOUT)
.setMsg("collect timeout")
.build();
log.error("[Collect Timeout]: \n{}", metricsData);
if (metricsData.getPriority() == CommonConstants.AVAILABLE_METRICS) {
//todo 使用chain bootstrap
// commonDispatcher.dispatchCollectData(metricsTime.timeout, metricsTime.getMetrics(), metricsData);
}
}
}
} catch (Exception e) {
log.error("[Task Timeout Monitor]-{}.", e.getMessage(), e);
}
}
/**
* Metrics times.
*/
@Data
@AllArgsConstructor
public static class MetricsTime {
private long startTime;
private Metrics metrics;
private Timeout timeout;
}
}
@@ -17,23 +17,13 @@
package org.apache.hertzbeat.collector.dispatch;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gson.Gson;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.context.impl.DefaultContext;
import org.apache.hertzbeat.collector.dispatch.entrance.internal.CollectJobService;
import org.apache.hertzbeat.collector.handler.ChainBootstrap;
import org.apache.hertzbeat.collector.handler.CollectMetricsDataDataStream;
import org.apache.hertzbeat.collector.listener.CalculateFieldsListener;
import org.apache.hertzbeat.collector.listener.MetricsDataDeliveryListener;
import org.apache.hertzbeat.collector.listener.RemoveTimeoutMonitorListener;
import org.apache.hertzbeat.collector.listener.RerunDataStream;
import org.apache.hertzbeat.collector.listener.ResponseJobDataListener;
import org.apache.hertzbeat.collector.listener.ValidateResponseListener;
import org.apache.hertzbeat.collector.metrics.HertzBeatMetricsCollector;
import org.apache.hertzbeat.collector.handler.impl.BatchExecuteTaskChain;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.collector.CollectorMetaData;
import org.apache.hertzbeat.common.timer.Timeout;
import org.apache.hertzbeat.collector.timer.TimerDispatch;
import org.apache.hertzbeat.collector.timer.WheelTimerTask;
@@ -47,18 +37,17 @@ import org.apache.hertzbeat.common.queue.CommonDataQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* Collection task and response data scheduler
@@ -67,6 +56,10 @@ import java.util.stream.Collectors;
@Slf4j
public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatch {
/**
* Collection task timeout value
*/
private static final long DURATION_TIME = 240_000L;
/**
* Trigger sub task max num
*/
@@ -88,14 +81,16 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
* collection data exporter
*/
private final CommonDataQueue commonDataQueue;
/**
* Metrics task and start time mapping map
*/
private final Map<String, MetricsTime> metricsTimeoutMonitorMap;
private final List<UnitConvert> unitConvertList;
private final WorkerPool workerPool;
private final CollectorMetaData metaData;
private final CollectTaskTimeoutMonitor collectTaskTimeoutMonitor;
private final String collectorIdentity;
@Autowired
private HertzBeatMetricsCollector metricsCollector;
@@ -105,24 +100,17 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
CommonDataQueue commonDataQueue,
WorkerPool workerPool,
CollectJobService collectJobService,
List<UnitConvert> unitConvertList,
CollectTaskTimeoutMonitor collectTaskTimeoutMonitor) {
List<UnitConvert> unitConvertList) {
this.commonDataQueue = commonDataQueue;
this.jobRequestQueue = jobRequestQueue;
this.timerDispatch = timerDispatch;
this.unitConvertList = unitConvertList;
this.workerPool = workerPool;
this.metaData = CollectorMetaData.builder()
.identity(collectJobService.getCollectorIdentity())
.mode(collectJobService.getCollectorMode())
.startTime(new Date())
.build();
this.collectTaskTimeoutMonitor = collectTaskTimeoutMonitor;
// this.start();
this.collectTaskTimeoutMonitor.start(this);
this.collectorIdentity = collectJobService.getCollectorIdentity();
this.metricsTimeoutMonitorMap = new ConcurrentHashMap<>(16);
this.start();
}
@Deprecated
public void start() {
try {
// Pull the collection task from the task queue and put it into the thread pool for execution
@@ -150,104 +138,91 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
}
log.info("Thread Interrupted, Shutdown the [metrics-task-dispatcher]");
});
// monitoring metrics collection task execution timeout
ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setNameFormat("metrics-task-timeout-monitor-%d")
.setDaemon(true)
.build();
ScheduledThreadPoolExecutor scheduledExecutor = new ScheduledThreadPoolExecutor(1, threadFactory);
scheduledExecutor.scheduleWithFixedDelay(this::monitorCollectTaskTimeout, 2, 20, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("Common Dispatcher error: {}.", e.getMessage(), e);
}
}
private void monitorCollectTaskTimeout() {
try {
// Detect whether the collection unit of each metrics has timed out for 4 minutes,
// and if it times out, it will be discarded and an exception will be returned.
long deadline = System.currentTimeMillis() - DURATION_TIME;
for (Map.Entry<String, MetricsTime> entry : metricsTimeoutMonitorMap.entrySet()) {
MetricsTime metricsTime = entry.getValue();
if (metricsTime.getStartTime() < deadline) {
// Metrics collection timeout
MetricsTime removedMetricsTime = metricsTimeoutMonitorMap.remove(entry.getKey());
if (removedMetricsTime == null) {
continue;
}
WheelTimerTask timerJob = (WheelTimerTask) metricsTime.getTimeout().task();
Job job = timerJob.getJob();
// timeout metrics
if (metricsCollector != null) {
long duration = System.currentTimeMillis() - removedMetricsTime.getStartTime();
metricsCollector.recordCollectMetrics(job, duration, "timeout");
}
CollectRep.MetricsData metricsData = CollectRep.MetricsData.newBuilder()
.setId(job.getMonitorId())
.setTenantId(job.getTenantId())
.setApp(job.getApp())
.setMetrics(metricsTime.getMetrics().getName())
.setPriority(metricsTime.getMetrics().getPriority())
.setTime(System.currentTimeMillis())
.setCode(CollectRep.Code.TIMEOUT).setMsg("collect timeout").build();
log.error("[Collect Timeout]: \n{}", metricsData);
if (metricsData.getPriority() == 0) {
dispatchCollectData(metricsTime.timeout, metricsTime.getMetrics(), metricsData);
}
}
}
} catch (Exception e) {
log.error("[Task Timeout Monitor]-{}.", e.getMessage(), e);
}
}
@Override
public void dispatchMetricsTask(Timeout timeout) {
// Divide the collection task of a single application into corresponding collection tasks of the metrics under it.
// Put each collect task into the thread pool for scheduling
WheelTimerTask timerTask = (WheelTimerTask) timeout.task();
Job job = timerTask.getJob();
ChainBootstrap bootstrap = constructMetricsCollectTaskChain(job);
//todo context需要划分作用域
bootstrap.addContext(ContextKey.META_DATA, metaData)
.addContext(ContextKey.JOB, job)
.addContext(ContextKey.TIMEOUT, timeout)
.addListener(new CalculateFieldsListener(unitConvertList))
.addListener(new ValidateResponseListener())
.onEachDataStreamComplete(new RemoveTimeoutMonitorListener(collectTaskTimeoutMonitor));
if (job.isCyclic()) {
bootstrap.withWorkerPool(workerPool)
.addListener(new MetricsDataDeliveryListener(commonDataQueue))
.onComplete(new RerunDataStream(timerDispatch));
} else {
bootstrap.addListener(new ResponseJobDataListener(timerDispatch));
}
bootstrap.start();
}
private ChainBootstrap constructMetricsCollectTaskChain(Job job) {
long now = System.currentTimeMillis();
Map<Byte, List<Metrics>> currentCollectMetrics = job.getMetrics().stream()
.filter(metrics -> (now >= metrics.getCollectTime() + metrics.getInterval() * 1000L))
.peek(metric -> {
metric.setCollectTime(now);
// Determine whether to configure aliasFields If not, configure the default
if ((metric.getAliasFields() == null || metric.getAliasFields().isEmpty()) && metric.getFields() != null) {
metric.setAliasFields(metric.getFields().stream().map(Metrics.Field::getField).collect(Collectors.toList()));
}
// Set the default metrics execution priority, if not filled, the default last priority
if (metric.getPriority() == null) {
metric.setPriority(Byte.MAX_VALUE);
}
})
.collect(Collectors.groupingBy(Metrics::getPriority));
// the current collect metrics can not empty, if empty, add a default availability metrics
// due the metric collect is trigger by the previous metric collect
if (currentCollectMetrics.isEmpty()) {
Optional<Metrics> defaultMetricOption = job.getMetrics().stream()
.filter(metric -> metric.getPriority() == CommonConstants.AVAILABLE_METRICS).findFirst();
if (defaultMetricOption.isPresent()) {
Metrics defaultMetric = defaultMetricOption.get();
defaultMetric.setCollectTime(now);
currentCollectMetrics.put(CommonConstants.AVAILABLE_METRICS, Collections.singletonList(defaultMetric));
job.constructPriorMetrics();
Set<Metrics> metricsSet = job.getNextCollectMetrics(null, true);
metricsSet.forEach(metrics -> {
MetricsCollect metricsCollect = new MetricsCollect(metrics, timeout, this,
collectorIdentity, unitConvertList);
jobRequestQueue.addJob(metricsCollect);
if (metrics.getPrometheus() != null) {
metricsTimeoutMonitorMap.put(String.valueOf(job.getId()),
new MetricsTime(System.currentTimeMillis(), metrics, timeout));
} else {
log.error("metrics must has one priority 0 metrics at least.");
metricsTimeoutMonitorMap.put(job.getId() + "-" + metrics.getName(),
new MetricsTime(System.currentTimeMillis(), metrics, timeout));
}
}
ChainBootstrap chainBootstrap = ChainBootstrap.withContext(DefaultContext.newInstance())
.withChain(new BatchExecuteTaskChain<Metrics>());
// order by priority
currentCollectMetrics.keySet().stream()
.sorted()
.forEach(priority -> {
if (job.isCyclic() || isOneTimeJobAndIsAvailableMetrics(job, priority)) {
List<Metrics> metricsList = currentCollectMetrics.get(priority);
CollectMetricsDataDataStream collectHandler = CollectMetricsDataDataStream.builder()
.collectTaskTimeoutMonitor(collectTaskTimeoutMonitor)
.build();
collectHandler.setSourceDataList(metricsList);
chainBootstrap.addDataStream(collectHandler);
}
});
return chainBootstrap;
});
}
private boolean isOneTimeJobAndIsAvailableMetrics(Job job, byte priority) {
return (!job.isCyclic()) && priority == CommonConstants.AVAILABLE_METRICS;
}
@Deprecated
@Override
public void dispatchCollectData(Timeout timeout, Metrics metrics, CollectRep.MetricsData metricsData) {
WheelTimerTask timerJob = (WheelTimerTask) timeout.task();
Job job = timerJob.getJob();
String monitorKey = job.getId() + "-" + metrics.getName();
String monitorKey;
if (metrics.isHasSubTask()) {
monitorKey = monitorKey + "-sub-" + metrics.getSubTaskId();
monitorKey = job.getId() + "-" + metrics.getName() + "-sub-" + metrics.getSubTaskId();
} else {
monitorKey = job.getId() + "-" + metrics.getName();
}
CollectTaskTimeoutMonitor.MetricsTime metricsTime = this.collectTaskTimeoutMonitor.removeMetrics(monitorKey);
MetricsTime metricsTime = metricsTimeoutMonitorMap.remove(monitorKey);
// job completed metrics
if (metricsTime != null && metricsCollector != null) {
@@ -263,28 +238,31 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
return;
}
}
Set<Metrics> metricsSet = job.getNextCollectMetrics(metrics, false);
if (job.isCyclic()) {
cyclicJobDebugLog(job, metricsData);
if (log.isDebugEnabled()) {
log.debug("Cyclic Job: {} - {} - {}", job.getMonitorId(), job.getApp(), metricsData.getMetrics());
for (CollectRep.ValueRow valueRow : metricsData.getValues()) {
for (CollectRep.Field field : metricsData.getFields()) {
log.debug("Field-->{},Value-->{}", field.getName(), valueRow.getColumns(metricsData.getFields().indexOf(field)));
}
}
}
// If metricsSet is null, it means that the execution is completed or whether the priority of the collection metrics is 0, that is, the availability collection metrics.
// If the availability collection fails, the next metrics scheduling will be cancelled and the next round of scheduling will be entered directly.
boolean isAvailableCollectFailed = metricsSet != null && !metricsSet.isEmpty()
&& metrics.getPriority() == CommonConstants.AVAILABLE_METRICS && metricsData.getCode() != CollectRep.Code.SUCCESS;
&& metrics.getPriority() == (byte) 0 && metricsData.getCode() != CollectRep.Code.SUCCESS;
if (metricsSet == null || isAvailableCollectFailed || job.isSd()) {
// The collection and execution task of this job are completed.
// The periodic task pushes the task to the time wheel again.
// First, determine the execution time of the task and the task collection interval.
if (!timeout.isCancelled()) {
long spendTime = System.currentTimeMillis() - job.getDispatchTime();
long interval = job.getInterval() - spendTime / 1000L;
long interval = job.getInterval() - spendTime / 1000;
interval = interval <= 0 ? 0 : interval;
timerDispatch.cyclicJob(timerJob, interval, TimeUnit.SECONDS);
}
}
else if (!metricsSet.isEmpty()) {
} else if (!metricsSet.isEmpty()) {
// The execution of the current level metrics is completed, and the execution of the next level metrics starts
// use pre collect metrics data to replace next metrics config params
List<Map<String, Configmap>> configmapList = CollectUtil.getConfigmapFromPreCollectData(metricsData);
@@ -295,15 +273,12 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
Set<String> cryPlaceholderFields = CollectUtil.matchCryPlaceholderField(GSON.toJsonTree(metricItem));
if (cryPlaceholderFields.isEmpty()) {
MetricsCollect metricsCollect = new MetricsCollect(metricItem, timeout, this,
metaData.getIdentity(), unitConvertList);
collectorIdentity, unitConvertList);
jobRequestQueue.addJob(metricsCollect);
this.collectTaskTimeoutMonitor.putMetrics(job.getId() + "-" + metricItem.getName(),
new CollectTaskTimeoutMonitor.MetricsTime(System.currentTimeMillis(), metricItem, timeout));
metricsTimeoutMonitorMap.put(job.getId() + "-" + metricItem.getName(),
new MetricsTime(System.currentTimeMillis(), metricItem, timeout));
continue;
}
boolean isSubTask = configmapList.stream().anyMatch(map -> map.keySet().stream().anyMatch(cryPlaceholderFields::contains));
int subTaskNum = isSubTask ? Math.min(configmapList.size(), MAX_SUB_TASK_NUM) : 1;
AtomicInteger subTaskNumAtomic = new AtomicInteger(subTaskNum);
@@ -319,30 +294,95 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
metric.setSubTaskId(index);
metric.setSubTaskDataRef(metricsDataReference);
MetricsCollect metricsCollect = new MetricsCollect(metric, timeout, this,
metaData.getIdentity(), unitConvertList);
collectorIdentity, unitConvertList);
jobRequestQueue.addJob(metricsCollect);
this.collectTaskTimeoutMonitor.putMetrics(job.getId() + "-" + metric.getName() + "-sub-" + index,
new CollectTaskTimeoutMonitor.MetricsTime(System.currentTimeMillis(), metric, timeout));
metricsTimeoutMonitorMap.put(job.getId() + "-" + metric.getName() + "-sub-" + index,
new MetricsTime(System.currentTimeMillis(), metric, timeout));
}
}
} else {
// The list of metrics at the current execution level has not been fully executed.
// It needs to wait for the execution of other metrics task of the same level to complete the execution and enter the next level for execution.
}
// If it is an asynchronous periodic cyclic task, directly response the collected data
if (job.isSd()) {
CollectRep.MetricsData sdMetricsData = CollectRep.MetricsData.newBuilder(metricsData).build();
commonDataQueue.sendServiceDiscoveryData(sdMetricsData);
}
commonDataQueue.sendMetricsData(metricsData);
} else {
// If it is a temporary one-time task, you need to wait for the collected data of all metrics task to be packaged and returned.
// Insert the current metrics data into the job for unified assembly
job.addCollectMetricsData(metricsData);
if (log.isDebugEnabled()) {
log.debug("One-time Job: {}", metricsData.getMetrics());
for (CollectRep.ValueRow valueRow : metricsData.getValues()) {
for (CollectRep.Field field : metricsData.getFields()) {
log.debug("Field-->{},Value-->{}", field.getName(), valueRow.getColumns(metricsData.getFields().indexOf(field)));
}
}
}
if (job.isSd() || metricsSet == null) {
// The collection and execution of all metrics of this job are completed
// and the result listener is notified of the combination of all metrics data
timerDispatch.responseSyncJobData(job.getId(), job.getResponseDataTemp());
} else if (!metricsSet.isEmpty()) {
// The execution of the current level metrics is completed, and the execution of the next level metrics starts
metricsSet.forEach(metricItem -> {
MetricsCollect metricsCollect = new MetricsCollect(metricItem, timeout, this,
collectorIdentity, unitConvertList);
jobRequestQueue.addJob(metricsCollect);
metricsTimeoutMonitorMap.put(job.getId() + "-" + metricItem.getName(),
new MetricsTime(System.currentTimeMillis(), metricItem, timeout));
});
} else {
// The list of metrics task at the current execution level has not been fully executed.
// It needs to wait for the execution of other metrics task of the same level to complete the execution and enter the next level for execution.
}
}
}
private void cyclicJobDebugLog(Job job, CollectRep.MetricsData metricsData) {
if (log.isDebugEnabled()) {
log.debug("Cyclic Job: {} - {} - {}", job.getMonitorId(), job.getApp(), metricsData.getMetrics());
metricsDataDebugLog(metricsData);
@Override
public void dispatchCollectData(Timeout timeout, Metrics metrics, List<CollectRep.MetricsData> metricsDataList) {
WheelTimerTask timerJob = (WheelTimerTask) timeout.task();
Job job = timerJob.getJob();
MetricsTime metricsTime = metricsTimeoutMonitorMap.remove(String.valueOf(job.getId()));
if (metricsTime != null && metricsCollector != null) {
long duration = System.currentTimeMillis() - metricsTime.getStartTime();
// For a list, we consider it a success if at least one item is successful.
boolean isSuccess = metricsDataList.stream().anyMatch(item -> item.getCode() == CollectRep.Code.SUCCESS);
metricsCollector.recordCollectMetrics(job, duration, isSuccess ? "success" : "fail");
}
if (job.isCyclic()) {
// The collection and execution of all task of this job are completed.
// The periodic task pushes the task to the time wheel again.
// First, determine the execution time of the task and the task collection interval.
if (!timeout.isCancelled()) {
long spendTime = System.currentTimeMillis() - job.getDispatchTime();
long interval = job.getInterval() - spendTime / 1000;
interval = interval <= 0 ? 0 : interval;
timerDispatch.cyclicJob(timerJob, interval, TimeUnit.SECONDS);
}
// it is an asynchronous periodic cyclic task, directly response the collected data
metricsDataList.forEach(commonDataQueue::sendMetricsData);
} else {
// The collection and execution of all metrics of this job are completed
// and the result listener is notified of the combination of all metrics data
timerDispatch.responseSyncJobData(job.getId(), metricsDataList);
}
}
private void metricsDataDebugLog(CollectRep.MetricsData metricsData) {
for (CollectRep.ValueRow valueRow : metricsData.getValues()) {
for (CollectRep.Field field : metricsData.getFields()) {
log.debug("Field-->{},Value-->{}", field.getName(), valueRow.getColumns(metricsData.getFields().indexOf(field)));
}
}
/**
* Metrics times.
*/
@Data
@AllArgsConstructor
protected static class MetricsTime {
private long startTime;
private Metrics metrics;
private Timeout timeout;
}
}
@@ -129,6 +129,7 @@ public class MetricsCollect implements Runnable, Comparable<MetricsCollect> {
this.newTime = System.currentTimeMillis();
this.timeout = timeout;
this.metrics = metrics;
this.collectorIdentity = collectorIdentity;
WheelTimerTask timerJob = (WheelTimerTask) timeout.task();
Job job = timerJob.getJob();
this.id = job.getMonitorId();
@@ -152,9 +153,327 @@ public class MetricsCollect implements Runnable, Comparable<MetricsCollect> {
@Override
public void run() {
// collectDataDispatch.dispatchCollectData(timeout, metrics, metricsData);
this.startTime = System.currentTimeMillis();
setNewThreadName(id, app, startTime, metrics);
CollectRep.MetricsData.Builder response = CollectRep.MetricsData.newBuilder();
response.setApp(app).setId(id).setTenantId(tenantId)
.setLabels(labels).setAnnotations(annotations).addMetadataAll(metadata);
// for prometheus auto or proxy mode
if (DispatchConstants.PROTOCOL_PROMETHEUS.equalsIgnoreCase(metrics.getProtocol())) {
List<CollectRep.MetricsData> metricsData;
// TODO: Refactor Prometheus metrics collection logic.
// The current implementation for proxy mode and auto mode needs review and potential simplification.
// Consider a more unified approach or clarify the conditions for each mode.
/*
// TODO USE PROXY MODE
if (prometheusProxyMode) {
List<CollectRep.MetricsData> proxyData = PrometheusProxyCollectImpl.getInstance().collect(response, metrics);
List<CollectRep.MetricsData> autoData = PrometheusAutoCollectImpl.getInstance().collect(response, metrics);
metricsData = new LinkedList<>();
if (proxyData != null) {
metricsData.addAll(proxyData);
}
if (autoData != null) {
metricsData.addAll(autoData);
}
} else {
metricsData = PrometheusAutoCollectImpl.getInstance().collect(response, metrics);
}
*/
metricsData = PrometheusAutoCollectImpl.getInstance().collect(response, metrics);
validateResponse(metricsData == null ? null : metricsData.stream().findFirst().orElse(null));
collectDataDispatch.dispatchCollectData(timeout, metrics, metricsData);
return;
}
response.setMetrics(metrics.getName());
// According to the metrics collection protocol, application type, etc.,
// dispatch to the real application metrics collection implementation class
AbstractCollect abstractCollect = CollectStrategyFactory.invoke(metrics.getProtocol());
if (abstractCollect == null) {
log.error("[Dispatcher] - not support this: app: {}, metrics: {}, protocol: {}.",
app, metrics.getName(), metrics.getProtocol());
response.setCode(CollectRep.Code.FAIL);
response.setMsg("not support " + app + ", "
+ metrics.getName() + ", " + metrics.getProtocol());
} else {
try {
abstractCollect.preCheck(metrics);
abstractCollect.collect(response, metrics);
} catch (Exception e) {
String msg = e.getMessage();
if (msg == null && e.getCause() != null) {
msg = e.getCause().getMessage();
}
if (e instanceof IllegalArgumentException) {
log.error("[Metrics PreCheck]: {}.", msg, e);
} else {
log.error("[Metrics Collect]: {}.", msg, e);
}
response.setCode(CollectRep.Code.FAIL);
if (msg != null) {
response.setMsg(msg);
}
}
}
// Alias attribute expression replacement calculation
if (fastFailed()) {
return;
}
calculateFields(metrics, response);
CollectRep.MetricsData metricsData = validateResponse(response);
collectDataDispatch.dispatchCollectData(timeout, metrics, metricsData);
}
/**
* Calculate the real metrics value according to the calculates and aliasFields configuration
*
* @param metrics Metrics configuration
* @param collectData Data collection
*/
public void calculateFields(Metrics metrics, CollectRep.MetricsData.Builder collectData) {
collectData.setPriority(metrics.getPriority());
List<CollectRep.Field> fieldList = new LinkedList<>();
for (Metrics.Field field : metrics.getFields()) {
CollectRep.Field.Builder fieldBuilder = CollectRep.Field.newBuilder();
fieldBuilder.setName(field.getField()).setType(field.getType()).setLabel(field.isLabel());
if (field.getUnit() != null) {
fieldBuilder.setUnit(field.getUnit());
}
fieldList.add(fieldBuilder.build());
}
collectData.addAllFields(fieldList);
List<CollectRep.ValueRow> aliasRowList = collectData.getValuesList();
if (aliasRowList == null || aliasRowList.isEmpty()) {
return;
}
collectData.clearValues();
// Preprocess calculates first
if (metrics.getCalculates() == null) {
metrics.setCalculates(Collections.emptyList());
}
// eg: database_pages=Database pages unconventional mapping
Map<String, String> fieldAliasMap = new HashMap<>(8);
Map<String, JexlExpression> fieldExpressionMap = metrics.getCalculates()
.stream()
.map(cal -> transformCal(cal, fieldAliasMap))
.filter(Objects::nonNull)
.collect(Collectors.toMap(arr -> (String) arr[0], arr -> (JexlExpression) arr[1], (oldValue, newValue) -> newValue));
if (metrics.getUnits() == null) {
metrics.setUnits(Collections.emptyList());
}
Map<String, Pair<String, String>> fieldUnitMap = metrics.getUnits()
.stream()
.map(this::transformUnit)
.filter(Objects::nonNull)
.collect(Collectors.toMap(arr -> (String) arr[0], arr -> (Pair<String, String>) arr[1], (oldValue, newValue) -> newValue));
List<Metrics.Field> fields = metrics.getFields();
List<String> aliasFields = Optional.ofNullable(metrics.getAliasFields()).orElseGet(Collections::emptyList);
Map<String, String> aliasFieldValueMap = new HashMap<>(8);
Map<String, Object> fieldValueMap = new HashMap<>(8);
Map<String, Object> stringTypefieldValueMap = new HashMap<>(8);
Map<String, String> aliasFieldUnitMap = new HashMap<>(8);
CollectRep.ValueRow.Builder realValueRowBuilder = CollectRep.ValueRow.newBuilder();
for (CollectRep.ValueRow aliasRow : aliasRowList) {
for (int aliasIndex = 0; aliasIndex < aliasFields.size(); aliasIndex++) {
String aliasFieldValue = aliasRow.getColumns(aliasIndex);
String aliasField = aliasFields.get(aliasIndex);
if (!CommonConstants.NULL_VALUE.equals(aliasFieldValue)) {
aliasFieldValueMap.put(aliasField, aliasFieldValue);
// whether the alias field is a number
CollectUtil.DoubleAndUnit doubleAndUnit = CollectUtil
.extractDoubleAndUnitFromStr(aliasFieldValue);
if (doubleAndUnit != null && doubleAndUnit.getValue() != null) {
fieldValueMap.put(aliasField, doubleAndUnit.getValue());
if (doubleAndUnit.getUnit() != null) {
aliasFieldUnitMap.put(aliasField, doubleAndUnit.getUnit());
}
} else {
fieldValueMap.put(aliasField, aliasFieldValue);
}
stringTypefieldValueMap.put(aliasField, aliasFieldValue);
} else {
fieldValueMap.put(aliasField, null);
stringTypefieldValueMap.put(aliasField, null);
}
}
for (Metrics.Field field : fields) {
String realField = field.getField();
JexlExpression expression = fieldExpressionMap.get(realField);
String value = null;
String aliasFieldUnit = null;
if (expression != null) {
try {
Map<String, Object> context;
if (CommonConstants.TYPE_STRING == field.getType()) {
context = stringTypefieldValueMap;
} else {
for (Map.Entry<String, String> unitEntry : aliasFieldUnitMap.entrySet()) {
if (expression.getSourceText().contains(unitEntry.getKey())) {
aliasFieldUnit = unitEntry.getValue();
break;
}
}
context = fieldValueMap;
}
// Also executed when valueList is empty, covering pure string assignment expressions
Object objValue = JexlExpressionRunner.evaluate(expression, context);
if (objValue != null) {
value = String.valueOf(objValue);
}
} catch (Exception e) {
log.warn("[calculates execute warning, use original value.] {}", e.getMessage());
value = Optional.ofNullable(fieldValueMap.get(expression.getSourceText()))
.map(String::valueOf)
.orElse(null);
}
} else {
// does not exist then map the alias value
String aliasField = fieldAliasMap.get(realField);
if (aliasField != null) {
value = aliasFieldValueMap.get(aliasField);
} else {
value = aliasFieldValueMap.get(realField);
}
if (value != null) {
final byte fieldType = field.getType();
if (fieldType == CommonConstants.TYPE_NUMBER) {
CollectUtil.DoubleAndUnit doubleAndUnit = CollectUtil
.extractDoubleAndUnitFromStr(value);
final Double tempValue = doubleAndUnit == null ? null : doubleAndUnit.getValue();
value = tempValue == null ? null : String.valueOf(tempValue);
aliasFieldUnit = doubleAndUnit == null ? null : doubleAndUnit.getUnit();
} else if (fieldType == CommonConstants.TYPE_TIME) {
final int tempValue;
value = (tempValue = CommonUtil.parseTimeStrToSecond(value)) == -1 ? null : String.valueOf(tempValue);
}
}
}
Pair<String, String> unitPair = fieldUnitMap.get(realField);
if (aliasFieldUnit != null) {
if (unitPair != null) {
unitPair.setLeft(aliasFieldUnit);
} else if (field.getUnit() != null && !aliasFieldUnit.equalsIgnoreCase(field.getUnit())) {
unitPair = Pair.of(aliasFieldUnit, field.getUnit());
}
}
if (value != null && unitPair != null) {
for (UnitConvert unitConvert : unitConvertList) {
if (unitConvert.checkUnit(unitPair.getLeft()) && unitConvert.checkUnit(unitPair.getRight())) {
value = unitConvert.convert(value, unitPair.getLeft(), unitPair.getRight());
}
}
}
// Handle metrics values that may have units such as 34%, 34Mb, and limit values to 4 decimal places
if (CommonConstants.TYPE_NUMBER == field.getType()) {
value = CommonUtil.parseDoubleStr(value, field.getUnit());
}
if (value == null) {
value = CommonConstants.NULL_VALUE;
}
realValueRowBuilder.addColumn(value);
}
aliasFieldValueMap.clear();
fieldValueMap.clear();
aliasFieldUnitMap.clear();
stringTypefieldValueMap.clear();
CollectRep.ValueRow realValueRow = realValueRowBuilder.build();
realValueRowBuilder.clear();
// apply filter calculation to the real value row
if (!CollectionUtils.isEmpty(metrics.getFilters())) {
Map<String, Object> contextMap = new HashMap<>(8);
for (int i = 0; i < fields.size(); i++) {
Metrics.Field field = fields.get(i);
String value = realValueRow.getColumns(i);
contextMap.put(field.getField(), value);
}
boolean isMatch = false;
for (String filterExpr : metrics.getFilters()) {
try {
JexlExpression expression = JexlExpressionRunner.compile(filterExpr);
if ((Boolean) JexlExpressionRunner.evaluate(expression, contextMap)) {
isMatch = true;
break;
}
} catch (Exception e) {
log.warn("[metrics data row filters execute warning] {}.", e.getMessage());
}
}
if (!isMatch) {
// ignore this data row
continue;
}
}
collectData.addValueRow(realValueRow);
}
}
/**
* @param cal cal
* @param fieldAliasMap field alias map
* @return expr
*/
private Object[] transformCal(String cal, Map<String, String> fieldAliasMap) {
int splitIndex = cal.indexOf("=");
if (splitIndex < 0) {
return null;
}
String field = cal.substring(0, splitIndex).trim();
String expressionStr = cal.substring(splitIndex + 1).trim().replace("\\#", "#");
JexlExpression expression;
try {
expression = JexlExpressionRunner.compile(expressionStr);
} catch (Exception e) {
fieldAliasMap.put(field, expressionStr);
return null;
}
return new Object[]{field, expression};
}
/**
* transform unit
*
* @param unit unit
* @return units
*/
private Object[] transformUnit(String unit) {
int equalIndex = unit.indexOf("=");
int arrowIndex = unit.indexOf("->");
if (equalIndex < 0 || arrowIndex < 0) {
return null;
}
String field = unit.substring(0, equalIndex).trim();
String originUnit = unit.substring(equalIndex + 1, arrowIndex).trim();
String newUnit = unit.substring(arrowIndex + 2).trim();
return new Object[]{field, Pair.of(originUnit, newUnit)};
}
private boolean fastFailed() {
return this.timeout == null || this.timeout.isCancelled();
}
private CollectRep.MetricsData validateResponse(CollectRep.MetricsData.Builder builder) {
long endTime = System.currentTimeMillis();
builder.setTime(endTime);
long runningTime = endTime - startTime;
long allTime = endTime - newTime;
if (startTime - newTime >= WARN_DISPATCH_TIME) {
log.warn("[Collector Dispatch Warn, Dispatch Use {}ms.", startTime - newTime);
}
if (builder.getCode() != CollectRep.Code.SUCCESS) {
log.info("[Collect Failed, Run {}ms, All {}ms] Reason: {}", runningTime, allTime, builder.getMsg());
} else {
log.info("[Collect Success, Run {}ms, All {}ms].", runningTime, allTime);
}
return builder.build();
}
private void validateResponse(CollectRep.MetricsData metricsData) {
if (metricsData == null) {
@@ -1,127 +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.
*/
package org.apache.hertzbeat.collector.handler;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.hertzbeat.collector.collect.AbstractCollect;
import org.apache.hertzbeat.collector.collect.strategy.CollectStrategyFactory;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.constants.ContextStatus;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.dispatch.CollectTaskTimeoutMonitor;
import org.apache.hertzbeat.collector.handler.impl.AbstractBatchDataStream;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.job.Job;
import org.apache.hertzbeat.common.entity.job.Metrics;
import org.apache.hertzbeat.common.entity.message.CollectRep;
import org.apache.hertzbeat.common.timer.Timeout;
@Data
@Slf4j
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class CollectMetricsDataDataStream extends AbstractBatchDataStream<Metrics, CollectRep.MetricsData.Builder> {
private CollectTaskTimeoutMonitor collectTaskTimeoutMonitor;
@Override
public CollectRep.MetricsData.Builder executeWithResponse(Context context, Metrics data) {
// preset start info
context.put(ContextKey.METRICS, data);
Job job = context.get(ContextKey.JOB);
long startTime = context.get(ContextKey.METRICS_COLLECT_START_TIME);
setNewThreadName(job.getMonitorId(), job.getApp(), startTime, data);
Timeout timeout = context.get(ContextKey.TIMEOUT);
String key = data.getPrometheus() != null ? String.valueOf(job.getId()) : job.getId() + "-" + data.getName();
context.put(ContextKey.METRICS_KEY, key);
this.collectTaskTimeoutMonitor.putMetrics(key, new CollectTaskTimeoutMonitor.MetricsTime(startTime, data, timeout));
CollectRep.MetricsData.Builder fetchedData = this.fetchData(job, data);
if (fetchedData.getCode() != CollectRep.Code.SUCCESS && CommonConstants.AVAILABLE_METRICS == data.getPriority()) {
context.setStatus(ContextStatus.TRUNCATE_HANDLER);
}
return fetchedData;
}
private void setNewThreadName(long monitorId, String app, long startTime, Metrics metrics) {
String builder = monitorId + "-" + app + "-" + metrics.getName() + "-" + String.valueOf(startTime).substring(9);
Thread.currentThread().setName(builder);
}
private CollectRep.MetricsData.Builder fetchData(Job job, Metrics metrics) {
CollectRep.MetricsData.Builder response = CollectRep.MetricsData.newBuilder();
response.setApp(job.getApp())
.setId(job.getMonitorId())
.setTenantId(job.getTenantId())
.setLabels(job.getLabels())
.setAnnotations(job.getAnnotations())
.addMetadataAll(job.getMetadata());
//todo transcribe Prometheus to different chain
// for prometheus auto or proxy mode
// if (DispatchConstants.PROTOCOL_PROMETHEUS.equalsIgnoreCase(metrics.getProtocol())) {
// List<CollectRep.MetricsData> metricsData = PrometheusAutoCollectImpl.getInstance().collect(response, metrics);
// validateResponse(metricsData == null ? null : metricsData.stream().findFirst().orElse(null));
// collectDataDispatch.dispatchCollectData(timeout, metrics, metricsData);
// return null;
// }
response.setMetrics(metrics.getName());
// According to the metrics collection protocol, application type, etc.,
// dispatch to the real application metrics collection implementation class
AbstractCollect abstractCollect = CollectStrategyFactory.invoke(metrics.getProtocol());
if (abstractCollect == null) {
log.error("[Dispatcher] - not support this: app: {}, metrics: {}, protocol: {}.", job.getApp(), metrics.getName(), metrics.getProtocol());
response.setCode(CollectRep.Code.FAIL);
response.setMsg("not support " + job.getApp() + ", " + metrics.getName() + ", " + metrics.getProtocol());
return response;
}
try {
abstractCollect.preCheck(metrics);
abstractCollect.collect(response, metrics);
} catch (Exception e) {
String msg = e.getMessage();
if (msg == null && e.getCause() != null) {
msg = e.getCause().getMessage();
}
if (e instanceof IllegalArgumentException) {
log.error("[Metrics PreCheck]: {}.", msg, e);
} else {
log.error("[Metrics Collect]: {}.", msg, e);
}
response.setCode(CollectRep.Code.FAIL);
if (msg != null) {
response.setMsg(msg);
}
}
return response;
}
}
@@ -1,34 +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.
*/
package org.apache.hertzbeat.collector.handler;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.handler.impl.AbstractBatchDataStream;
import org.apache.hertzbeat.common.entity.job.Metrics;
import org.apache.hertzbeat.common.entity.message.CollectRep;
/**
*
*/
public class DynamicSubTaskCollectMetricsDataDataStream extends AbstractBatchDataStream<Metrics, CollectRep.MetricsData.Builder> {
@Override
public CollectRep.MetricsData.Builder executeWithResponse(Context context, Metrics data) {
//todo 动态拆分
return null;
}
}
@@ -1,289 +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.
*/
package org.apache.hertzbeat.collector.listener;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.jexl3.JexlExpression;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.dispatch.unit.UnitConvert;
import org.apache.hertzbeat.collector.handler.ContextBoundListener;
import org.apache.hertzbeat.collector.util.CollectUtil;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.job.Metrics;
import org.apache.hertzbeat.common.entity.message.CollectRep;
import org.apache.hertzbeat.common.util.CommonUtil;
import org.apache.hertzbeat.common.util.JexlExpressionRunner;
import org.apache.hertzbeat.common.util.Pair;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/**
*
*/
@Slf4j
@AllArgsConstructor
public class CalculateFieldsListener implements ContextBoundListener<CollectRep.MetricsData.Builder> {
private List<UnitConvert> unitConvertList;
@Override
public void execute(Context context, CollectRep.MetricsData.Builder data) {
Metrics metrics = context.get(ContextKey.METRICS);
this.calculateFields(metrics, unitConvertList, data);
}
/**
* Calculate the real metrics value according to the calculates and aliasFields configuration
*
* @param metrics Metrics configuration
* @param collectData Data collection
*/
private void calculateFields(Metrics metrics, List<UnitConvert> unitConvertList, CollectRep.MetricsData.Builder collectData) {
collectData.setPriority(metrics.getPriority());
List<CollectRep.Field> fieldList = new LinkedList<>();
for (Metrics.Field field : metrics.getFields()) {
CollectRep.Field.Builder fieldBuilder = CollectRep.Field.newBuilder();
fieldBuilder.setName(field.getField()).setType(field.getType()).setLabel(field.isLabel());
if (field.getUnit() != null) {
fieldBuilder.setUnit(field.getUnit());
}
fieldList.add(fieldBuilder.build());
}
collectData.addAllFields(fieldList);
List<CollectRep.ValueRow> aliasRowList = collectData.getValuesList();
if (aliasRowList == null || aliasRowList.isEmpty()) {
return;
}
collectData.clearValues();
// Preprocess calculates first
if (metrics.getCalculates() == null) {
metrics.setCalculates(Collections.emptyList());
}
// eg: database_pages=Database pages unconventional mapping
Map<String, String> fieldAliasMap = new HashMap<>(8);
Map<String, JexlExpression> fieldExpressionMap = metrics.getCalculates()
.stream()
.map(cal -> transformCal(cal, fieldAliasMap))
.filter(Objects::nonNull)
.collect(Collectors.toMap(arr -> (String) arr[0], arr -> (JexlExpression) arr[1], (oldValue, newValue) -> newValue));
if (metrics.getUnits() == null) {
metrics.setUnits(Collections.emptyList());
}
Map<String, Pair<String, String>> fieldUnitMap = metrics.getUnits()
.stream()
.map(this::transformUnit)
.filter(Objects::nonNull)
.collect(Collectors.toMap(arr -> (String) arr[0], arr -> (Pair<String, String>) arr[1], (oldValue, newValue) -> newValue));
List<Metrics.Field> fields = metrics.getFields();
List<String> aliasFields = Optional.ofNullable(metrics.getAliasFields()).orElseGet(Collections::emptyList);
Map<String, String> aliasFieldValueMap = new HashMap<>(8);
Map<String, Object> fieldValueMap = new HashMap<>(8);
Map<String, Object> stringTypefieldValueMap = new HashMap<>(8);
Map<String, String> aliasFieldUnitMap = new HashMap<>(8);
CollectRep.ValueRow.Builder realValueRowBuilder = CollectRep.ValueRow.newBuilder();
for (CollectRep.ValueRow aliasRow : aliasRowList) {
for (int aliasIndex = 0; aliasIndex < aliasFields.size(); aliasIndex++) {
String aliasFieldValue = aliasRow.getColumns(aliasIndex);
String aliasField = aliasFields.get(aliasIndex);
if (!CommonConstants.NULL_VALUE.equals(aliasFieldValue)) {
aliasFieldValueMap.put(aliasField, aliasFieldValue);
// whether the alias field is a number
CollectUtil.DoubleAndUnit doubleAndUnit = CollectUtil
.extractDoubleAndUnitFromStr(aliasFieldValue);
if (doubleAndUnit != null && doubleAndUnit.getValue() != null) {
fieldValueMap.put(aliasField, doubleAndUnit.getValue());
if (doubleAndUnit.getUnit() != null) {
aliasFieldUnitMap.put(aliasField, doubleAndUnit.getUnit());
}
} else {
fieldValueMap.put(aliasField, aliasFieldValue);
}
stringTypefieldValueMap.put(aliasField, aliasFieldValue);
} else {
fieldValueMap.put(aliasField, null);
stringTypefieldValueMap.put(aliasField, null);
}
}
for (Metrics.Field field : fields) {
String realField = field.getField();
JexlExpression expression = fieldExpressionMap.get(realField);
String value = null;
String aliasFieldUnit = null;
if (expression != null) {
try {
Map<String, Object> context;
if (CommonConstants.TYPE_STRING == field.getType()) {
context = stringTypefieldValueMap;
} else {
for (Map.Entry<String, String> unitEntry : aliasFieldUnitMap.entrySet()) {
if (expression.getSourceText().contains(unitEntry.getKey())) {
aliasFieldUnit = unitEntry.getValue();
break;
}
}
context = fieldValueMap;
}
// Also executed when valueList is empty, covering pure string assignment expressions
Object objValue = JexlExpressionRunner.evaluate(expression, context);
if (objValue != null) {
value = String.valueOf(objValue);
}
} catch (Exception e) {
log.warn("[calculates execute warning, use original value.] {}", e.getMessage());
value = Optional.ofNullable(fieldValueMap.get(expression.getSourceText()))
.map(String::valueOf)
.orElse(null);
}
} else {
// does not exist then map the alias value
String aliasField = fieldAliasMap.get(realField);
if (aliasField != null) {
value = aliasFieldValueMap.get(aliasField);
} else {
value = aliasFieldValueMap.get(realField);
}
if (value != null) {
final byte fieldType = field.getType();
if (fieldType == CommonConstants.TYPE_NUMBER) {
CollectUtil.DoubleAndUnit doubleAndUnit = CollectUtil
.extractDoubleAndUnitFromStr(value);
final Double tempValue = doubleAndUnit == null ? null : doubleAndUnit.getValue();
value = tempValue == null ? null : String.valueOf(tempValue);
aliasFieldUnit = doubleAndUnit == null ? null : doubleAndUnit.getUnit();
} else if (fieldType == CommonConstants.TYPE_TIME) {
final int tempValue;
value = (tempValue = CommonUtil.parseTimeStrToSecond(value)) == -1 ? null : String.valueOf(tempValue);
}
}
}
Pair<String, String> unitPair = fieldUnitMap.get(realField);
if (aliasFieldUnit != null) {
if (unitPair != null) {
unitPair.setLeft(aliasFieldUnit);
} else if (field.getUnit() != null && !aliasFieldUnit.equalsIgnoreCase(field.getUnit())) {
unitPair = Pair.of(aliasFieldUnit, field.getUnit());
}
}
if (value != null && unitPair != null) {
for (UnitConvert unitConvert : unitConvertList) {
if (unitConvert.checkUnit(unitPair.getLeft()) && unitConvert.checkUnit(unitPair.getRight())) {
value = unitConvert.convert(value, unitPair.getLeft(), unitPair.getRight());
}
}
}
// Handle metrics values that may have units such as 34%, 34Mb, and limit values to 4 decimal places
if (CommonConstants.TYPE_NUMBER == field.getType()) {
value = CommonUtil.parseDoubleStr(value, field.getUnit());
}
if (value == null) {
value = CommonConstants.NULL_VALUE;
}
realValueRowBuilder.addColumn(value);
}
aliasFieldValueMap.clear();
fieldValueMap.clear();
aliasFieldUnitMap.clear();
stringTypefieldValueMap.clear();
CollectRep.ValueRow realValueRow = realValueRowBuilder.build();
realValueRowBuilder.clear();
// apply filter calculation to the real value row
if (!CollectionUtils.isEmpty(metrics.getFilters())) {
Map<String, Object> contextMap = new HashMap<>(8);
for (int i = 0; i < fields.size(); i++) {
Metrics.Field field = fields.get(i);
String value = realValueRow.getColumns(i);
contextMap.put(field.getField(), value);
}
boolean isMatch = false;
for (String filterExpr : metrics.getFilters()) {
try {
JexlExpression expression = JexlExpressionRunner.compile(filterExpr);
if ((Boolean) JexlExpressionRunner.evaluate(expression, contextMap)) {
isMatch = true;
break;
}
} catch (Exception e) {
log.warn("[metrics data row filters execute warning] {}.", e.getMessage());
}
}
if (!isMatch) {
// ignore this data row
continue;
}
}
collectData.addValueRow(realValueRow);
}
}
/**
* @param cal cal
* @param fieldAliasMap field alias map
* @return expr
*/
private Object[] transformCal(String cal, Map<String, String> fieldAliasMap) {
int splitIndex = cal.indexOf("=");
if (splitIndex < 0) {
return null;
}
String field = cal.substring(0, splitIndex).trim();
String expressionStr = cal.substring(splitIndex + 1).trim().replace("\\#", "#");
JexlExpression expression;
try {
expression = JexlExpressionRunner.compile(expressionStr);
} catch (Exception e) {
fieldAliasMap.put(field, expressionStr);
return null;
}
return new Object[]{field, expression};
}
/**
* transform unit
*
* @param unit unit
* @return units
*/
private Object[] transformUnit(String unit) {
int equalIndex = unit.indexOf("=");
int arrowIndex = unit.indexOf("->");
if (equalIndex < 0 || arrowIndex < 0) {
return null;
}
String field = unit.substring(0, equalIndex).trim();
String originUnit = unit.substring(equalIndex + 1, arrowIndex).trim();
String newUnit = unit.substring(arrowIndex + 2).trim();
return new Object[]{field, Pair.of(originUnit, newUnit)};
}
}
@@ -1,38 +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.
*/
package org.apache.hertzbeat.collector.listener;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.constants.ContextStatus;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.handler.ContextBoundListener;
import org.apache.hertzbeat.common.timer.Timeout;
/**
*
*/
public class CommonMetricsDataListener<T> implements ContextBoundListener<T> {
@Override
public void execute(Context context, T data) {
Timeout timeout = context.get(ContextKey.TIMEOUT);
if (timeout == null || timeout.isCancelled()) {
context.setStatus(ContextStatus.STOP);
}
}
}
@@ -1,69 +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.
*/
package org.apache.hertzbeat.collector.listener;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.handler.ContextBoundListener;
import org.apache.hertzbeat.common.entity.job.Job;
import org.apache.hertzbeat.common.entity.message.CollectRep;
import org.apache.hertzbeat.common.queue.CommonDataQueue;
/**
* 周期任务专用
*/
@Slf4j
@AllArgsConstructor
public class MetricsDataDeliveryListener implements ContextBoundListener<CollectRep.MetricsData.Builder> {
private CommonDataQueue commonDataQueue;
@Override
public void execute(Context context, CollectRep.MetricsData.Builder data) {
Job job = context.get(ContextKey.JOB);
CollectRep.MetricsData metricsData = data.build();
cyclicJobDebugLog(job, metricsData);
sendToQueue(job, metricsData);
}
private void sendToQueue(Job job, CollectRep.MetricsData metricsData) {
if (job.isSd()) {
CollectRep.MetricsData sdMetricsData = CollectRep.MetricsData.newBuilder(metricsData).build();
commonDataQueue.sendServiceDiscoveryData(sdMetricsData);
}
commonDataQueue.sendMetricsData(metricsData);
}
private void cyclicJobDebugLog(Job job, CollectRep.MetricsData metricsData) {
if (log.isDebugEnabled()) {
log.debug("Cyclic Job: {} - {} - {}", job.getMonitorId(), job.getApp(), metricsData.getMetrics());
metricsDataDebugLog(metricsData);
}
}
private void metricsDataDebugLog(CollectRep.MetricsData metricsData) {
for (CollectRep.ValueRow valueRow : metricsData.getValues()) {
for (CollectRep.Field field : metricsData.getFields()) {
log.debug("Field-->{},Value-->{}", field.getName(), valueRow.getColumns(metricsData.getFields().indexOf(field)));
}
}
}
}
@@ -1,43 +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.
*/
package org.apache.hertzbeat.collector.listener;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.dispatch.CollectTaskTimeoutMonitor;
import org.apache.hertzbeat.collector.handler.ContextBoundListener;
/**
*
*/
@AllArgsConstructor
public class RemoveTimeoutMonitorListener implements ContextBoundListener<Object> {
private CollectTaskTimeoutMonitor collectTaskTimeoutMonitor;
@Override
public void execute(Context context, Object data) {
String metricsKey = context.get(ContextKey.METRICS_KEY);
if (StringUtils.isBlank(metricsKey)) {
return;
}
collectTaskTimeoutMonitor.removeMetrics(metricsKey);
}
}
@@ -1,55 +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.
*/
package org.apache.hertzbeat.collector.listener;
import lombok.AllArgsConstructor;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.handler.ContextBoundDataStream;
import org.apache.hertzbeat.collector.timer.TimerDispatch;
import org.apache.hertzbeat.collector.timer.WheelTimerTask;
import org.apache.hertzbeat.common.entity.job.Job;
import org.apache.hertzbeat.common.timer.Timeout;
import java.util.concurrent.TimeUnit;
/**
* 周期任务专用
*/
@AllArgsConstructor
public class RerunDataStream implements ContextBoundDataStream<Object> {
private TimerDispatch timerDispatch;
@Override
public void execute(Context context, Object data) {
Job job = context.get(ContextKey.JOB);
Timeout timeout = context.get(ContextKey.TIMEOUT);
if (!timeout.isCancelled()) {
long spendTime = System.currentTimeMillis() - job.getDispatchTime();
long interval = job.getInterval() - spendTime / 1000L;
interval = interval <= 0 ? 0 : interval;
timerDispatch.cyclicJob((WheelTimerTask) timeout.task(), interval, TimeUnit.SECONDS);
}
}
@Override
public void whenException(Context context, Object data, Throwable throwable) {
}
}
@@ -1,61 +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.
*/
package org.apache.hertzbeat.collector.listener;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.handler.ContextBoundListener;
import org.apache.hertzbeat.collector.timer.TimerDispatch;
import org.apache.hertzbeat.common.entity.job.Job;
import org.apache.hertzbeat.common.entity.message.CollectRep;
/**
* 一次性任务专用
*/
@Slf4j
@AllArgsConstructor
public class ResponseJobDataListener implements ContextBoundListener<CollectRep.MetricsData.Builder> {
private TimerDispatch timerDispatch;
@Override
public void execute(Context context, CollectRep.MetricsData.Builder data) {
Job job = context.get(ContextKey.JOB);
CollectRep.MetricsData metricsData = data.build();
oneTimeJobDebugLog(metricsData);
timerDispatch.responseSyncJobData(job.getId(), Lists.newArrayList(metricsData));
}
private void oneTimeJobDebugLog(CollectRep.MetricsData metricsData) {
if (log.isDebugEnabled()) {
log.debug("One-time Job: {}", metricsData.getMetrics());
metricsDataDebugLog(metricsData);
}
}
private void metricsDataDebugLog(CollectRep.MetricsData metricsData) {
for (CollectRep.ValueRow valueRow : metricsData.getValues()) {
for (CollectRep.Field field : metricsData.getFields()) {
log.debug("Field-->{},Value-->{}", field.getName(), valueRow.getColumns(metricsData.getFields().indexOf(field)));
}
}
}
}
@@ -1,53 +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.
*/
package org.apache.hertzbeat.collector.listener;
import lombok.extern.slf4j.Slf4j;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.handler.ContextBoundListener;
import org.apache.hertzbeat.common.entity.job.Metrics;
import org.apache.hertzbeat.common.entity.message.CollectRep;
/**
*
* @author Calvin
* @date 9/1/2025
*/
@Slf4j
public class ValidateResponseListener implements ContextBoundListener<CollectRep.MetricsData.Builder> {
@Override
public void execute(Context context, CollectRep.MetricsData.Builder data) {
long startTime = context.get(ContextKey.METRICS_COLLECT_START_TIME);
Metrics metrics = context.get(ContextKey.METRICS);
this.validateResponse(startTime, metrics, data);
}
private void validateResponse(long startTime, Metrics metrics, CollectRep.MetricsData.Builder builder) {
long endTime = System.currentTimeMillis();
builder.setTime(endTime);
long allTime = endTime - startTime;
if (builder.getCode() != CollectRep.Code.SUCCESS) {
log.info("[Metrics: {}][Collect Failed, Run {}ms] Reason: {}", metrics.getName(), allTime, builder.getMsg());
} else {
log.info("[Metrics: {}][Collect Success, Run {}ms].", metrics.getName(), allTime);
}
}
}
@@ -55,7 +55,7 @@ spring:
collector:
info:
version: ${COLLECTOR_VERSION:1.7.3}
version: ${COLLECTOR_VERSION:1.7.2}
ip: ${COLLECTOR_IP:}
dispatch:
entrance:
@@ -1,41 +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.
*/
package org.apache.hertzbeat.collector.constants;
import lombok.Getter;
import org.apache.hertzbeat.common.entity.collector.CollectorMetaData;
import org.apache.hertzbeat.common.entity.job.Job;
import org.apache.hertzbeat.common.entity.job.Metrics;
import org.apache.hertzbeat.common.timer.Timeout;
public enum ContextKey {
META_DATA(CollectorMetaData.class),
JOB(Job.class),
TIMEOUT(Timeout.class),
METRICS_COLLECT_START_TIME(Long.class),
METRICS(Metrics.class),
METRICS_KEY(String.class),
;
@Getter
private final Class<?> clazz;
ContextKey(Class<?> clazz) {
this.clazz = clazz;
}
}
@@ -1,25 +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.
*/
package org.apache.hertzbeat.collector.constants;
/**
*
*/
public enum ContextStatus {
WAITING, RUNNING, STOP, TRUNCATE_HANDLER
}
@@ -1,25 +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.
*/
package org.apache.hertzbeat.collector.constants;
/**
*
*/
public enum HandlerType {
NORMAL, ON_COMPLETE
}
@@ -1,73 +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.
*/
package org.apache.hertzbeat.collector.context;
import lombok.Getter;
import lombok.Setter;
import org.apache.hertzbeat.collector.constants.ContextStatus;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
/**
*
*/
public abstract class AbstractInmemoryContext implements Context {
protected final AtomicReference<ContextStatus> contextStatus = new AtomicReference<>(ContextStatus.WAITING);
protected final Map<Object, Object> map = new ConcurrentHashMap<>();
@Getter
@Setter
private Throwable error;
@Override
public <T> void put(Object key, T value) {
this.map.put(key, value);
}
@Override
public <T> T remove(Object key) {
return (T) this.map.remove(key);
}
@Override
public <T> T get(Object key) {
return (T) this.map.get(key);
}
@Override
public <T> T getOrDefault(Object key, T defaultValue) {
return (T) this.map.getOrDefault(key, defaultValue);
}
@Override
public boolean hasKey(Object key) {
return this.map.containsKey(key);
}
@Override
public ContextStatus getStatus() {
return contextStatus.get();
}
@Override
public void setStatus(ContextStatus status) {
contextStatus.set(status);
}
}
@@ -1,29 +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.
*/
package org.apache.hertzbeat.collector.context;
import org.apache.hertzbeat.collector.constants.ContextStatus;
/**
* 只维护与上下文的元数据
*/
public interface Context extends ContextView, ContextOperation {
ContextStatus getStatus();
void setStatus(ContextStatus status);
}
@@ -1,34 +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.
*/
package org.apache.hertzbeat.collector.context;
import io.micrometer.common.lang.Nullable;
/**
*
*/
public interface ContextOperation {
<T> void put(Object key, T value);
<T> T remove(Object key);
@Nullable
Throwable getError();
void setError(Throwable error);
}
@@ -1,29 +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.
*/
package org.apache.hertzbeat.collector.context;
/**
* 对上下文内容的查询操作
*/
public interface ContextView {
<T> T get(Object key);
<T> T getOrDefault(Object key, T defaultValue);
boolean hasKey(Object key);
}
@@ -1,32 +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.
*/
package org.apache.hertzbeat.collector.context.impl;
import org.apache.hertzbeat.collector.context.AbstractInmemoryContext;
/**
*
*/
public class DefaultContext extends AbstractInmemoryContext {
private DefaultContext() {
}
public static DefaultContext newInstance() {
return new DefaultContext();
}
}
@@ -36,4 +36,13 @@ public interface CollectDataDispatch {
*/
void dispatchCollectData(Timeout timeout, Metrics metrics, CollectRep.MetricsData metricsData);
/**
* Processing and distributing collection result data
*
* @param timeout time wheel timeout
* @param metrics The following metrics collection tasks
* @param metricsDataList Collect result data
*/
void dispatchCollectData(Timeout timeout, Metrics metrics, List<CollectRep.MetricsData> metricsDataList);
}
@@ -1,113 +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.
*/
package org.apache.hertzbeat.collector.handler;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.hertzbeat.collector.constants.HandlerType;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.dispatch.WorkerPool;
import org.apache.hertzbeat.collector.handler.impl.AbstractListenerBoundDataStream;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
@Slf4j
public class ChainBootstrap {
@Setter
private Context context;
private TaskChain<?> taskChain;
private WorkerPool workerPool;
private final List<ContextBoundDataStream> contextBoundDataStreamList = new ArrayList<>();
private final List<ContextBoundDataStream> onCompleteContextBoundDataStreamList = new ArrayList<>();
private final List<ContextBoundListener> dataListenerList = new ArrayList<>();
private final List<ContextBoundListener> onCompleteListenerList = new ArrayList<>();
public static ChainBootstrap withContext(Context context) {
ChainBootstrap bootstrap = new ChainBootstrap();
bootstrap.setContext(context);
return bootstrap;
}
public ChainBootstrap withChain(TaskChain<?> taskChain) {
this.taskChain = taskChain;
return this;
}
public ChainBootstrap withWorkerPool(WorkerPool workerPool) {
this.workerPool = workerPool;
return this;
}
public <T> ChainBootstrap addContext(Object key, T value) {
context.put(key, value);
return this;
}
public ChainBootstrap addDataStream(ContextBoundDataStream contextBoundDataStream) {
contextBoundDataStreamList.add(contextBoundDataStream);
return this;
}
public ChainBootstrap onComplete(ContextBoundDataStream contextBoundDataStream) {
onCompleteContextBoundDataStreamList.add(contextBoundDataStream);
return this;
}
public ChainBootstrap addListener(ContextBoundListener dataListener) {
dataListenerList.add(dataListener);
return this;
}
public ChainBootstrap onEachDataStreamComplete(ContextBoundListener dataListener) {
onCompleteListenerList.add(dataListener);
return this;
}
public void start() {
if (taskChain == null || context == null) {
log.error("Failed to start chain boostrap due to null value of Context or TaskChain");
return;
}
for (ContextBoundDataStream contextBoundDataStream : contextBoundDataStreamList) {
if (contextBoundDataStream instanceof AbstractListenerBoundDataStream listenerBoundHandler) {
if (CollectionUtils.isNotEmpty(dataListenerList)) {
listenerBoundHandler.getDataListenerList().addAll(dataListenerList);
}
if (CollectionUtils.isNotEmpty(onCompleteListenerList)) {
listenerBoundHandler.getOnCompleteListenerList().addAll(onCompleteListenerList);
}
}
taskChain.addLast(HandlerType.NORMAL, contextBoundDataStream);
}
onCompleteContextBoundDataStreamList.forEach(handler -> taskChain.addLast(HandlerType.ON_COMPLETE, handler));
if (workerPool != null) {
workerPool.executeJob(() -> taskChain.execute(context));
} else {
taskChain.execute(context);
}
}
}
@@ -1,29 +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.
*/
package org.apache.hertzbeat.collector.handler;
import org.apache.hertzbeat.collector.context.Context;
/**
*
*/
public interface ContextBoundDataStream<T> {
void execute(Context context, T data);
void whenException(Context context, T data, Throwable throwable);
}
@@ -1,26 +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.
*/
package org.apache.hertzbeat.collector.handler;
import org.apache.hertzbeat.collector.context.Context;
/**
*/
public interface ContextBoundListener<T> {
void execute(Context context, T data);
}
@@ -1,32 +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.
*/
package org.apache.hertzbeat.collector.handler;
import org.apache.hertzbeat.collector.constants.HandlerType;
import org.apache.hertzbeat.collector.context.Context;
/**
*
*/
public interface TaskChain<T> {
void execute(Context context);
void execute(Context context, T data);
void addLast(HandlerType handlerType, ContextBoundDataStream<T> handler);
}
@@ -1,38 +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.
*/
package org.apache.hertzbeat.collector.handler.impl;
import lombok.Setter;
import org.apache.hertzbeat.collector.context.Context;
import java.util.List;
/**
*
*/
public abstract class AbstractBatchDataStream<T, R> extends AbstractListenerBoundDataStream<T, R> {
@Setter
protected List<T> sourceDataList;
@Override
public void execute(Context context, T data) {
for (T t : sourceDataList) {
super.execute(context, t);
}
}
}
@@ -1,43 +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.
*/
package org.apache.hertzbeat.collector.handler.impl;
import org.apache.hertzbeat.collector.constants.HandlerType;
import org.apache.hertzbeat.collector.handler.ContextBoundDataStream;
import org.apache.hertzbeat.collector.handler.TaskChain;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*/
public abstract class AbstractContextBoundTaskChain<T> implements TaskChain<T> {
protected final Map<HandlerType, List<ContextBoundDataStream<T>>> contextBoundHandlerMap = new HashMap<>();
@Override
public void addLast(HandlerType handlerType, ContextBoundDataStream<T> handler) {
if (!contextBoundHandlerMap.containsKey(handlerType)) {
contextBoundHandlerMap.put(handlerType, new ArrayList<>());
}
contextBoundHandlerMap.get(handlerType).add(handler);
}
}
@@ -1,90 +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.
*/
package org.apache.hertzbeat.collector.handler.impl;
import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.hertzbeat.collector.constants.ContextKey;
import org.apache.hertzbeat.collector.constants.ContextStatus;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.handler.ContextBoundDataStream;
import org.apache.hertzbeat.collector.handler.ContextBoundListener;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public abstract class AbstractListenerBoundDataStream<T, R> implements ContextBoundDataStream<T> {
@Getter
private final List<? extends ContextBoundListener<R>> dataListenerList = new ArrayList<>();
@Getter
private final List<? extends ContextBoundListener<R>> onCompleteListenerList = new ArrayList<>();
@Override
public void execute(Context context, T data) {
long startTime = System.currentTimeMillis();
context.put(ContextKey.METRICS_COLLECT_START_TIME, startTime);
R executeResult = executeWithResponse(context, data);
runListener(context, executeResult);
runOnCompleteListener(context, executeResult);
}
public R executeWithResponse(Context context, T data) {
// no-op
return null;
}
@Override
public void whenException(Context context, T data, Throwable throwable) {
// no-op
}
private void runListener(Context context, R executeResult) {
if (CollectionUtils.isEmpty(dataListenerList)) {
return;
}
if (ContextStatus.STOP.equals(context.getStatus())) {
return;
}
//todo 异常处理
for (ContextBoundListener<R> listener : dataListenerList) {
listener.execute(context, executeResult);
if (ContextStatus.STOP.equals(context.getStatus())) {
break;
}
}
}
private void runOnCompleteListener(Context context, R executeResult) {
if (CollectionUtils.isEmpty(onCompleteListenerList)) {
return;
}
for (ContextBoundListener<R> listener : onCompleteListenerList) {
listener.execute(context, executeResult);
}
}
}
@@ -1,63 +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.
*/
package org.apache.hertzbeat.collector.handler.impl;
import org.apache.hertzbeat.collector.constants.ContextStatus;
import org.apache.hertzbeat.collector.constants.HandlerType;
import org.apache.hertzbeat.collector.context.Context;
import org.apache.hertzbeat.collector.handler.ContextBoundDataStream;
import java.util.ArrayList;
/**
*
*/
public class BatchExecuteTaskChain<T> extends AbstractContextBoundTaskChain<T> {
@Override
public void execute(Context context) {
this.execute(context, null);
}
@Override
public void execute(Context context, T data) {
context.setStatus(ContextStatus.RUNNING);
for (ContextBoundDataStream<T> contextBoundDataStream : contextBoundHandlerMap.getOrDefault(HandlerType.NORMAL, new ArrayList<>())) {
runHandler(context, data, contextBoundDataStream);
if (ContextStatus.TRUNCATE_HANDLER.equals(context.getStatus()) || ContextStatus.STOP.equals(context.getStatus())) {
break;
}
// in order to init error info for the next loop
context.setError(null);
}
contextBoundHandlerMap.getOrDefault(HandlerType.ON_COMPLETE, new ArrayList<>()).forEach(handler -> runHandler(context, data, handler));
}
private static <T> void runHandler(Context context, T data, ContextBoundDataStream<T> contextBoundDataStream) {
try {
contextBoundDataStream.execute(context, data);
} catch (Exception exception) {
context.setError(exception);
contextBoundDataStream.whenException(context, data, exception);
}
}
}
@@ -171,16 +171,7 @@ public final class CollectUtil {
* assert prom field
*/
public static Boolean assertPromRequireField(String aliasField) {
return CommonConstants.PROM_TIME.equals(aliasField)
|| CommonConstants.PROM_VALUE.equals(aliasField)
|| CommonConstants.PROM_METRIC_VALUE.equals(aliasField);
}
/**
* Check if "value" field should be treated as a label instead of special field
*/
public static Boolean isValueAsLabel(String aliasField, JsonObject metric) {
return CommonConstants.PROM_VALUE.equals(aliasField) && null != metric && metric.has(aliasField);
return CommonConstants.PROM_TIME.equals(aliasField) || CommonConstants.PROM_VALUE.equals(aliasField);
}
/**
+3
View File
@@ -83,10 +83,13 @@
<groupId>org.apache.hertzbeat</groupId>
<artifactId>hertzbeat-common</artifactId>
</dependency>
</dependencies>
<build>
<finalName>apache-${project.artifactId}-${hzb.version}</finalName>
</build>
</project>
@@ -197,11 +197,6 @@ public interface CommonConstants {
*/
String PROM_VALUE = "value";
/**
* prometheus metric value alias
*/
String PROM_METRIC_VALUE = "metric_value";
/**
* Parameter Type Number
*/
@@ -382,6 +377,4 @@ public interface CommonConstants {
* JEXL custom function `json`
*/
String JEXL_CUSTOM_JSON_FUNCTION = "json";
byte AVAILABLE_METRICS = 0;
}
@@ -1,38 +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.
*/
package org.apache.hertzbeat.common.entity.collector;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
*
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CollectorMetaData {
private String identity;
private String mode;
private Date startTime;
}
@@ -17,14 +17,10 @@
package org.apache.hertzbeat.manager.controller;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.data.domain.Page;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import jakarta.validation.Valid;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.dto.Message;
@@ -41,7 +37,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -54,7 +49,7 @@ public class StatusPageController {
@Autowired
private StatusPageService statusPageService;
@GetMapping("/org")
@Operation(summary = "Query Status Page Organization")
public ResponseEntity<Message<StatusPageOrg>> queryStatusPageOrg() {
@@ -71,35 +66,35 @@ public class StatusPageController {
StatusPageOrg org = statusPageService.saveStatusPageOrg(statusPageOrg);
return ResponseEntity.ok(Message.success(org));
}
@GetMapping("/component")
@Operation(summary = "Query Status Page Components")
public ResponseEntity<Message<List<StatusPageComponent>>> queryStatusPageComponent() {
List<StatusPageComponent> statusPageComponents = statusPageService.queryStatusPageComponents();
return ResponseEntity.ok(Message.success(statusPageComponents));
}
@PostMapping("/component")
@Operation(summary = "Save Status Page Component")
public ResponseEntity<Message<Void>> newStatusPageComponent(@Valid @RequestBody StatusPageComponent statusPageComponent) {
statusPageService.newStatusPageComponent(statusPageComponent);
return ResponseEntity.ok(Message.success("Add success"));
}
@PutMapping("/component")
@Operation(summary = "Update Status Page Component")
public ResponseEntity<Message<Void>> updateStatusPageComponent(@Valid @RequestBody StatusPageComponent statusPageComponent) {
statusPageService.updateStatusPageComponent(statusPageComponent);
return ResponseEntity.ok(Message.success("Update success"));
}
@DeleteMapping("/component/{id}")
@Operation(summary = "Delete Status Page Component")
public ResponseEntity<Message<Void>> deleteStatusPageComponent(@PathVariable("id") final long id) {
statusPageService.deleteStatusPageComponent(id);
return ResponseEntity.ok(Message.success("Delete success"));
}
@GetMapping("/component/{id}")
@Operation(summary = "Query Status Page Component")
public ResponseEntity<Message<StatusPageComponent>> queryStatusPageComponent(@PathVariable("id") final long id) {
@@ -137,13 +132,8 @@ public class StatusPageController {
@GetMapping("/incident")
@Operation(summary = "Query Status Page Incidents")
public ResponseEntity<Message<Page<StatusPageIncident>>> queryStatusPageIncident(
@Parameter(description = "Search-Target", example = "x") @RequestParam(required = false) String search,
@Parameter(description = "Start Time", example = "1756384301907") @RequestParam(required = false) Long startTime,
@Parameter(description = "End Time", example = "1756384301907") @RequestParam(required = false) Long endTime,
@Parameter(description = "List current page", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
@Parameter(description = "Number of list pages", example = "8") @RequestParam(defaultValue = "8") int pageSize) {
Page<StatusPageIncident> incidents = statusPageService.queryStatusPageIncidents(search, startTime, endTime, pageIndex, pageSize);
public ResponseEntity<Message<List<StatusPageIncident>>> queryStatusPageIncident() {
List<StatusPageIncident> incidents = statusPageService.queryStatusPageIncidents();
return ResponseEntity.ok(Message.success(incidents));
}
}
@@ -17,14 +17,10 @@
package org.apache.hertzbeat.manager.controller;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.data.domain.Page;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.dto.Message;
import org.apache.hertzbeat.common.entity.manager.StatusPageIncident;
@@ -36,7 +32,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -49,7 +44,7 @@ public class StatusPagePublicController {
@Autowired
private StatusPageService statusPageService;
@GetMapping("/org")
@Operation(summary = "Query Status Page Organization")
public ResponseEntity<Message<StatusPageOrg>> queryStatusPageOrg() {
@@ -59,14 +54,14 @@ public class StatusPagePublicController {
}
return ResponseEntity.ok(Message.success(statusPageOrg));
}
@GetMapping("/component")
@Operation(summary = "Query Status Page Components")
public ResponseEntity<Message<List<ComponentStatus>>> queryStatusPageComponent() {
List<ComponentStatus> componentStatusList = statusPageService.queryComponentsStatus();
return ResponseEntity.ok(Message.success(componentStatusList));
}
@GetMapping("/component/{id}")
@Operation(summary = "Query Status Page Component")
public ResponseEntity<Message<ComponentStatus>> queryStatusPageComponent(@PathVariable("id") final long id) {
@@ -76,13 +71,8 @@ public class StatusPagePublicController {
@GetMapping("/incident")
@Operation(summary = "Query Status Page Incidents")
public ResponseEntity<Message<Page<StatusPageIncident>>> queryStatusPageIncident(
@Parameter(description = "Search-Target", example = "x") @RequestParam(required = false) String search,
@Parameter(description = "Start Time", example = "1756384301907") @RequestParam(required = false) Long startTime,
@Parameter(description = "End Time", example = "1756384301907") @RequestParam(required = false) Long endTime,
@Parameter(description = "List current page", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
@Parameter(description = "Number of list pages", example = "10") @RequestParam(defaultValue = "10") int pageSize) {
Page<StatusPageIncident> incidents = statusPageService.queryStatusPageIncidents(search, startTime, endTime, pageIndex, pageSize);
public ResponseEntity<Message<List<StatusPageIncident>>> queryStatusPageIncident() {
List<StatusPageIncident> incidents = statusPageService.queryStatusPageIncidents();
return ResponseEntity.ok(Message.success(incidents));
}
}
@@ -18,12 +18,10 @@
package org.apache.hertzbeat.manager.service;
import java.util.List;
import org.apache.hertzbeat.common.entity.manager.StatusPageComponent;
import org.apache.hertzbeat.common.entity.manager.StatusPageIncident;
import org.apache.hertzbeat.common.entity.manager.StatusPageOrg;
import org.apache.hertzbeat.manager.pojo.dto.ComponentStatus;
import org.springframework.data.domain.Page;
/**
* status page service interface.
@@ -32,49 +30,42 @@ public interface StatusPageService {
/**
* query status page organization.
*
* @return status page organization
*/
StatusPageOrg queryStatusPageOrg();
/**
* save status page organization.
*
* @return status page organization
*/
StatusPageOrg saveStatusPageOrg(StatusPageOrg statusPageOrg);
/**
* query status page components.
*
* @return status page components
*/
List<StatusPageComponent> queryStatusPageComponents();
/**
* save status page component.
*
* @param statusPageComponent status page component
*/
void newStatusPageComponent(StatusPageComponent statusPageComponent);
/**
* update status page component.
*
* @param statusPageComponent status page component
*/
void updateStatusPageComponent(StatusPageComponent statusPageComponent);
/**
* delete status page component.
*
* @param id status page component id
*/
void deleteStatusPageComponent(long id);
/**
* query status page component.
*
* @param id status page component id
* @return status page component
*/
@@ -82,56 +73,44 @@ public interface StatusPageService {
/**
* query status page components status.
*
* @return status page components status
*/
List<ComponentStatus> queryComponentsStatus();
/**
* query status page component status.
*
* @param id status page component id
* @return status page component status
*/
ComponentStatus queryComponentStatus(long id);
/**
* query status page incidents.
*
* @param search Search Target
* @param startTime Start Time
* @param endTime End Time
* @param pageIndex List current page
* @param pageSize Number of list pages
* @return The query results
* @return status page incidents
*/
Page<StatusPageIncident> queryStatusPageIncidents(String search, Long startTime, Long endTime, int pageIndex, int pageSize);
List<StatusPageIncident> queryStatusPageIncidents();
/**
* query status page incident.
*
* @param id status page incident id
* @return status page incident
*/
StatusPageIncident queryStatusPageIncident(long id);
/**
* save status page incident.
*
* @param statusPageIncident status page incident
*/
void newStatusPageIncident(StatusPageIncident statusPageIncident);
/**
* update status page incident.
*
* @param statusPageIncident status page incident
*/
void updateStatusPageIncident(StatusPageIncident statusPageIncident);
/**
* delete status page incident.
*
* @param id status page incident id
*/
void deleteStatusPageIncident(long id);
@@ -212,7 +212,7 @@ public class AppServiceImpl implements AppService, InitializingBean {
var name = job.getName();
var i18nName = CommonUtil.getLangMappingValueFromI18nMap(lang, name);
if (i18nName != null) {
i18nMap.put("monitor.app." + job.getApp(), i18nName);
i18nMap.put("monitor.app." + job.getApp().toLowerCase(), i18nName);
}
var help = job.getHelp();
var i18nHelp = CommonUtil.getLangMappingValueFromI18nMap(lang, help);
@@ -21,12 +21,9 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import jakarta.persistence.criteria.Predicate;
import lombok.RequiredArgsConstructor;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.manager.StatusPageComponent;
@@ -43,12 +40,8 @@ import org.apache.hertzbeat.manager.dao.StatusPageOrgDao;
import org.apache.hertzbeat.manager.pojo.dto.ComponentStatus;
import org.apache.hertzbeat.manager.service.StatusPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
/**
* status page service implement.
@@ -264,28 +257,9 @@ public class StatusPageServiceImpl implements StatusPageService {
}
@Override
public Page<StatusPageIncident> queryStatusPageIncidents(String search, Long startTime, Long endTime, int pageIndex, int pageSize) {
// build search condition
Specification<StatusPageIncident> specification = (root, query, criteriaBuilder) -> {
List<Predicate> andList = new ArrayList<>();
if (StringUtils.hasText(search)) {
Predicate predicateName = criteriaBuilder.like(criteriaBuilder.lower(root.get("name")), "%" + search.toLowerCase() + "%");
andList.add(predicateName);
}
if (startTime != null) {
andList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("startTime"), startTime));
}
if (endTime != null) {
andList.add(criteriaBuilder.lessThanOrEqualTo(root.get("endTime"), endTime));
}
Predicate[] predicates = new Predicate[andList.size()];
return criteriaBuilder.and(andList.toArray(predicates));
};
public List<StatusPageIncident> queryStatusPageIncidents() {
Sort sort = Sort.by(Sort.Direction.DESC, "startTime");
PageRequest pageRequest = PageRequest.of(pageIndex, pageSize, sort);
return statusPageIncidentDao.findAll(specification, pageRequest);
return statusPageIncidentDao.findAll(sort);
}
@Override
@@ -208,11 +208,6 @@ warehouse:
database: public
username: greptime
password: greptime
questdb:
enabled: false
url: localhost:9000
username: admin
password: quest
iot-db:
enabled: false
host: 127.0.0.1
@@ -1,21 +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.
-- ensure every sql can rerun without error
-- Modify message column to TEXT (H2 TEXT is equivalent to CLOB)
ALTER TABLE HZB_STATUS_PAGE_INCIDENT_CONTENT ALTER COLUMN message CLOB;
@@ -1,52 +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.
-- ensure every sql can rerun without error
-- Modify hzb_status_page_incident_content table columns to TEXT type to resolve MySQL row size limit issue
DELIMITER //
CREATE PROCEDURE ModifyStatusIncidentContentColumns()
BEGIN
DECLARE table_exists INT;
DECLARE col_exists INT;
-- Check if the table exists
SELECT COUNT(*) INTO table_exists
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'HZB_STATUS_PAGE_INCIDENT_CONTENT';
IF table_exists = 1 THEN
-- Check and modify message column to TEXT
SELECT COUNT(*) INTO col_exists
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'HZB_STATUS_PAGE_INCIDENT_CONTENT'
AND COLUMN_NAME = 'message'
AND DATA_TYPE != 'text';
IF col_exists = 1 THEN
ALTER TABLE HZB_STATUS_PAGE_INCIDENT_CONTENT MODIFY COLUMN message TEXT;
END IF;
END IF;
END //
DELIMITER ;
CALL ModifyStatusIncidentContentColumns();
DROP PROCEDURE IF EXISTS ModifyStatusIncidentContentColumns;
COMMIT;
@@ -1,23 +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.
-- ensure every sql can rerun without error
-- Modify message column to TEXT
ALTER TABLE HZB_STATUS_PAGE_INCIDENT_CONTENT ALTER COLUMN message TYPE TEXT;
commit;
@@ -490,7 +490,7 @@ metrics:
zh-CN: 次数
en-US: Num
ja-JP: 数量
- field: Size
- field: size
type: 0
unit: B
i18n:
@@ -26,7 +26,7 @@ help:
zh-CN: Hertzbeat 使用 Prometheus PromQL 从 Prometheus 服务器中查询到 InfluxDB 的通用指标数据来进行监控。此方案适用于 Prometheus 已监控 InfluxDB,需要从 Prometheus 服务器抓取 InfluxDB 的监控数据。<br>您可以点击 “<i>新建 InfluxDB-PromQL</i>” 并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat uses Prometheus PromQL query metrics data from Prometheus Server to monitoring InfluxDB. This solution is suitable for Prometheus to monitor InfluxDB, and it need to capture InfluxDB monitoring data from the Prometheus server. <br>You could click the "<i>New InfluxDB-PromQL</i>" button and proceed with the configuration or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: Hertzbeat 使用 Prometheus PromQL 從 Prometheus 服務器中查詢到 InfluxDB 的通用指標數據來進行監控。此方案適用于 Prometheus 已監控 InfluxDB,需要從 Prometheus 服務器抓取 InfluxDB 的監控數據。<br>您可以點擊 “<i>新建 InfluxDB-PromQL</i>” 並進行配置,或者選擇“<i>更多操作</i>”,導入已有配置。
ja-JP: Hertzbeat は Prometheus PromQL を介して Prometheus サーバーに InfluxDB の一般的なパフォーマンスのメトリクスをクエリして監視します。このシナリオは、PrometheusがすでにInfluxDBを監視しており、PrometheusサーバーからInfluxDBの監視データを取得する必要がある場合に適用されます。<br>「<i>新規 InfluxDB-PromQL</i>」をクリックして設定しましょう。
ja-JP: Hertzbeat は Prometheus PromQL を介して Prometheus サーバーに InfluxDB の一般的なパフォーマンスのメトリクスをクエリして監視します。このシナリオは、PrometheusがすでにInfluxDBを監視しており、PrometheusサーバーからInfluxDBの監視データを取得する必要がある場合に適用されます。<br>「<i>新規 InfluxDB-PromQL</i>」をクリックして設定しましょう。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/influxdb_promql
en-US: https://hertzbeat.apache.org/docs/help/influxdb_promql
@@ -26,7 +26,7 @@ help:
zh-CN: Hertzbeat 使用 Prometheus PromQL 从 Prometheus 服务器中查询到 Kafka 的通用指标数据来进行监控。此方案适用于 Prometheus 已监控 Kafka,需要从 Prometheus 服务器抓取 Kafka 的监控数据。<br>您可以点击 “<i>新建 Kafka-PromQL</i>” 并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat uses Prometheus PromQL query metrics data from Prometheus Server to monitoring Kafka. This solution is suitable for Prometheus to monitor Kafka, and it need to capture Kafka monitoring data from the Prometheus server. <br>You could click the "<i>New Kafka-PromQL</i>" button and proceed with the configuration or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: Hertzbeat 使用 Prometheus PromQL 從 Prometheus 服務器中查詢到 Kafka 的通用指標數據來進行監控。此方案適用于 Prometheus 已監控 Kafka,需要從 Prometheus 服務器抓取 Kafka 的監控數據。<br>您可以點擊 “<i>新建 Kafka-PromQL</i>” 並進行配置,或者選擇“<i>更多操作</i>”,導入已有配置。
ja-JP: Hertzbeat は Prometheus PromQL を介して Prometheus サーバーに Kafka の一般的なパフォーマンスのメトリクスをクエリして監視します。このシナリオは、PrometheusがすでにKafkaを監視しており、PrometheusサーバーからKafkaの監視データを取得する必要がある場合に適用されます。<br>「<i>新規 Kafka-PromQL</i>」をクリックして設定しましょう。
ja-JP: Hertzbeat は Prometheus PromQL を介して Prometheus サーバーに Kafka の一般的なパフォーマンスのメトリクスをクエリして監視します。このシナリオは、PrometheusがすでにKafkaを監視しており、PrometheusサーバーからKafkaの監視データを取得する必要がある場合に適用されます。<br>「<i>新規 Kafka-PromQL</i>」をクリックして設定しましょう。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/kafka_promql
en-US: https://hertzbeat.apache.org/docs/help/kafka_promql
@@ -490,7 +490,7 @@ metrics:
zh-CN: 次数
en-US: Num
ja-JP: 数量
- field: Size
- field: size
type: 0
unit: B
i18n:
@@ -1,750 +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 categoryservice-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: os
# The monitoring type eg: linux windows tomcat mysql aws...
app: macos
# The monitoring i18n name
name:
zh-CN: macOS
en-US: macOS
ja-JP: macOS
# The description and help of this monitoring type
help:
zh-CN: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH 协议</a> 对 macOS 操作系统的通用性能指标 (系统信息、CPU、内存、磁盘、网卡、文件系统、TOP资源进程等) 进行采集监控。<br>您可以点击“<i>新建 macOS</i>”并配置 HOST 端口账户等相关参数进行添加,支持 SSH 账户密码或密钥认证。或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat uses <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH protocol</a> to monitors macOS operating system's general performance metrics such as cpu, memory, disk, basic, interface, disk_free, top_process etc. <br>You can click the "<i>New macOS</i>" and config host port and other related params to add, auth support password or secretKey. Or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH 协议</a> 對 macOS 操作系统的通用性能指標 (系統信息、CPU、內存、磁盤、網卡、文件系統、TOP資源進程等) 進行採集監控。<br>您可以點擊“<i>新建 macOS</i>”並配置HOST端口賬戶等相關參數進行添加,支持SSH賬戶密碼或密鑰認證。或者選擇“<i>更多操作</i>”,導入已有配寘。
ja-JP: Hertzbeat は <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSHプロトコルを介して</a> macOS システムの一般的なパフォーマンスのメトリクスを監視します。<br>「<i>新規 macOS</i>」をクリックしてホストなどのパラメタを設定した後、新規することができます。SSHまたはキー認証をサポートします。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/macos/
en-US: https://hertzbeat.apache.org/docs/help/macos/
# Input params define for monitoring(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: Target 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
- 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: 22
# field-param field key
- field: timeout
# name-param field display i18n name
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
ja-JP: タイムアウト(ms)
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
range: '[400,200000]'
# required-true or false
required: false
# default value
defaultValue: 6000
# field-param field key
- field: reuseConnection
# name-param field display i18n name
name:
zh-CN: 复用连接
en-US: Reuse Connection
ja-JP: 接続再利用
# type-param field type(most mapping the html input type)
type: boolean
# required-true or false
required: true
defaultValue: true
# field-param field key
- field: useProxy
# name-param field display i18n name
name:
zh-CN: 使用代理
en-US: Use Proxy Connection
ja-JP: プロキシ接続利用
# type-param field type(most mapping the html input type)
type: boolean
# required-true or false
required: true
defaultValue: false
# field-param field key
- field: username
# name-param field display i18n name
name:
zh-CN: 用户名
en-US: Username
ja-JP: ユーザー名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 50
# required-true or false
required: true
# field-param field key
- field: password
# name-param field display i18n name
name:
zh-CN: 密码
en-US: Password
ja-JP: パスワード
# type-param field type(most mapping the html input tag)
type: password
# required-true or false
required: false
# field-param field key
- field: privateKey
# name-param field display i18n name
name:
zh-CN: 私钥
en-US: PrivateKey
ja-JP: 秘密鍵
# type-param field type(most mapping the html input type)
type: textarea
placeholder: -----BEGIN RSA PRIVATE KEY-----
# required-true or false
required: false
# hide param-true or false
hide: true
# field-param field key
- field: privateKeyPassphrase
# name-param field display i18n name
name:
zh-CN: 密钥短语
en-US: PrivateKey PassPhrase
ja-JP: 秘密鍵フレーズ
# type-param field type(most mapping the html input type)
type: password
# required-true or false
required: false
# hide param-true or false
hide: true
# field-param field key
- field: proxyHost
# name-param field display i18n name
name:
zh-CN: 代理主机
en-US: Proxy Host
ja-JP: プロキシホスト
# type-param field type(most mapping the html input type)
type: text
# required-true or false
required: false
# hide param-true or false
hide: true
- field: proxyPort
# name-param field display i18n name
name:
zh-CN: 代理端口
en-US: Proxy 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: false
# hide param-true or false
hide: true
# default value
defaultValue: 22
# field-param field key
- field: proxyUsername
# name-param field display i18n name
name:
zh-CN: 代理用户名
en-US: Proxy Username
ja-JP: プロキシユーザー名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 50
# required-true or false
required: false
# hide param-true or false
hide: true
# field-param field key
- field: proxyPassword
# name-param field display i18n name
name:
zh-CN: 代理密码
en-US: Proxy Password
ja-JP: プロキシパスワード
# type-param field type(most mapping the html input tag)
type: password
# required-true or false
required: false
# hide param-true or false
hide: true
# field-param field key
- field: proxyPrivateKey
# name-param field display i18n name
name:
zh-CN: 代理主机私钥
en-US: proxyPrivateKey
ja-JP: プロキシ秘密鍵
# type-param field type(most mapping the html input type)
type: textarea
placeholder: -----BEGIN RSA PRIVATE KEY-----
# required-true or false
required: false
# hide param-true or false
hide: true
# collect metrics config list
metrics:
# metrics - basic, inner monitoring metrics (responseTime - response time)
- name: basic
i18n:
zh-CN: 系统基本信息
en-US: Basic Info
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
# collect metrics content
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: hostname
type: 1
label: true
i18n:
zh-CN: 主机名称
en-US: Host Name
ja-JP: ホスト名
- field: version
type: 1
i18n:
zh-CN: 操作系统版本
en-US: System Version
ja-JP: オーエスバージョン
- field: uptime
type: 1
i18n:
zh-CN: 启动时间
en-US: Uptime
ja-JP: アップタイム
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: ssh
# the config content when protocol is ssh
ssh:
# ssh host: ipv4 ipv6 domain
host: ^_^host^_^
# ssh port
port: ^_^port^_^
# ssh username
username: ^_^username^_^
# ssh password
password: ^_^password^_^
# ssh private key
privateKey: ^_^privateKey^_^
# ssh private key passphrase
privateKeyPassphrase: ^_^privateKeyPassphrase^_^
timeout: ^_^timeout^_^
reuseConnection: ^_^reuseConnection^_^
# whether to use proxy server for ssh connection
useProxy: ^_^useProxy^_^
# ssh proxy host: ipv4 domain
proxyHost: ^_^proxyHost^_^
# ssh proxy port
proxyPort: ^_^proxyPort^_^
# ssh proxy username
proxyUsername: ^_^proxyUsername^_^
# ssh proxy password
proxyPassword: ^_^proxyPassword^_^
# ssh proxy private key
proxyPrivateKey: ^_^proxyPrivateKey^_^
# ssh run collect script
script: scutil --get ComputerName; echo "$(sw_vers -productName) $(sw_vers -productVersion) ($(sw_vers -buildVersion))"; uptime| awk '{print $1,$2,$3,$4}' | sed 's/,//'
# ssh response data parse type: oneRow, multiRow
parseType: oneRow
- name: cpu
i18n:
zh-CN: CPU 信息
en-US: CPU Info
ja-JP: CPU情報
priority: 1
fields:
- field: info
type: 1
i18n:
zh-CN: 型号
en-US: Info
ja-JP: バージョン
- field: cores
type: 1
i18n:
zh-CN: 核数
en-US: Cores
ja-JP: コア数
- field: load
type: 1
i18n:
zh-CN: 负载
en-US: Load
ja-JP: ロード
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
ja-JP: 使用率
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- info
- cores
- load
- idle
# mapping and conversion expressions, use these and aliasField above to calculate metrics value
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- info=info
- cores=cores
- load=load
- usage=idle
protocol: ssh
ssh:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
privateKey: ^_^privateKey^_^
privateKeyPassphrase: ^_^privateKeyPassphrase^_^
timeout: ^_^timeout^_^
reuseConnection: ^_^reuseConnection^_^
# whether to use proxy server for ssh connection
useProxy: ^_^useProxy^_^
# ssh proxy host: ipv4 domain
proxyHost: ^_^proxyHost^_^
# ssh proxy port
proxyPort: ^_^proxyPort^_^
# ssh proxy username
proxyUsername: ^_^proxyUsername^_^
# ssh proxy password
proxyPassword: ^_^proxyPassword^_^
# ssh proxy private key
proxyPrivateKey: ^_^proxyPrivateKey^_^
script: sysctl -n machdep.cpu.brand_string; sysctl -n hw.ncpu; sysctl -n vm.loadavg | awk '{print $2,$3,$4}'; top -l 1 | grep 'CPU usage' | awk '{print $3}' | sed 's/%//'
parseType: oneRow
- name: memory
i18n:
zh-CN: 内存信息
en-US: Memory Info
ja-JP: メモリ情報
priority: 2
fields:
- field: total
type: 1
unit: Mb
i18n:
zh-CN: 总内存容量
en-US: Total Memory
ja-JP: メモリ容量
- field: used
type: 0
unit: Mb
i18n:
zh-CN: 用户程序内存量
en-US: User Program Memory
ja-JP: ユーザープログラムメモリ
- field: free
type: 0
unit: Mb
i18n:
zh-CN: 空闲内存容量
en-US: Free Memory
ja-JP: 空きメモリ
- field: buff_cache
type: 0
unit: Mb
i18n:
zh-CN: 缓存占用内存
en-US: Buff Cache Memory
ja-JP: バッファメモリ
- field: available
type: 0
unit: Mb
i18n:
zh-CN: 剩余可用内存
en-US: Available Memory
ja-JP: 使用可能のメモリ
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 内存使用率
en-US: Memory Usage
ja-JP: メモリ使用率
aliasFields:
- total
- used
- free
- buff_cache
- available
calculates:
- total=total
- used=used
- free=free
- buff_cache=buff_cache
- available=available
- usage=(used / total) * 100
protocol: ssh
ssh:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
privateKey: ^_^privateKey^_^
privateKeyPassphrase: ^_^privateKeyPassphrase^_^
timeout: ^_^timeout^_^
reuseConnection: ^_^reuseConnection^_^
# whether to use proxy server for ssh connection
useProxy: ^_^useProxy^_^
# ssh proxy host: ipv4 domain
proxyHost: ^_^proxyHost^_^
# ssh proxy port
proxyPort: ^_^proxyPort^_^
# ssh proxy username
proxyUsername: ^_^proxyUsername^_^
# ssh proxy password
proxyPassword: ^_^proxyPassword^_^
# ssh proxy private key
proxyPrivateKey: ^_^proxyPrivateKey^_^
script: echo "total used free buff_cache available"; vm_stat | awk 'BEGIN{cmd="sysctl -n hw.memsize";cmd|getline total;close(cmd);cmd="sysctl -n hw.pagesize";cmd|getline ps;close(cmd);total=total/1024/1024} /Pages free/{free=$3} /Pages active/{active=$3} /Pages inactive/{inactive=$3} /Pages wired/{wired=$4} /Pages occupied by compressor/{comp=$5} END{free_mb=free*ps/1024/1024;used_mb=(active+inactive+wired+comp)*ps/1024/1024;inactive_mb=inactive*ps/1024/1024;avail_mb=(free+inactive)*ps/1024/1024;printf "%.0f %.0f %.0f %.0f %.0f\n",total,used_mb,free_mb,inactive_mb,avail_mb}'
parseType: multiRow
- name: disk
i18n:
zh-CN: 磁盘信息
en-US: Disk Info
ja-JP: ディスク情報
priority: 3
fields:
- field: disk_num
type: 1
i18n:
zh-CN: 磁盘总数
en-US: Disk Num
ja-JP: ディスク番号
- field: partition_num
type: 1
i18n:
zh-CN: 分区总数
en-US: Partition Num
ja-JP: パーティション
- field: block_write
type: 0
i18n:
zh-CN: 写磁盘块数
en-US: Block Write
ja-JP: 書き込みディスクブロック数
- field: block_read
type: 0
i18n:
zh-CN: 读磁盘块数
en-US: Block Read
ja-JP: 読み取りブロック数
- field: write_rate
type: 0
unit: iops
i18n:
zh-CN: 磁盘写速率
en-US: Write Rate
ja-JP: ディスク書き込み速度
protocol: ssh
ssh:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
privateKey: ^_^privateKey^_^
privateKeyPassphrase: ^_^privateKeyPassphrase^_^
timeout: ^_^timeout^_^
reuseConnection: ^_^reuseConnection^_^
# whether to use proxy server for ssh connection
useProxy: ^_^useProxy^_^
# ssh proxy host: ipv4 domain
proxyHost: ^_^proxyHost^_^
# ssh proxy port
proxyPort: ^_^proxyPort^_^
# ssh proxy username
proxyUsername: ^_^proxyUsername^_^
# ssh proxy password
proxyPassword: ^_^proxyPassword^_^
# ssh proxy private key
proxyPrivateKey: ^_^proxyPrivateKey^_^
script: iostat -d | awk 'NR==3{print $1}'; iostat -d | awk 'NR==3{print $2}'; vm_stat | awk '/Pages free/{print $3}' | tr -d ':'; vm_stat | awk '/Pages active/{print $3}' | tr -d ':'; sysctl -n hw.memsize | awk '{print int($1/1024/1024)}'
parseType: oneRow
- name: interface
i18n:
zh-CN: 网卡信息
en-US: Interface Info
ja-JP: ネットワークカード情報
priority: 4
fields:
- field: interface_name
type: 1
label: true
i18n:
zh-CN: 网卡名称
en-US: Interface Name
ja-JP: ネットワークカード名
- field: receive_bytes
type: 0
unit: Mb
i18n:
zh-CN: 入站数据流量
en-US: Receive Bytes
ja-JP: 受信されたバイト数
- field: transmit_bytes
type: 0
unit: Mb
i18n:
zh-CN: 出站数据流量
en-US: Transmit Bytes
ja-JP: 転送されたバイト数
units:
- receive_bytes=B->MB
- transmit_bytes=B->MB
protocol: ssh
ssh:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
privateKey: ^_^privateKey^_^
privateKeyPassphrase: ^_^privateKeyPassphrase^_^
timeout: ^_^timeout^_^
reuseConnection: ^_^reuseConnection^_^
# whether to use proxy server for ssh connection
useProxy: ^_^useProxy^_^
# ssh proxy host: ipv4 domain
proxyHost: ^_^proxyHost^_^
# ssh proxy port
proxyPort: ^_^proxyPort^_^
# ssh proxy username
proxyUsername: ^_^proxyUsername^_^
# ssh proxy password
proxyPassword: ^_^proxyPassword^_^
# ssh proxy private key
proxyPrivateKey: ^_^proxyPrivateKey^_^
script: netstat -ibn | awk 'NR==1{print "interface_name receive_bytes transmit_bytes"} NR>1 && $1!~/Name/ && $7~/^[0-9]+$/{print $1,$7,$10}'
parseType: multiRow
- name: disk_free
i18n:
zh-CN: 文件系统
en-US: Disk Free
ja-JP: ファイルシステム
priority: 5
fields:
- field: filesystem
type: 1
i18n:
zh-CN: 文件系统
en-US: Filesystem
ja-JP: ファイルシステム
- field: used
type: 0
unit: Mb
i18n:
zh-CN: 已使用量
en-US: Used
ja-JP: 使用済み
- field: available
type: 0
unit: Mb
i18n:
zh-CN: 可用量
en-US: Available
ja-JP: 使用可能
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
ja-JP: 使用率
- field: mounted
type: 1
label: true
i18n:
zh-CN: 挂载点
en-US: Mounted
ja-JP: マウント
protocol: ssh
ssh:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
privateKey: ^_^privateKey^_^
privateKeyPassphrase: ^_^privateKeyPassphrase^_^
timeout: ^_^timeout^_^
reuseConnection: ^_^reuseConnection^_^
# whether to use proxy server for ssh connection
useProxy: ^_^useProxy^_^
# ssh proxy host: ipv4 domain
proxyHost: ^_^proxyHost^_^
# ssh proxy port
proxyPort: ^_^proxyPort^_^
# ssh proxy username
proxyUsername: ^_^proxyUsername^_^
# ssh proxy password
proxyPassword: ^_^proxyPassword^_^
# ssh proxy private key
proxyPrivateKey: ^_^proxyPrivateKey^_^
script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$9}'
parseType: multiRow
- name: top_cpu_process
i18n:
zh-CN: Top10 CPU 进程
en-US: Top10 CPU Process
ja-JP: トップ10 CPUプロセス
priority: 6
fields:
- field: pid
type: 1
label: true
i18n:
zh-CN: 进程ID
en-US: PID
ja-JP: プロセスID
- field: cpu_usage
type: 0
unit: '%'
i18n:
zh-CN: CPU占用率
en-US: CPU Usage
ja-JP: CPU使用率
- field: mem_usage
type: 0
unit: '%'
i18n:
zh-CN: 内存占用率
en-US: Memory Usage
ja-JP: メモリ使用率
- field: command
type: 1
i18n:
zh-CN: 执行命令
en-US: Command
ja-JP: コマンド
protocol: ssh
ssh:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
privateKey: ^_^privateKey^_^
privateKeyPassphrase: ^_^privateKeyPassphrase^_^
timeout: ^_^timeout^_^
reuseConnection: ^_^reuseConnection^_^
# whether to use proxy server for ssh connection
useProxy: ^_^useProxy^_^
# ssh proxy host: ipv4 domain
proxyHost: ^_^proxyHost^_^
# ssh proxy port
proxyPort: ^_^proxyPort^_^
# ssh proxy username
proxyUsername: ^_^proxyUsername^_^
# ssh proxy password
proxyPassword: ^_^proxyPassword^_^
# ssh proxy private key
proxyPrivateKey: ^_^proxyPrivateKey^_^
script: ps aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {printf "%s %s %s ", $2, $3, $4; for (i=11; i<=NF; i++) { printf "%s", $i; if (i < NF) printf " "; } print ""}' | head -n 11
parseType: multiRow
- name: top_mem_process
i18n:
zh-CN: Top10 内存进程
en-US: Top10 Memory Process
ja-JP: トップ10 メモリプロセス
priority: 7
fields:
- field: pid
type: 1
label: true
i18n:
zh-CN: 进程ID
en-US: PID
ja-JP: プロセスID
- field: mem_usage
type: 0
unit: '%'
i18n:
zh-CN: 内存占用率
en-US: Memory Usage
ja-JP: メモリ使用率
- field: cpu_usage
type: 0
unit: '%'
i18n:
zh-CN: CPU占用率
en-US: CPU Usage
ja-JP: CPU使用率
- field: command
type: 1
i18n:
zh-CN: 执行命令
en-US: Command
ja-JP: コマンド
protocol: ssh
ssh:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
privateKey: ^_^privateKey^_^
privateKeyPassphrase: ^_^privateKeyPassphrase^_^
timeout: ^_^timeout^_^
reuseConnection: ^_^reuseConnection^_^
# whether to use proxy server for ssh connection
useProxy: ^_^useProxy^_^
# ssh proxy host: ipv4 domain
proxyHost: ^_^proxyHost^_^
# ssh proxy port
proxyPort: ^_^proxyPort^_^
# ssh proxy username
proxyUsername: ^_^proxyUsername^_^
# ssh proxy password
proxyPassword: ^_^proxyPassword^_^
# ssh proxy private key
proxyPrivateKey: ^_^proxyPrivateKey^_^
script: ps aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } NR>1{cmd=""; for(i=11;i<=NF;i++) cmd=cmd $i (i==NF?"":" "); printf "%s %s %s %s\n", $2, $3, $4, cmd}' | head -n 11
parseType: multiRow
@@ -21,13 +21,11 @@ app: rockylinux
name:
zh-CN: Rocky Linux
en-US: Rocky Linux
ja-JP: Rocky Linux
# The description and help of this monitoring type
help:
zh-CN: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH 协议</a> 对 Rocky 操作系统的通用性能指标 (系统信息、CPU、内存、磁盘、网卡、文件系统、TOP资源进程等) 进行采集监控。<br>您可以点击“<i>新建 Rocky</i>”并配置HOST端口账户等相关参数进行添加,支持SSH账户密码或密钥认证。或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat uses <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH protocol</a> to monitors Rocky operating system's general performance metrics such as cpu, memory, disk, basic, interface, disk_free, top_process etc. <br>You can click the "<i>New Rocky</i>" and config host port and other related params to add, auth support password or secretKey. Or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH 协议</a> 對 Rocky 操作系统的通用性能指標 (系統信息、CPU、內存、磁盤、網卡、文件系統、TOP資源進程等) 進行採集監控。<br>您可以點擊“<i>新建 Rocky</i>”並配置HOST端口賬戶等相關參數進行添加,支持SSH賬戶密碼或密鑰認證。或者選擇“<i>更多操作</i>”,導入已有配寘。
ja-JP: Hertzbeat は <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSHプロトコルを介して</a> Rockyオーエスの一般的なパフォーマンスのメトリクスを監視します。<br>「<i>新規 Rocky</i>」をクリックしてホストなどのパラメタを設定した後、新規することができます。SSHまたはキー認証をサポートします。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/rockylinux
en-US: https://hertzbeat.apache.org/docs/help/rockylinux
@@ -39,7 +37,6 @@ params:
name:
zh-CN: 目标Host
en-US: Target Host
ja-JP: 目標ホスト
# type-param field type(most mapping the html input type)
type: host
# required-true or false
@@ -50,7 +47,6 @@ params:
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
@@ -65,7 +61,6 @@ params:
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
ja-JP: タイムアウト(ms)
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
@@ -80,7 +75,6 @@ params:
name:
zh-CN: 复用连接
en-US: Reuse Connection
ja-JP: 接続再利用
# type-param field type(most mapping the html input type)
type: boolean
# required-true or false
@@ -92,7 +86,6 @@ params:
name:
zh-CN: 使用代理
en-US: Use Proxy Connection
ja-JP: プロキシ接続利用
# type-param field type(most mapping the html input type)
type: boolean
# required-true or false
@@ -104,7 +97,6 @@ params:
name:
zh-CN: 用户名
en-US: Username
ja-JP: ユーザー名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
@@ -117,7 +109,6 @@ params:
name:
zh-CN: 密码
en-US: Password
ja-JP: パスワード
# type-param field type(most mapping the html input tag)
type: password
# required-true or false
@@ -128,7 +119,6 @@ params:
name:
zh-CN: 私钥
en-US: PrivateKey
ja-JP: 秘密鍵
# type-param field type(most mapping the html input type)
type: textarea
placeholder: -----BEGIN RSA PRIVATE KEY-----
@@ -142,7 +132,6 @@ params:
name:
zh-CN: 密钥短语
en-US: PrivateKey PassPhrase
ja-JP: 秘密鍵フレーズ
# type-param field type(most mapping the html input type)
type: password
# required-true or false
@@ -155,7 +144,6 @@ params:
name:
zh-CN: 代理主机
en-US: Proxy Host
ja-JP: プロキシホスト
# type-param field type(most mapping the html input type)
type: text
# required-true or false
@@ -167,7 +155,6 @@ params:
name:
zh-CN: 代理端口
en-US: Proxy Port
ja-JP: プロキシポート
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
@@ -184,7 +171,6 @@ params:
name:
zh-CN: 代理用户名
en-US: Proxy Username
ja-JP: プロキシユーザー名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
@@ -199,7 +185,6 @@ params:
name:
zh-CN: 代理密码
en-US: Proxy Password
ja-JP: プロキシパスワード
# type-param field type(most mapping the html input tag)
type: password
# required-true or false
@@ -212,7 +197,6 @@ params:
name:
zh-CN: 代理主机私钥
en-US: proxyPrivateKey
ja-JP: プロキシ秘密鍵
# type-param field type(most mapping the html input type)
type: textarea
placeholder: -----BEGIN RSA PRIVATE KEY-----
@@ -227,7 +211,6 @@ metrics:
i18n:
zh-CN: 系统基本信息
en-US: Basic Info
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
@@ -240,19 +223,16 @@ metrics:
i18n:
zh-CN: 主机名称
en-US: Host Name
ja-JP: ホスト名
- field: version
type: 1
i18n:
zh-CN: 操作系统版本
en-US: System Version
ja-JP: システムバージョン
- field: uptime
type: 1
i18n:
zh-CN: 启动时间
en-US: Uptime
ja-JP: アップタイム
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: ssh
# the config content when protocol is ssh
@@ -292,7 +272,6 @@ metrics:
i18n:
zh-CN: CPU 信息
en-US: CPU Info
ja-JP: CPU情報
priority: 1
fields:
- field: info
@@ -300,38 +279,32 @@ metrics:
i18n:
zh-CN: 型号
en-US: Info
ja-JP: バージョン
- field: cores
type: 1
i18n:
zh-CN: 核数
en-US: Cores
ja-JP: コア数
- field: interrupt
type: 0
i18n:
zh-CN: 中断数
en-US: Interrupt
ja-JP: 割り込み数
- field: load
type: 1
i18n:
zh-CN: 负载
en-US: Load
ja-JP: ロード
- field: context_switch
type: 0
i18n:
zh-CN: 上下文切换
en-US: Context Switch
ja-JP: コンテキストスイッチ
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
ja-JP: 使用率
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- info
@@ -378,7 +351,6 @@ metrics:
i18n:
zh-CN: 内存信息
en-US: Memory Info
ja-JP: メモリ情報
priority: 2
fields:
- field: total
@@ -387,42 +359,36 @@ metrics:
i18n:
zh-CN: 总内存容量
en-US: Total Memory
ja-JP: メモリ容量
- field: used
type: 0
unit: Mb
i18n:
zh-CN: 用户程序内存量
en-US: User Program Memory
ja-JP: ユーザープログラムメモリ
- field: free
type: 0
unit: Mb
i18n:
zh-CN: 空闲内存容量
en-US: Free Memory
ja-JP: 空きメモリ
- field: buff_cache
type: 0
unit: Mb
i18n:
zh-CN: 缓存占用内存
en-US: Buff Cache Memory
ja-JP: バッファメモリ
- field: available
type: 0
unit: Mb
i18n:
zh-CN: 剩余可用内存
en-US: Available Memory
ja-JP: 使用可能のメモリ
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 内存使用率
en-US: Memory Usage
ja-JP: メモリ使用率
aliasFields:
- total
- used
@@ -465,7 +431,6 @@ metrics:
i18n:
zh-CN: 磁盘信息
en-US: Disk Info
ja-JP: ディスク情報
priority: 3
fields:
- field: disk_num
@@ -473,32 +438,27 @@ metrics:
i18n:
zh-CN: 磁盘总数
en-US: Disk Num
ja-JP: ディスク番号
- field: partition_num
type: 1
i18n:
zh-CN: 分区总数
en-US: Partition Num
ja-JP: パーティション
- field: block_write
type: 0
i18n:
zh-CN: 写磁盘块数
en-US: Block Write
ja-JP: 書き込みディスクブロック数
- field: block_read
type: 0
i18n:
zh-CN: 读磁盘块数
en-US: Block Read
ja-JP: 読み取りブロック数
- field: write_rate
type: 0
unit: iops
i18n:
zh-CN: 磁盘写速率
en-US: Write Rate
ja-JP: ディスク書き込み速度
protocol: ssh
ssh:
host: ^_^host^_^
@@ -528,7 +488,6 @@ metrics:
i18n:
zh-CN: 网卡信息
en-US: Interface Info
ja-JP: ネットワークカード情報
priority: 4
fields:
- field: interface_name
@@ -537,21 +496,18 @@ metrics:
i18n:
zh-CN: 网卡名称
en-US: Interface Name
ja-JP: ネットワークカード名
- field: receive_bytes
type: 0
unit: Mb
i18n:
zh-CN: 入站数据流量
en-US: Receive Bytes
ja-JP: 受信されたバイト数
- field: transmit_bytes
type: 0
unit: Mb
i18n:
zh-CN: 出站数据流量
en-US: Transmit Bytes
ja-JP: 転送されたバイト数
units:
- receive_bytes=B->MB
- transmit_bytes=B->MB
@@ -584,7 +540,6 @@ metrics:
i18n:
zh-CN: 文件系统
en-US: Disk Free
ja-JP: ファイルシステム
priority: 5
fields:
- field: filesystem
@@ -592,35 +547,30 @@ metrics:
i18n:
zh-CN: 文件系统
en-US: Filesystem
ja-JP: ファイルシステム
- field: used
type: 0
unit: Mb
i18n:
zh-CN: 已使用量
en-US: Used
ja-JP: 使用済み
- field: available
type: 0
unit: Mb
i18n:
zh-CN: 可用量
en-US: Available
ja-JP: 使用可能
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
ja-JP: 使用率
- field: mounted
type: 1
label: true
i18n:
zh-CN: 挂载点
en-US: Mounted
ja-JP: マウント
protocol: ssh
ssh:
host: ^_^host^_^
@@ -650,7 +600,6 @@ metrics:
i18n:
zh-CN: Top10 CPU 进程
en-US: Top10 CPU Process
ja-JP: トップ10 CPUプロセス
priority: 6
fields:
- field: pid
@@ -659,27 +608,23 @@ metrics:
i18n:
zh-CN: 进程ID
en-US: PID
ja-JP: プロセスID
- field: cpu_usage
type: 0
unit: '%'
i18n:
zh-CN: CPU占用率
en-US: CPU Usage
ja-JP: CPU使用率
- field: mem_usage
type: 0
unit: '%'
i18n:
zh-CN: 内存占用率
en-US: Memory Usage
ja-JP: メモリ使用率
- field: command
type: 1
i18n:
zh-CN: 执行命令
en-US: Command
ja-JP: コマンド
protocol: ssh
ssh:
host: ^_^host^_^
@@ -709,7 +654,6 @@ metrics:
i18n:
zh-CN: Top10 内存进程
en-US: Top10 Memory Process
ja-JP: トップ10 メモリプロセス
priority: 7
fields:
- field: pid
@@ -718,27 +662,23 @@ metrics:
i18n:
zh-CN: 进程ID
en-US: PID
ja-JP: プロセスID
- field: mem_usage
type: 0
unit: '%'
i18n:
zh-CN: 内存占用率
en-US: Memory Usage
ja-JP: メモリ使用率
- field: cpu_usage
type: 0
unit: '%'
i18n:
zh-CN: CPU占用率
en-US: CPU Usage
ja-JP: CPU使用率
- field: command
type: 1
i18n:
zh-CN: 执行命令
en-US: Command
ja-JP: コマンド
protocol: ssh
ssh:
host: ^_^host^_^
@@ -21,13 +21,11 @@ app: seatunnel
name:
zh-CN: Seatunnel
en-US: Seatunnel
ja-JP: Seatunnel
# The description and help of this monitoring type
help:
zh-CN: Hertzbeat 对 Seatunnel 通用指标进行测量监控。<br>您可以点击 “<i>新建 Seatunnel</i>” 并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: Hertzbeat measures and monitors the general metrics of Seatunnel.<br>You can click on “<i>Create New Seatunnel</i>” to configure it, or select “<i>More Actions</i>” to import an existing configuration.
zh-TW: Hertzbeat 對 Seatunnel 通用指標進行測量監控。<br>您可以點擊 “<i>新建 Seatunnel</i>” 並進行配置,或者選擇“<i>更多操作</i>”,導入已有配置。
ja-JP: Hertzbeat は Seatunnelの一般的なメトリクスを監視します。<br>「<i>新規 Seatunnel</i>」をクリックしてパラメタを設定した後、新規することができます。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/seatunnel
en-US: https://hertzbeat.apache.org/docs/help/seatunnel
@@ -39,7 +37,6 @@ params:
name:
zh-CN: 目标Host
en-US: Target Host
ja-JP: 目標ホスト
# type-param field type(most mapping the html input type)
type: host
# required-true or false
@@ -50,7 +47,6 @@ params:
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
@@ -65,7 +61,6 @@ params:
name:
zh-CN: 查询超时时间
en-US: Query Timeout
ja-JP: クエリタイムアウト
# type-param field type(most mapping the html input type)
type: number
# required-true or false
@@ -80,7 +75,6 @@ params:
name:
zh-CN: 启用HTTPS
en-US: SSL
ja-JP: SSL
# type-param field type(boolean mapping the html h tag)
type: boolean
# required-true or false
@@ -92,7 +86,6 @@ metrics:
i18n:
zh-CN: 集群概览
en-US: Cluster Overview
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
@@ -104,56 +97,48 @@ metrics:
i18n:
zh-CN: 项目版本
en-US: Project Version
ja-JP: プロジェクトバージョン
- field: gitCommitAbbrev
type: 1
i18n:
zh-CN: Git提交编号
en-US: Git Commit Abbrev
ja-JP: GitコミットID
- field: totalSlot
type: 0
i18n:
zh-CN: 总槽位数
en-US: Total Slot
ja-JP: スロット数
- field: unassignedSlot
type: 0
i18n:
zh-CN: 未分配槽位数
en-US: Unassigned Slot
ja-JP: 未割り当てのスロット数
- field: runningJobs
type: 0
i18n:
zh-CN: 运行中任务数
en-US: Running Jobs
ja-JP: 実行中のタスク数
- field: finishedJobs
type: 0
i18n:
zh-CN: 已完成任务数
en-US: Finished Jobs
ja-JP: 完了したタスク数
- field: failedJobs
type: 0
i18n:
zh-CN: 失败任务数
en-US: Failed Jobs
ja-JP: 失敗したタスク数
- field: cancelledJobs
type: 0
i18n:
zh-CN: 取消任务数
en-US: Cancelled Jobs
ja-JP: キャンセルされたタスク数
- field: workers
type: 0
i18n:
zh-CN: Worker数
en-US: Workers
ja-JP: ワーカー数
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
# (可选)监控指标别名, 做为中间字段与采集数据字段和指标字段映射转换
aliasFields:
- projectVersion
- gitCommitAbbrev
@@ -197,7 +182,6 @@ metrics:
i18n:
zh-CN: 线程信息
en-US: Thread Info
ja-JP: スレッド情報
priority: 1
fields:
- field: threadName
@@ -206,25 +190,21 @@ metrics:
i18n:
zh-CN: 线程名称
en-US: Thread Name
ja-JP: スレッド名
- field: threadId
type: 0
i18n:
zh-CN: 线程ID
en-US: Thread ID
ja-JP: スレッドID
- field: threadState
type: 1
i18n:
zh-CN: 线程状态
en-US: Thread State
ja-JP: スレッド状態
- field: stackTrace
type: 1
i18n:
zh-CN: 堆栈信息
en-US: Stack Trace
ja-JP: スタックトレース
protocol: http
http:
host: ^_^host^_^
@@ -247,7 +227,6 @@ metrics:
i18n:
zh-CN: 节点监控
en-US: Node Monitor
ja-JP: ノード情報
priority: 1
fields:
- field: isMaster
@@ -256,289 +235,241 @@ metrics:
i18n:
zh-CN: 是否主节点
en-US: Is Master
ja-JP: マスターノード
- field: host
type: 1
i18n:
zh-CN: IP地址
en-US: IP Address
ja-JP: IPアドレス
- field: port
type: 1
i18n:
zh-CN: 端口
en-US: Port
ja-JP: ポート
- field: processors
type: 1
i18n:
zh-CN: 处理器数
en-US: Processors
ja-JP: プロセッサ数
- field: physical.memory.total
type: 1
i18n:
zh-CN: 物理内存总量
en-US: Physical Memory Total
ja-JP: 物理メモリ容量
- field: physical.memory.free
type: 1
i18n:
zh-CN: 物理内存可用
en-US: Physical Memory Free
ja-JP: 利用可能な物理メモリ
- field: swap.space.total
type: 1
i18n:
zh-CN: 交换空间总量
en-US: Swap Space Total
ja-JP: スワップ領域容量
- field: swap.space.free
type: 1
i18n:
zh-CN: 交换空间可用
en-US: Swap Space Free
ja-JP: 利用可能なスワップ領域
- field: heap.memory.used
type: 1
i18n:
zh-CN: 堆内存已用
en-US: Heap Memory Used
ja-JP: 使用したヒープメモリ
- field: heap.memory.free
type: 1
i18n:
zh-CN: 堆内存可用
en-US: Heap Memory Free
ja-JP: 利用可能なヒープメモリ
- field: heap.memory.total
type: 1
i18n:
zh-CN: 堆内存总量
en-US: Heap Memory Total
ja-JP: ヒープメモリ容量
- field: heap.memory.max
type: 1
i18n:
zh-CN: 堆内存最大
en-US: Heap Memory Max
ja-JP: ヒープメモリの最大値
- field: heap.memory.used/total
type: 1
i18n:
zh-CN: 堆内存使用率
en-US: Heap Memory Used/Total
ja-JP: ヒープメモリの使用率
- field: heap.memory.used/max
type: 1
i18n:
zh-CN: 堆内存使用率最大
en-US: Heap Memory Used/Max
ja-JP: ヒープメモリの使用率の最大値
- field: minor.gc.count
type: 1
i18n:
zh-CN: 小垃圾回收次数
en-US: Minor GC Count
ja-JP: 若い領域GC回数
- field: minor.gc.time
type: 1
i18n:
zh-CN: 小垃圾回收时间
en-US: Minor GC Time
ja-JP: 若い領域GC時間
- field: major.gc.count
type: 1
i18n:
zh-CN: 大垃圾回收次数
en-US: Major GC Count
ja-JP: 古い領域GC回数
- field: major.gc.time
type: 1
i18n:
zh-CN: 大垃圾回收时间
en-US: Major GC Time
ja-JP: 古い領域GC時間
- field: load.process
type: 1
i18n:
zh-CN: 进程负载
en-US: Load Process
ja-JP: プロセスロード
- field: load.system
type: 1
i18n:
zh-CN: 系统负载
en-US: Load System
ja-JP: システムロード
- field: load.systemAverage
type: 1
i18n:
zh-CN: 系统平均负载
en-US: Load System Average
ja-JP: システムの平均ロード
- field: thread.count
type: 1
i18n:
zh-CN: 线程数
en-US: Thread Count
ja-JP: スレッド数
- field: thread.peakCount
type: 1
i18n:
zh-CN: 线程峰值
en-US: Thread Peak Count
ja-JP: 最大スレッド数
- field: cluster.timeDiff
type: 1
i18n:
zh-CN: 集群时间差
en-US: Cluster Time Diff
ja-JP: クラスター間の時差
- field: event.q.size
type: 1
i18n:
zh-CN: 事件队列大小
en-US: Event Queue Size
ja-JP: イベントキューのサイズ
- field: executor.q.async.size
type: 1
i18n:
zh-CN: 异步执行队列大小
en-US: Executor Queue Async Size
ja-JP: 非同期実行キューのサイズ
- field: executor.q.client.size
type: 1
i18n:
zh-CN: 客户端执行队列大小
en-US: Executor Queue Client Size
ja-JP: クライアントが実行するキューのサイズ
- field: executor.q.client.query.size
type: 1
i18n:
zh-CN: 客户端查询队列大小
en-US: Executor Queue Client Query Size
ja-JP: クライアントが実行するクエリキューのサイズ
- field: executor.q.client.blocking.size
type: 1
i18n:
zh-CN: 客户端阻塞队列大小
en-US: Executor Queue Client Blocking Size
ja-JP: クライアントが実行するブロッキングキューのサイズ
- field: executor.q.query.size
type: 1
i18n:
zh-CN: 查询队列大小
en-US: Executor Queue Query Size
ja-JP: クエリキューのサイズ
- field: executor.q.scheduled.size
type: 1
i18n:
zh-CN: 定时执行队列大小
en-US: Executor Queue Scheduled Size
ja-JP: スケジュールされたキューのサイズ
- field: executor.q.io.size
type: 1
i18n:
zh-CN: IO队列大小
en-US: Executor Queue IO Size
ja-JP: IOキューのサイズ
- field: executor.q.system.size
type: 1
i18n:
zh-CN: 系统执行队列大小
en-US: Executor Queue System Size
ja-JP: システムキューのサイズ
- field: executor.q.operations.size
type: 1
i18n:
zh-CN: 操作队列大小
en-US: Executor Queue Operations Size
ja-JP: 操作キューのサイズ
- field: executor.q.priorityOperation.size
type: 1
i18n:
zh-CN: 优先操作队列大小
en-US: Executor Queue Priority Operation Size
ja-JP: 優先操作キューのサイズ
- field: operations.completed.count
type: 1
i18n:
zh-CN: 完成操作次数
en-US: Operations Completed Count
ja-JP: 操作完了の回数
- field: executor.q.mapLoad.size
type: 1
i18n:
zh-CN: 映射加载队列大小
en-US: Executor Queue Map Load Size
ja-JP: Mapからロードするキューのサイズ
- field: executor.q.mapLoadAllKeys.size
type: 1
i18n:
zh-CN: 映射加载所有键大小
en-US: Executor Queue Map Load All Keys Size
ja-JP: Mapから全てのキーをロードするキューのサイズ
- field: executor.q.cluster.size
type: 1
i18n:
zh-CN: 集群执行队列大小
en-US: Executor Queue Cluster Size
ja-JP: クラスターキューのサイズ
- field: executor.q.response.size
type: 1
i18n:
zh-CN: 响应队列大小
en-US: Executor Queue Response Size
ja-JP: 応答キューのサイズ
- field: operations.running.count
type: 1
i18n:
zh-CN: 正在运行的操作数量
en-US: Operations Running Count
ja-JP: 実行中のキューのサイズ
- field: operations.pending.invocations.percentage
type: 1
i18n:
zh-CN: 待处理调用百分比
en-US: Operations Pending Invocations Percentage
ja-JP: 待機中の操作の比率
- field: operations.pending.invocations.count
type: 1
i18n:
zh-CN: 待处理调用数量
en-US: Operations Pending Invocations Count
ja-JP: 待機中の操作数
- field: proxy.count
type: 1
i18n:
zh-CN: 代理数量
en-US: Proxy Count
ja-JP: プロキシ数
- field: clientEndpoint.count
type: 1
i18n:
zh-CN: 客户端端点数量
en-US: Client Endpoint Count
ja-JP: クライアントエンドポイントの数
- field: connection.active.count
type: 1
i18n:
zh-CN: 活动连接数
en-US: Connection Active Count
ja-JP: アクティブな接続数
- field: client.connection.count
type: 1
i18n:
zh-CN: 客户端连接数
en-US: Client Connection Count
ja-JP: クライアント接続数
- field: connection.count
type: 1
i18n:
zh-CN: 总连接数
en-US: Connection Count
ja-JP: 接続総数
protocol: http
http:
host: ^_^host^_^
@@ -1,863 +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 categoryservice-application service monitoring db-database monitoring mid-middleware custom-custom monitoring os-operating system monitoring
category: server
# The monitoring type eg: linux windows tomcat mysql aws...
app: synology
# The monitoring i18n name
name:
zh-CN: Synology NAS
en-US: Synology NAS
ja-JP: Synology NAS
# The description and help of this monitoring type
help:
zh-CN: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-snmp'> SNMP 协议</a> 对 Synology NAS 的通用指标进行采集监控。<br><span class='help_module_span'>注意⚠️Synology NAS 要开启 SNMP 服务,<a class='help_module_content' href='https://kb.synology.cn/zh-cn/DSM/help/DSM/AdminCenter/system_snmp'>点击查看开启步骤</a>。</span>您可以点击 “<i>新建 Synology NAS</i>” 并进行配置SNMP相关参数添加,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat uses <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-snmp'> SNMP Protocol</a> to monitoring Synology NAS general performance metrics. <br><span class='help_module_span'>Note⚠️:Synology NAS need enable the SNMP services <a class='help_module_content' href='https://kb.synology.com/en-global/DSM/help/DSM/AdminCenter/system_snmp'>Click here to view the specific steps.</a></span> You can click the "<i>Synology NAS</i>" button and config snmp params to add monitor or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-snmp'> SNMP 协议</a> 对 Synology NAS 的通用指标进行采集监控。<br><span class='help_module_span'>注意⚠️Synology NAS 需要开启 SNMP 服务,<a class='help_module_content' href='https://kb.synology.com/zh-tw/DSM/help/DSM/AdminCenter/system_snmp'>点击查看开启步骤</a>。</span>您可以点击 “<i>新建 Synology NAS</i>” 并进行配置SNMP相关参数添加,或者选择“<i>更多操作</i>”,导入已有配置。
ja-JP: Hertzbeat は <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-snmp'> SNMP プロトコルを介して</a> Synology NAS 一般的なメトリクスを監視します。<br><span class='help_module_span'>注意⚠️Synology NAS で SNMP サービスを有効にする必要があります,<a class='help_module_content' href='https://kb.synology.com/ja-jp/DSM/help/DSM/AdminCenter/system_snmp'>クリックしてガイドを見ます</a>。<br>「<i>新規 Synology NAS</i>」をクリックしてSNMPなどのパラメタを設定した後、新規することができます。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/synology_nas
en-US: https://hertzbeat.apache.org/docs/help/synology_nas
# Input params define for monitoring(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: Target 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
- 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: 161
# field-param field key
- field: snmpVersion
# name-param field display i18n name
name:
zh-CN: SNMP 版本
en-US: SNMP Version
ja-JP: SNMPバージョン
# type-param field type(radio mapping the html radio tag)
type: radio
# required-true or false
required: true
# when type is radio checkbox, use option to show optional values {name1:value1,name2:value2}
options:
- label: SNMPv1
value: 0
- label: SNMPv2c
value: 1
- label: SNMPv3
value: 3
# field-param field key
- field: community
# name-param field display i18n name
name:
zh-CN: SNMP 团体字
en-US: SNMP Community
ja-JP: SNMPコミュニティ
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 100
# required-true or false
required: false
# param field input placeholder
placeholder: 'Snmp community for v1 v2c'
# dependent parameter values list
depend:
snmpVersion:
- 0
- 1
# field-param field key
- field: username
# name-param field display i18n name
name:
zh-CN: SNMP username
en-US: SNMP username
ja-JP: SNMPユーザー名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 50
# required-true or false
required: false
# param field input placeholder
placeholder: 'Snmp username for v3'
# dependent parameter values list
depend:
snmpVersion:
- 3
# field-param field key
- field: contextName
# name-param field display i18n name
name:
zh-CN: SNMP contextName
en-US: SNMP contextName
ja-JP: SNMPコンテキスト名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 100
# required-true or false
required: false
# param field input placeholder
placeholder: 'Snmp contextName for v3'
# dependent parameter values list
depend:
snmpVersion:
- 3
# field-param field key
- field: authPassphrase
# name-param field display i18n name
name:
zh-CN: SNMP authPassword
en-US: SNMP authPassword
ja-JP: SNMP認証パスワード
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 100
# required-true or false
required: false
# param field input placeholder
placeholder: 'Snmp authPassword for v3'
# dependent parameter values list
depend:
snmpVersion:
- 3
# field-param field key
- field: authPasswordEncryption
# name-param field display i18n name
name:
zh-CN: authPassword 加密方式
en-US: authPassword Encryption
ja-JP: 認証暗号
# type-param field type(radio mapping the html radio tag)
type: radio
# required-true or false
required: false
# when type is radio checkbox, use option to show optional values {name1:value1,name2:value2}
options:
- label: MD5
value: 0
- label: SHA1
value: 1
# dependent parameter values list
depend:
snmpVersion:
- 3
# field-param field key
- field: privPassphrase
# name-param field display i18n name
name:
zh-CN: SNMP privPassphrase
en-US: SNMP privPassphrase
ja-JP: SNMPパスワードフレーズ
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 100
# required-true or false
required: false
# param field input placeholder
placeholder: 'Snmp authPassword for v3'
# dependent parameter values list
depend:
snmpVersion:
- 3
# field-param field key
- field: privPasswordEncryption
# name-param field display i18n name
name:
zh-CN: privPassword 加密方式
en-US: privPassword Encryption
ja-JP: パスワードの暗号
# type-param field type(radio mapping the html radio tag)
type: radio
# required-true or false
required: false
# when type is radio checkbox, use option to show optional values {name1:value1,name2:value2}
options:
- label: DES
value: 0
- label: AES128
value: 1
# dependent parameter values list
depend:
snmpVersion:
- 3
# field-param field key
- field: timeout
# name-param field display i18n name
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
ja-JP: タイムアウト(ms)
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
range: '[0,100000]'
# required-true or false
required: false
# hide-is hide this field and put it in advanced layout
hide: true
# default value
defaultValue: 6000
# collect metrics config list
metrics:
# metrics - system
- name: system
i18n:
zh-CN: 系统
en-US: System
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
fields:
- field: modelName
type: 1
i18n:
zh-CN: 型号
en-US: Name
ja-JP: モデル
- field: serialNumber
type: 1
i18n:
zh-CN: 序列号
en-US: Serial Number
ja-JP: シリアル番号
- field: version
type: 1
i18n:
zh-CN: DSM 版本
en-US: Version
ja-JP: DSM バージョン
- field: controllerNumber
type: 1
i18n:
zh-CN: 控制器编号
en-US: Number of Users
ja-JP: コントローラー番号
protocol: snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp username
username: ^_^username^_^
# snmp authPassphrase
authPassphrase: ^_^authPassphrase^_^
# snmp privPassphrase
privPassphrase: ^_^privPassphrase^_^
# snmp privPasswordEncryption
privPasswordEncryption: ^_^privPasswordEncryption^_^
# snmp authPasswordEncryption
authPasswordEncryption: ^_^authPasswordEncryption^_^
# contextName
contextName: ^_^contextName^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
community: ^_^community^_^
# snmp version
version: ^_^snmpVersion^_^
# snmp operation: get, walk
operation: walk
oids:
modelName: 1.3.6.1.4.1.6574.1.5.1
serialNumber: 1.3.6.1.4.1.6574.1.5.2
version: 1.3.6.1.4.1.6574.1.5.3
controllerNumber: 1.3.6.1.4.1.6574.1.6
- name: status
i18n:
zh-CN: 状态
en-US: Status
ja-JP: ステータス
priority: 1
fields:
- field: powerStatus
type: 0
i18n:
zh-CN: 电源
en-US: Power
ja-JP: 電源
- field: systemFanStatus
type: 0
i18n:
zh-CN: 系统风扇
en-US: System Fan
ja-JP: システムファン
- field: cpuFanStatus
type: 0
i18n:
zh-CN: CPU 风扇
en-US: CPU Fan
ja-JP: CPUファン
- field: systemStatus
type: 0
i18n:
zh-CN: 系统分区
en-US: System Partition
ja-JP: システムパーティション
- field: thermalStatus
type: 0
i18n:
zh-CN: 散热状态
en-US: Thermal Partition
ja-JP: 熱源
- field: temperature
type: 0
i18n:
zh-CN: 温度
en-US: Temperature
ja-JP: 温度
- field: cpuUtilization
type: 0
i18n:
zh-CN: CPU 利用率
en-US: CPU Utilization
ja-JP: CPU 使用率
- field: memUtilization
type: 0
i18n:
zh-CN: 内存利用率
en-US: Memory Utilization
ja-JP: メモリ使用率
protocol: snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp username
username: ^_^username^_^
# snmp authPassphrase
authPassphrase: ^_^authPassphrase^_^
# snmp privPassphrase
privPassphrase: ^_^privPassphrase^_^
# snmp privPasswordEncryption
privPasswordEncryption: ^_^privPasswordEncryption^_^
# snmp authPasswordEncryption
authPasswordEncryption: ^_^authPasswordEncryption^_^
# contextName
contextName: ^_^contextName^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
community: ^_^community^_^
# snmp version
version: ^_^snmpVersion^_^
# snmp operation: get, walk
operation: walk
oids:
systemStatus: 1.3.6.1.4.1.6574.1.1
temperature: 1.3.6.1.4.1.6574.1.2
powerStatus: 1.3.6.1.4.1.6574.1.3
systemFanStatus: 1.3.6.1.4.1.6574.1.4.1
cpuFanStatus: 1.3.6.1.4.1.6574.1.4.2
cpuUtilization: 1.3.6.1.4.1.6574.1.7.1
memUtilization: 1.3.6.1.4.1.6574.1.7.2
thermalStatus: 1.3.6.1.4.1.6574.1.78
- name: disk
i18n:
zh-CN: 硬盘
en-US: Disk
ja-JP: ディスク
priority: 2
fields:
- field: diskID
type: 1
i18n:
zh-CN: ID
en-US: ID
ja-JP: ディスクID
- field: diskModel
type: 1
i18n:
zh-CN: 型号
en-US: Model
ja-JP: ディスクモデル
- field: diskType
type: 1
i18n:
zh-CN: 类型
en-US: Type
ja-JP: ディスクタイプ
- field: diskStatus
type: 1
i18n:
zh-CN: 状态
en-US: Status
ja-JP: ディスクステータス
- field: diskTemperature
type: 0
i18n:
zh-CN: 温度
en-US: Temperature
ja-JP: ディスク温度
- field: diskRole
type: 1
i18n:
zh-CN: 作用
en-US: Role
ja-JP: ディスク作用
- field: diskRetry
type: 0
i18n:
zh-CN: 连接重试次数
en-US: Retry count
ja-JP: ディスクリミネーション
- field: diskBadSector
type: 0
i18n:
zh-CN: 坏扇区数
en-US: Bad Sector
ja-JP: ディスクバッドセクタ
- field: diskIdentifyFail
type: 0
i18n:
zh-CN: 计数失败
en-US: Identify Fail
ja-JP: ディスク識別失敗
- field: diskRemainLife
type: 0
i18n:
zh-CN: 预计剩余寿命
en-US: Remain Life
ja-JP: ディスク残り寿命
- field: diskName
type: 1
i18n:
zh-CN: 保留名称
en-US: Disk Name
ja-JP: ディスク名
- field: diskHealthStatus
type: 0
i18n:
zh-CN: 健康状况
en-US: Health Status
ja-JP: ディスクヘルスステータス
protocol: snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp username
username: ^_^username^_^
# snmp authPassphrase
authPassphrase: ^_^authPassphrase^_^
# snmp privPassphrase
privPassphrase: ^_^privPassphrase^_^
# snmp privPasswordEncryption
privPasswordEncryption: ^_^privPasswordEncryption^_^
# snmp authPasswordEncryption
authPasswordEncryption: ^_^authPasswordEncryption^_^
# contextName
contextName: ^_^contextName^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
community: ^_^community^_^
# snmp version
version: ^_^snmpVersion^_^
# snmp operation: get, walk
operation: walk
oids:
diskID: 1.3.6.1.4.1.6574.2.1.1.2
diskModel: 1.3.6.1.4.1.6574.2.1.1.3
diskType: 1.3.6.1.4.1.6574.2.1.1.4
diskStatus: 1.3.6.1.4.1.6574.2.1.1.5
diskTemperature: 1.3.6.1.4.1.6574.2.1.1.6
diskRole: 1.3.6.1.4.1.6574.2.1.1.7
diskRetry: 1.3.6.1.4.1.6574.2.1.1.8
diskBadSector: 1.3.6.1.4.1.6574.2.1.1.9
diskIdentifyFail: 1.3.6.1.4.1.6574.2.1.1.10
diskRemainLife: 1.3.6.1.4.1.6574.2.1.1.11
diskName: 1.3.6.1.4.1.6574.2.1.1.12
diskHealthStatus: 1.3.6.1.4.1.6574.2.1.1.13
- name: raid
i18n:
zh-CN: RAID
en-US: RAID
ja-JP: RAID
priority: 3
fields:
- field: raidName
type: 1
i18n:
zh-CN: 名称
en-US: Name
ja-JP:
- field: raidStatus
type: 0
i18n:
zh-CN: 状态
en-US: Status
ja-JP: ディスクモデル
- field: raidFreeSize
type: 0
i18n:
zh-CN: 可用容量
en-US: Free Size
ja-JP: ディスク残りサイズ
- field: raidTotalSize
type: 0
i18n:
zh-CN: 总大小
en-US: Total Size
ja-JP: ディスクサイズ
- field: raidHotspareCnt
type: 0
i18n:
zh-CN: 热备数
en-US: Hot Spare Count
ja-JP: ディスクホットスパア数
protocol: snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp username
username: ^_^username^_^
# snmp authPassphrase
authPassphrase: ^_^authPassphrase^_^
# snmp privPassphrase
privPassphrase: ^_^privPassphrase^_^
# snmp privPasswordEncryption
privPasswordEncryption: ^_^privPasswordEncryption^_^
# snmp authPasswordEncryption
authPasswordEncryption: ^_^authPasswordEncryption^_^
# contextName
contextName: ^_^contextName^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
community: ^_^community^_^
# snmp version
version: ^_^snmpVersion^_^
# snmp operation: get, walk
operation: walk
oids:
raidName: 1.3.6.1.4.1.6574.3.1.1.2
raidStatus: 1.3.6.1.4.1.6574.3.1.1.3
raidFreeSize: 1.3.6.1.4.1.6574.3.1.1.4
raidTotalSize: 1.3.6.1.4.1.6574.3.1.1.5
raidHotspareCnt: 1.3.6.1.4.1.6574.3.1.1.6
- name: smart
i18n:
zh-CN: S.M.A.R.T
en-US: S.M.A.R.T
ja-JP: S.M.A.R.T
priority: 4
fields:
- field: diskSMARTInfoDevName
type: 1
i18n:
zh-CN: 设备名称
en-US: Device Name
ja-JP: ディスク名
- field: diskSMARTAttrName
type: 1
i18n:
zh-CN: 属性名
en-US: Attribute Name
ja-JP: ディスク属性名
- field: diskSMARTAttrId
type: 1
i18n:
zh-CN: 属性 ID
en-US: Attribute ID
ja-JP: ディスク属性ID
- field: diskSMARTAttrCurrent
type: 0
i18n:
zh-CN: 当前值
en-US: Attribute Current
ja-JP: ディスク属性現在値
- field: diskSMARTAttrWorst
type: 0
i18n:
zh-CN: 最差值
en-US: Attribute Worst
ja-JP: ディスク属性最差値
- field: diskSMARTAttrThreshold
type: 0
i18n:
zh-CN: 阈值
en-US: Attribute Threshold
ja-JP: ディスク属性しきい値
- field: diskSMARTAttrRaw
type: 0
i18n:
zh-CN: 原始值
en-US: Raw
ja-JP: ディスク属性原始値
- field: diskSMARTAttrStatus
type: 1
i18n:
zh-CN: 信息状态
en-US: Attribute Status
ja-JP: ディスク属性情報ステータス
protocol: snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp username
username: ^_^username^_^
# snmp authPassphrase
authPassphrase: ^_^authPassphrase^_^
# snmp privPassphrase
privPassphrase: ^_^privPassphrase^_^
# snmp privPasswordEncryption
privPasswordEncryption: ^_^privPasswordEncryption^_^
# snmp authPasswordEncryption
authPasswordEncryption: ^_^authPasswordEncryption^_^
# contextName
contextName: ^_^contextName^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
community: ^_^community^_^
# snmp version
version: ^_^snmpVersion^_^
# snmp operation: get, walk
operation: walk
oids:
diskSMARTInfoDevName: 1.3.6.1.4.1.6574.5.1.1.2
diskSMARTAttrName: 1.3.6.1.4.1.6574.5.1.1.3
diskSMARTAttrId: 1.3.6.1.4.1.6574.5.1.1.4
diskSMARTAttrCurrent: 1.3.6.1.4.1.6574.5.1.1.5
diskSMARTAttrWorst: 1.3.6.1.4.1.6574.5.1.1.6
diskSMARTAttrThreshold: 1.3.6.1.4.1.6574.5.1.1.7
diskSMARTAttrRaw: 1.3.6.1.4.1.6574.5.1.1.8
diskSMARTAttrStatus: 1.3.6.1.4.1.6574.5.1.1.9
- name: spaceio
i18n:
zh-CN: 存储空间 I/O
en-US: Space I/O
ja-JP: スペースI/O
priority: 5
fields:
- field: spaceIODevice
type: 1
i18n:
zh-CN: 设备名称
en-US: Device Name
ja-JP: ディスク名
- field: spaceIOReads
type: 0
i18n:
zh-CN: 读取访问次数
en-US: Read Accesses Count
ja-JP: ディスク属性読み込みアクセス回数
- field: spaceIOWrites
type: 0
i18n:
zh-CN: 写入访问次数
en-US: Write Accesses Count
ja-JP: ディスク属性書き込みアクセス回数
- field: spaceIOLA
type: 0
unit: '%'
i18n:
zh-CN: 硬盘负载
en-US: The load of disk
ja-JP: ディスク属性ディスクロード
- field: spaceIOLA1
type: 0
unit: '%'
i18n:
zh-CN: 1 分钟平均负载
en-US: The 1-minute average load of disk
ja-JP: 1分平均負荷
- field: spaceIOLA5
type: 0
unit: '%'
i18n:
zh-CN: 5分钟平均负载
en-US: The 5-minute average load of disk
ja-JP: 5分平均負荷
- field: spaceIOLA15
type: 0
unit: '%'
i18n:
zh-CN: 15 分钟平均负载
en-US: The-15 minute average load of disk
ja-JP: 15分平均負荷
- field: spaceUUID
type: 1
i18n:
zh-CN: 卷UUID
en-US: UUID
ja-JP: UUID
protocol: snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp username
username: ^_^username^_^
# snmp authPassphrase
authPassphrase: ^_^authPassphrase^_^
# snmp privPassphrase
privPassphrase: ^_^privPassphrase^_^
# snmp privPasswordEncryption
privPasswordEncryption: ^_^privPasswordEncryption^_^
# snmp authPasswordEncryption
authPasswordEncryption: ^_^authPasswordEncryption^_^
# contextName
contextName: ^_^contextName^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
community: ^_^community^_^
# snmp version
version: ^_^snmpVersion^_^
# snmp operation: get, walk
operation: walk
oids:
spaceIODevice: 1.3.6.1.4.1.6574.102.1.1.2
spaceIOReads: 1.3.6.1.4.1.6574.102.1.1.5
spaceIOWrites: 1.3.6.1.4.1.6574.102.1.1.6
spaceIOLA: 1.3.6.1.4.1.6574.102.1.1.7
spaceIOLA1: 1.3.6.1.4.1.6574.102.1.1.8
spaceIOLA5: 1.3.6.1.4.1.6574.102.1.1.9
spaceIOLA15: 1.3.6.1.4.1.6574.102.1.1.10
spaceUUID: 1.3.6.1.4.1.6574.102.1.1.13
- name: storageio
i18n:
zh-CN: 硬盘 I/O
en-US: Storage I/O
ja-JP: ハードディスクI/O
priority: 6
fields:
- field: storageIODevice
type: 1
i18n:
zh-CN: 设备名称
en-US: Device Name
ja-JP: ディスク名
- field: storageIOReads
type: 0
i18n:
zh-CN: 读取访问次数
en-US: Read Accesses Count
ja-JP: ディスク属性読み込みアクセス回数
- field: storageIOWrites
type: 0
i18n:
zh-CN: 写入访问次数
en-US: Write Accesses Count
ja-JP: ディスク属性書き込みアクセス回数
- field: storageIOLA
type: 0
unit: '%'
i18n:
zh-CN: 硬盘负载
en-US: The load of disk
ja-JP: ディスク属性ディスクロード
- field: storageIOLA1
type: 0
unit: '%'
i18n:
zh-CN: 1 分钟平均负载
en-US: The 1-minute average load of disk
ja-JP: 1分平均負荷
- field: storageIOLA5
type: 0
unit: '%'
i18n:
zh-CN: 5分钟平均负载
en-US: The 5-minute average load of disk
ja-JP: 5分平均負荷
- field: storageIOLA15
type: 0
unit: '%'
i18n:
zh-CN: 15 分钟平均负载
en-US: The-15 minute average load of disk
ja-JP: 15分平均負荷
- field: storageIODeviceSerial
type: 1
i18n:
zh-CN: 序列号
en-US: Serial Number
ja-JP: シリアルナンバー
protocol: snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp username
username: ^_^username^_^
# snmp authPassphrase
authPassphrase: ^_^authPassphrase^_^
# snmp privPassphrase
privPassphrase: ^_^privPassphrase^_^
# snmp privPasswordEncryption
privPasswordEncryption: ^_^privPasswordEncryption^_^
# snmp authPasswordEncryption
authPasswordEncryption: ^_^authPasswordEncryption^_^
# contextName
contextName: ^_^contextName^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
community: ^_^community^_^
# snmp version
version: ^_^snmpVersion^_^
# snmp operation: get, walk
operation: walk
oids:
storageIODevice: 1.3.6.1.4.1.6574.101.1.1.2
storageIOReads: 1.3.6.1.4.1.6574.101.1.1.5
storageIOWrites: 1.3.6.1.4.1.6574.101.1.1.6
storageIOLA: 1.3.6.1.4.1.6574.101.1.1.7
storageIOLA1: 1.3.6.1.4.1.6574.101.1.1.8
storageIOLA5: 1.3.6.1.4.1.6574.101.1.1.9
storageIOLA15: 1.3.6.1.4.1.6574.101.1.1.10
storageIODeviceSerial: 1.3.6.1.4.1.6574.101.1.1.13
File diff suppressed because it is too large Load Diff
@@ -21,13 +21,11 @@ app: tomcat
name:
zh-CN: Tomcat应用服务器
en-US: Tomcat WebServer
ja-JP: Tomcat WebServer
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 使用 <a href="https://hertzbeat.apache.org/docs/advanced/extend-jmx">JMX 协议</a> 对 Tomcat 的通用性能指标(基础信息,内存池,类加载,线程信息等)进行采集监控。<br>⚠️注意:您需要在 Tomcat 应用中开启 JMX 服务,应用启动时添加 JMX 参数, 可自定义暴露端口,对外IP。<a href="https://hertzbeat.apache.org/zh-cn/docs/help/tomcat">点击查看开启步骤</a>。
en-US: HertzBeat uses <a href='https://hertzbeat.apache.org/docs/advanced/extend-jmx'>JMX Protocol</a> to monitoring and collect general performance metric of Tomcat. <br>⚠️Note:You need to enable JMX services in Tomcat application, and add the JXM parameters when the application start. You can also customize external IP address and exposed port.<a href='https://hertzbeat.apache.org/docs/help/tomcat'>Click here to view the activation steps.</a>"
zh-TW: HertzBeat 使用 <a href="https://hertzbeat.apache.org/docs/advanced/extend-jmx">JMX 協議</a> 對 Tomcat 的通用性能指標(基礎信息,內存池,類加載,線程信息等)進行采集監控。<br>⚠️注意:您需要在 Tomcat 應用中開啓 JMX 服務,應用啓動時添加 JMX 參數, 可自定義暴露端口,對外IP。<a href="https://hertzbeat.apache.org/zh-cn/docs/help/tomcat">點擊查看開啓步驟</a>。
ja-JP: HertzBeat は <a href="https://hertzbeat.apache.org/docs/advanced/extend-jmx"> JMXプロトコルを介して</a> Tomcat の一般的なパフォーマンスのメトリクスを監視します。⚠️注意:Tomcat応用 で JMXサービス を有効にする必要があります。<a href="https://hertzbeat.apache.org/docs/help/tomcat">クリックしてガイドを見ます</a>。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/tomcat
en-US: https://hertzbeat.apache.org/docs/help/tomcat
@@ -39,7 +37,6 @@ params:
name:
zh-CN: 目标Host
en-US: Target Host
ja-JP: 目標ホスト
# type-param field type(most mapping the html input type)
type: host
# required-true or false
@@ -50,7 +47,6 @@ params:
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
@@ -65,7 +61,6 @@ params:
name:
zh-CN: JMX URL
en-US: JMX URL
ja-JP: JMX URL
# type-param field type(most mapping the html input type)
type: text
# required-true or false
@@ -80,7 +75,6 @@ params:
name:
zh-CN: 用户名
en-US: Username
ja-JP: ユーザー名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
@@ -95,7 +89,6 @@ params:
name:
zh-CN: 密码
en-US: Password
ja-JP: パスワード
# type-param field type(most mapping the html input tag)
type: password
# required-true or false
@@ -109,7 +102,6 @@ metrics:
i18n:
zh-CN: Tomcat 信息
en-US: Tomcat Server
ja-JP: Tomcatサーバー
# 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
@@ -121,31 +113,26 @@ metrics:
i18n:
zh-CN: 服务信息
en-US: Server Info
ja-JP: サーバー情報
- field: serverNumber
type: 1
i18n:
zh-CN: 服务版本
en-US: Server Number
ja-JP: サーバーバージョン
- field: serverBuilt
type: 1
i18n:
zh-CN: Server Built
en-US: Server Built
ja-JP: サーバービルド
- field: port
type: 1
i18n:
zh-CN: 端口
en-US: Port
ja-JP: ポート
- field: address
type: 1
i18n:
zh-CN: 地址
en-US: Address
ja-JP: アドレス
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: jmx
# the config content when protocol is http
@@ -168,7 +155,6 @@ metrics:
i18n:
zh-CN: 内存池
en-US: Memory Pool
ja-JP: メモリプール
fields:
- field: name
type: 1
@@ -176,35 +162,30 @@ metrics:
i18n:
zh-CN: 指标名称
en-US: Name
ja-JP: 名前
- field: committed
type: 0
unit: MB
i18n:
zh-CN: 已分配内存
en-US: Committed
ja-JP: コミットされたメモリ
- field: init
type: 0
unit: MB
i18n:
zh-CN: 初始化内存
en-US: Init
ja-JP: イニシャルメモリ
- field: max
type: 0
unit: MB
i18n:
zh-CN: 最大内存
en-US: Max
ja-JP: 最大メモリ
- field: used
type: 0
unit: MB
i18n:
zh-CN: 已使用内存
en-US: Used
ja-JP: 使用したメモリ
units:
- committed=B->MB
- init=B->MB
@@ -241,7 +222,6 @@ metrics:
i18n:
zh-CN: 类加载信息
en-US: Class Loading
ja-JP: クラスローディング情報
# collect metrics content
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
@@ -250,19 +230,16 @@ metrics:
i18n:
zh-CN: 当前已加载类数量
en-US: Loaded Class Count
ja-JP: ロードされたクラス数
- field: TotalLoadedClassCount
type: 0
i18n:
zh-CN: 已加载类总数量
en-US: Total Loaded Class Count
ja-JP: ロードされたクラス総数
- field: UnloadedClassCount
type: 0
i18n:
zh-CN: 未加载类总数量
en-US: Unloaded Class Count
ja-JP: アンロードされたクラス総数
protocol: jmx
jmx:
host: ^_^host^_^
@@ -277,7 +254,6 @@ metrics:
i18n:
zh-CN: 线程信息
en-US: Thread
ja-JP: スレッド情報
# collect metrics content
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
@@ -286,39 +262,33 @@ metrics:
i18n:
zh-CN: 已启动线程总数
en-US: Total Started Thread Count
ja-JP: スレッド総数
- field: ThreadCount
type: 0
i18n:
zh-CN: 活跃线程数
en-US: Thread Count
ja-JP: 活躍スレッド数
- field: PeakThreadCount
type: 0
i18n:
zh-CN: 最大峰值线程数
en-US: Peak Thread Count
ja-JP: 最大スレッド数
- field: DaemonThreadCount
type: 0
i18n:
zh-CN: 活跃守护线程数
en-US: Daemon Thread Count
ja-JP: デーモンスレッド数
- field: CurrentThreadUserTime
type: 0
unit: s
i18n:
zh-CN: 线程占用的CPU时间(用户态)
en-US: Current Thread User Time
ja-JP: 現在のスレッドユーザー時間
- field: CurrentThreadCpuTime
type: 0
unit: s
i18n:
zh-CN: 线程占用的CPU时间
en-US: Current Thread CPU Time
ja-JP: 現在のスレッドシステム時間
units:
- CurrentThreadUserTime=NS->S
- CurrentThreadCpuTime=NS->S
@@ -335,7 +305,6 @@ metrics:
i18n:
zh-CN: 应用信息
en-US: Application
ja-JP: 応用情報
priority: 4
fields:
- field: name
@@ -344,99 +313,83 @@ metrics:
i18n:
zh-CN: 名称
en-US: Name
ja-JP: 名前
- field: acceptCount
type: 0
i18n:
zh-CN: 接收请求数
en-US: Accept Count
ja-JP: 受け入れたリクエスト数
- field: acceptorThreadCount
type: 0
i18n:
zh-CN: 接收处理线程数
en-US: Acceptor Thread Count
ja-JP: アクセプタスレッド数
- field: acceptorThreadPriority
type : 0
i18n:
zh-CN: 接收线程级别
en-US: Acceptor Thread Priority
ja-JP: アクセプタスレッド優先度
- field: connectionTimeout
type: 0
unit: ms
i18n:
zh-CN: 链接超时时间
en-US: Connection Timeout
ja-JP: 接続のタイムアウト
- field: currentThreadCount
type: 0
i18n:
zh-CN: 当前线程数
en-US: Current Thread Count
ja-JP: 現在のスレッド数
- field: currentThreadsBusy
type: 0
i18n:
zh-CN: 繁忙线程数
en-US: Current Threads Busy
ja-JP: 現在の忙しいスレッド数
- field: keepAliveCount
type: 0
i18n:
zh-CN: 心跳保持链接数量
en-US: Keep Alive Count
ja-JP: ハートビート数量
- field: keepAliveTimeout
type: 0
unit: ms
i18n:
zh-CN: 心跳超时时间
en-US: Keep Alive Timeout
ja-JP: ハートビートのタイムアウト
- field: maxConnections
type: 0
i18n:
zh-CN: 最大链接数
en-US: Max Connections
ja-JP: 最大接続数
- field: maxKeepAliveRequests
type: 0
i18n:
zh-CN: 最大链接保持请求
en-US: Max KeepAlive Requests
ja-JP: 最大KeepAliveリクエスト数
- field: maxThreads
type: 0
i18n:
zh-CN: 最大线程数
en-US: Max Threads
ja-JP: 最大スレッド数
- field: minSpareThreads
type: 0
i18n:
zh-CN: 最小备用线程数
en-US: Min Spare Threads
ja-JP: 最小予備スレッド数
- field: pollerThreadCount
type: 0
i18n:
zh-CN: 轮询线程数
en-US: Poller Thread Count
ja-JP: ポーラースレッド数
- field: pollerThreadPriority
type: 0
i18n:
zh-CN: 轮询线程级别
en-US: Poller Thread Priority
ja-JP: ポーラースレッド優先度
- field: running
type: 1
i18n:
zh-CN: 运行中
en-US: Running
ja-JP: 実行中
protocol: jmx
jmx:
host: ^_^host^_^
@@ -21,13 +21,11 @@ app: ubuntu
name:
zh-CN: Ubuntu Linux
en-US: Ubuntu Linux
ja-JP: Ubuntu Linux
# The description and help of this monitoring type
help:
zh-CN: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH 协议</a> 对 Ubuntu 操作系统的通用性能指标 (系统信息、CPU、内存、磁盘、网卡、文件系统、TOP资源进程等) 进行采集监控。<br>您可以点击“<i>新建 Ubuntu</i>”并配置HOST端口账户等相关参数进行添加,支持SSH账户密码或密钥认证。或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat uses <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH protocol</a> to monitors Ubuntu operating system's general performance metrics such as cpu, memory, disk, basic, interface, disk_free, top_process etc. <br>You can click the "<i>New Ubuntu</i>" and config host port and other related params to add, auth support password or secretKey. Or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSH 协议</a> 對 Ubuntu 操作系统的通用性能指標 (系統信息、CPU、內存、磁盤、網卡、文件系統、TOP資源進程等) 進行採集監控。<br>您可以點擊“<i>新建 Ubuntu</i>”並配置HOST端口賬戶等相關參數進行添加,支持SSH賬戶密碼或密鑰認證。或者選擇“<i>更多操作</i>”,導入已有配寘。
ja-JP: Hertzbeat は <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-ssh'> SSHプロトコルを介して</a> Ubuntuシステムの一般的なパフォーマンスのメトリクスを監視します。<br>「<i>新規 Ubuntu</i>」をクリックしてホストなどのパラメタを設定した後、新規することができます。SSHまたはキー認証をサポートします。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/ubuntu
en-US: https://hertzbeat.apache.org/docs/help/ubuntu
@@ -39,7 +37,6 @@ params:
name:
zh-CN: 目标Host
en-US: Target Host
ja-JP: 目標ホスト
# type-param field type(most mapping the html input type)
type: host
# required-true or false
@@ -50,7 +47,6 @@ params:
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
@@ -65,7 +61,6 @@ params:
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
ja-JP: タイムアウト(ms)
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
@@ -80,7 +75,6 @@ params:
name:
zh-CN: 复用连接
en-US: Reuse Connection
ja-JP: 接続再利用
# type-param field type(most mapping the html input type)
type: boolean
# required-true or false
@@ -92,7 +86,6 @@ params:
name:
zh-CN: 使用代理
en-US: Use Proxy Connection
ja-JP: プロキシ接続利用
# type-param field type(most mapping the html input type)
type: boolean
# required-true or false
@@ -104,7 +97,6 @@ params:
name:
zh-CN: 用户名
en-US: Username
ja-JP: ユーザー名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
@@ -117,7 +109,6 @@ params:
name:
zh-CN: 密码
en-US: Password
ja-JP: パスワード
# type-param field type(most mapping the html input tag)
type: password
# required-true or false
@@ -128,7 +119,6 @@ params:
name:
zh-CN: 私钥
en-US: PrivateKey
ja-JP: 秘密鍵
# type-param field type(most mapping the html input type)
type: textarea
placeholder: -----BEGIN RSA PRIVATE KEY-----
@@ -142,7 +132,6 @@ params:
name:
zh-CN: 密钥短语
en-US: PrivateKey PassPhrase
ja-JP: 秘密鍵フレーズ
# type-param field type(most mapping the html input type)
type: password
# required-true or false
@@ -155,7 +144,6 @@ params:
name:
zh-CN: 代理主机
en-US: Proxy Host
ja-JP: プロキシホスト
# type-param field type(most mapping the html input type)
type: text
# required-true or false
@@ -167,7 +155,6 @@ params:
name:
zh-CN: 代理端口
en-US: Proxy Port
ja-JP: プロキシポート
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
@@ -184,7 +171,6 @@ params:
name:
zh-CN: 代理用户名
en-US: Proxy Username
ja-JP: プロキシユーザー名
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
@@ -199,7 +185,6 @@ params:
name:
zh-CN: 代理密码
en-US: Proxy Password
ja-JP: プロキシパスワード
# type-param field type(most mapping the html input tag)
type: password
# required-true or false
@@ -212,7 +197,6 @@ params:
name:
zh-CN: 代理主机私钥
en-US: proxyPrivateKey
ja-JP: プロキシ秘密鍵
# type-param field type(most mapping the html input type)
type: textarea
placeholder: -----BEGIN RSA PRIVATE KEY-----
@@ -227,7 +211,6 @@ metrics:
i18n:
zh-CN: 系统基本信息
en-US: Basic Info
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
@@ -240,19 +223,16 @@ metrics:
i18n:
zh-CN: 主机名称
en-US: Host Name
ja-JP: ホスト名
- field: version
type: 1
i18n:
zh-CN: 操作系统版本
en-US: System Version
ja-JP: オーエスバージョン
- field: uptime
type: 1
i18n:
zh-CN: 启动时间
en-US: Uptime
ja-JP: アップタイム
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: ssh
# the config content when protocol is ssh
@@ -292,7 +272,6 @@ metrics:
i18n:
zh-CN: CPU 信息
en-US: CPU Info
ja-JP: CPU情報
priority: 1
fields:
- field: info
@@ -300,38 +279,32 @@ metrics:
i18n:
zh-CN: 型号
en-US: Info
ja-JP: バージョン
- field: cores
type: 1
i18n:
zh-CN: 核数
en-US: Cores
ja-JP: コア数
- field: interrupt
type: 0
i18n:
zh-CN: 中断数
en-US: Interrupt
ja-JP: 割り込み数
- field: load
type: 1
i18n:
zh-CN: 负载
en-US: Load
ja-JP: ロード
- field: context_switch
type: 0
i18n:
zh-CN: 上下文切换
en-US: Context Switch
ja-JP: コンテキストスイッチ
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
ja-JP: 使用率
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- info
@@ -378,7 +351,6 @@ metrics:
i18n:
zh-CN: 内存信息
en-US: Memory Info
ja-JP: メモリ情報
priority: 2
fields:
- field: total
@@ -387,42 +359,36 @@ metrics:
i18n:
zh-CN: 总内存容量
en-US: Total Memory
ja-JP: メモリ容量
- field: used
type: 0
unit: Mb
i18n:
zh-CN: 用户程序内存量
en-US: User Program Memory
ja-JP: ユーザープログラムメモリ
- field: free
type: 0
unit: Mb
i18n:
zh-CN: 空闲内存容量
en-US: Free Memory
ja-JP: 空きメモリ
- field: buff_cache
type: 0
unit: Mb
i18n:
zh-CN: 缓存占用内存
en-US: Buff Cache Memory
ja-JP: バッファメモリ
- field: available
type: 0
unit: Mb
i18n:
zh-CN: 剩余可用内存
en-US: Available Memory
ja-JP: 使用可能のメモリ
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 内存使用率
en-US: Memory Usage
ja-JP: メモリ使用率
aliasFields:
- total
- used
@@ -465,7 +431,6 @@ metrics:
i18n:
zh-CN: 磁盘信息
en-US: Disk Info
ja-JP: ディスク情報
priority: 3
fields:
- field: disk_num
@@ -473,32 +438,27 @@ metrics:
i18n:
zh-CN: 磁盘总数
en-US: Disk Num
ja-JP: ディスク番号
- field: partition_num
type: 1
i18n:
zh-CN: 分区总数
en-US: Partition Num
ja-JP: パーティション
- field: block_write
type: 0
i18n:
zh-CN: 写磁盘块数
en-US: Block Write
ja-JP: 書き込みディスクブロック数
- field: block_read
type: 0
i18n:
zh-CN: 读磁盘块数
en-US: Block Read
ja-JP: 読み取りブロック数
- field: write_rate
type: 0
unit: iops
i18n:
zh-CN: 磁盘写速率
en-US: Write Rate
ja-JP: ディスク書き込み速度
protocol: ssh
ssh:
host: ^_^host^_^
@@ -528,7 +488,6 @@ metrics:
i18n:
zh-CN: 网卡信息
en-US: Interface Info
ja-JP: ネットワークカード情報
priority: 4
fields:
- field: interface_name
@@ -537,21 +496,18 @@ metrics:
i18n:
zh-CN: 网卡名称
en-US: Interface Name
ja-JP: ネットワークカード名
- field: receive_bytes
type: 0
unit: Mb
i18n:
zh-CN: 入站数据流量
en-US: Receive Bytes
ja-JP: 受信されたバイト数
- field: transmit_bytes
type: 0
unit: Mb
i18n:
zh-CN: 出站数据流量
en-US: Transmit Bytes
ja-JP: 転送されたバイト数
units:
- receive_bytes=B->MB
- transmit_bytes=B->MB
@@ -584,7 +540,6 @@ metrics:
i18n:
zh-CN: 文件系统
en-US: Disk Free
ja-JP: ファイルシステム
priority: 5
fields:
- field: filesystem
@@ -592,35 +547,30 @@ metrics:
i18n:
zh-CN: 文件系统
en-US: Filesystem
ja-JP: ファイルシステム
- field: used
type: 0
unit: Mb
i18n:
zh-CN: 已使用量
en-US: Used
ja-JP: 使用済み
- field: available
type: 0
unit: Mb
i18n:
zh-CN: 可用量
en-US: Available
ja-JP: 使用可能
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
ja-JP: 使用率
- field: mounted
type: 1
label: true
i18n:
zh-CN: 挂载点
en-US: Mounted
ja-JP: マウント
protocol: ssh
ssh:
host: ^_^host^_^
@@ -650,7 +600,6 @@ metrics:
i18n:
zh-CN: Top10 CPU 进程
en-US: Top10 CPU Process
ja-JP: トップ10 CPUプロセス
priority: 6
fields:
- field: pid
@@ -659,27 +608,23 @@ metrics:
i18n:
zh-CN: 进程ID
en-US: PID
ja-JP: プロセスID
- field: cpu_usage
type: 0
unit: '%'
i18n:
zh-CN: CPU占用率
en-US: CPU Usage
ja-JP: CPU使用率
- field: mem_usage
type: 0
unit: '%'
i18n:
zh-CN: 内存占用率
en-US: Memory Usage
ja-JP: メモリ使用率
- field: command
type: 1
i18n:
zh-CN: 执行命令
en-US: Command
ja-JP: コマンド
protocol: ssh
ssh:
host: ^_^host^_^
@@ -709,7 +654,6 @@ metrics:
i18n:
zh-CN: Top10 内存进程
en-US: Top10 Memory Process
ja-JP: トップ10 メモリプロセス
priority: 7
fields:
- field: pid
@@ -718,27 +662,23 @@ metrics:
i18n:
zh-CN: 进程ID
en-US: PID
ja-JP: プロセスID
- field: mem_usage
type: 0
unit: '%'
i18n:
zh-CN: 内存占用率
en-US: Memory Usage
ja-JP: メモリ使用率
- field: cpu_usage
type: 0
unit: '%'
i18n:
zh-CN: CPU占用率
en-US: CPU Usage
ja-JP: CPU使用率
- field: command
type: 1
i18n:
zh-CN: 执行命令
en-US: Command
ja-JP: コマンド
protocol: ssh
ssh:
host: ^_^host^_^
File diff suppressed because it is too large Load Diff
@@ -21,13 +21,11 @@ app: vastbase
name:
zh-CN: Vastbase数据库
en-US: Vastbase DB
ja-JP: Vastbase データベース
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> JDBC 协议</a> 通过配置 SQL 对 Vastbase 数据库的通用性能指标 (basic、state、activity etc) 进行采集监控,支持版本为 Vastbase 9.2.4+。<br>您可以点击“<i>新建 Vastbase 数据库</i>”并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat uses <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> JDBC Protocol</a> to configure SQL for collecting general metrics of Vastbase database (basic、state、activity etc). Supported version is Vastbase 9.2.4+. <br>You can click "<i>New Vastbase Database</i>" and configure it, or select "<i>More Action</i>" to import the existing configuration.
zh-TW: HertzBeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> JDBC 協議</a> 通過配置 SQL 對 Vastbase 數據庫的通用性能指標 (basic、state、activity etc)進行采集監控,支持版本爲 Vastbase 9.2.4+。<br>您可以點擊“<i>新建 Vastbase 數據庫</i>”並進行配置,或者選擇“<i>更多操作</i>”,導入已有配置。
ja-JP: Hertzbeat は <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> JDBCプロトコルを介して</a> Vastbase データベース(Vastbase 9.2.4+)の一般的なパフォーマンスのメトリクスを監視します。<br>「<i>新規 Vastbase データベース</i>」をクリックしてパラメタを設定した後、新規することができます。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/vastbase
en-US: https://hertzbeat.apache.org/docs/help/vastbase
@@ -39,7 +37,6 @@ params:
name:
zh-CN: 目标Host
en-US: Target Host
ja-JP: 目標ホスト
# type-param field type(most mapping the html input type)
type: host
# required-true or false
@@ -50,7 +47,6 @@ params:
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
@@ -63,7 +59,6 @@ params:
name:
zh-CN: 查询超时时间(ms)
en-US: Query Timeout(ms)
ja-JP: クエリタイムアウト(ms)
type: number
range: '[400,200000]'
required: false
@@ -73,7 +68,6 @@ params:
name:
zh-CN: 数据库名称
en-US: Database Name
ja-JP: データベース名
type: text
defaultValue: postgres
required: false
@@ -81,7 +75,6 @@ params:
name:
zh-CN: 用户名
en-US: Username
ja-JP: ユーザー名
type: text
limit: 50
required: false
@@ -89,14 +82,12 @@ params:
name:
zh-CN: 密码
en-US: Password
ja-JP: パスワード
type: password
required: false
- field: url
name:
zh-CN: URL
en-US: URL
ja-JP: URL
type: text
required: false
hide: true
@@ -108,7 +99,6 @@ metrics:
i18n:
zh-CN: 基本信息
en-US: Basic Info
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
@@ -121,31 +111,26 @@ metrics:
i18n:
zh-CN: 服务器版本
en-US: Server Version
ja-JP: バージョン
- field: port
type: 1
i18n:
zh-CN: 端口
en-US: Port
ja-JP: ポート
- field: server_encoding
type: 1
i18n:
zh-CN: 服务器编码
en-US: Server Encoding
ja-JP: サーバーのエンコード
- field: data_directory
type: 1
i18n:
zh-CN: 数据目录
en-US: Data Directory
ja-JP: データディレクトリ
- field: max_connections
type: 0
i18n:
zh-CN: 最大连接数
en-US: Max Connections
ja-JP: 最大接続数
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: jdbc
# the config content when protocol is jdbc
@@ -170,7 +155,6 @@ metrics:
i18n:
zh-CN: 状态信息
en-US: State Info
ja-JP: 状態情報
priority: 1
fields:
- field: db_name
@@ -179,55 +163,47 @@ metrics:
i18n:
zh-CN: 数据库名称
en-US: Database Name
ja-JP: データベース名
- field: conflicts
type: 0
unit: times
i18n:
zh-CN: 冲突次数
en-US: Conflicts
ja-JP: コンフリクト回数
- field: deadlocks
type: 0
unit: times
i18n:
zh-CN: 死锁次数
en-US: Deadlocks
ja-JP: デッドロック回数
- field: blks_read
type: 0
unit: blocks per second
i18n:
zh-CN: 读取块
en-US: Blocks Read
ja-JP: 読み取られたブロック
- field: blks_hit
type: 0
unit: blocks per second
i18n:
zh-CN: 命中块
en-US: Blocks Hit
ja-JP: ヒットブロック
- field: blk_read_time
type: 0
unit: ms
i18n:
zh-CN: 读取时间
en-US: Read Time
ja-JP: 読み取られタイム
- field: blk_write_time
type: 0
unit: ms
i18n:
zh-CN: 写入时间
en-US: Write Time
ja-JP: 書き込まれタイム
- field: stats_reset
type: 1
i18n:
zh-CN: 统计重置
en-US: Stats Reset
ja-JP: 統計リセット
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -245,7 +221,6 @@ metrics:
i18n:
zh-CN: 活动信息
en-US: Activity Info
ja-JP: 活動情報
priority: 2
fields:
- field: running
@@ -254,7 +229,6 @@ metrics:
i18n:
zh-CN: 运行中
en-US: Running
ja-JP: 実行中
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -272,7 +246,6 @@ metrics:
i18n:
zh-CN: 资源配置
en-US: Resource Config
ja-JP: リソース設定
priority: 3
fields:
- field: work_mem
@@ -281,40 +254,34 @@ metrics:
i18n:
zh-CN: 工作内存
en-US: Work Memory
ja-JP: ワークメモリ
- field: shared_buffers
type: 0
unit: MB
i18n:
zh-CN: 共享缓冲区
en-US: Shared Buffers
ja-JP: 共有バッファ
- field: autovacuum
type: 1
i18n:
zh-CN: 自动清理
en-US: Auto Vacuum
ja-JP: オートバキューム
- field: max_connections
type: 0
i18n:
zh-CN: 最大连接数
en-US: Max Connections
ja-JP: 最大接続数
- field: effective_cache_size
type: 0
unit: MB
i18n:
zh-CN: 有效缓存大小
en-US: Effective Cache Size
ja-JP: キャッシュサイズ
- field: wal_buffers
type: 0
unit: MB
i18n:
zh-CN: WAL缓冲区
en-US: WAL Buffers
ja-JP: WALバッファ
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -332,7 +299,6 @@ metrics:
i18n:
zh-CN: 连接信息
en-US: Connection Info
ja-JP: 接続情報
priority: 4
fields:
- field: active
@@ -340,7 +306,6 @@ metrics:
i18n:
zh-CN: 活动连接
en-US: Active Connection
ja-JP: 活躍的な接続
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -358,7 +323,6 @@ metrics:
i18n:
zh-CN: 连接状态
en-US: Connection State
ja-JP: 接続状態
priority: 5
fields:
- field: state
@@ -367,13 +331,11 @@ metrics:
i18n:
zh-CN: 状态
en-US: State
ja-JP: 状態
- field: num
type: 0
i18n:
zh-CN: 数量
en-US: Num
ja-JP: 数量
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -391,7 +353,6 @@ metrics:
i18n:
zh-CN: 连接数据库
en-US: Connection Db
ja-JP: 接続データベース
priority: 6
fields:
- field: db_name
@@ -400,13 +361,11 @@ metrics:
i18n:
zh-CN: 数据库名称
en-US: Database Name
ja-JP: データベース名
- field: active
type: 0
i18n:
zh-CN: 活动连接
en-US: Active Connection
ja-JP: 活躍的な接続
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -424,7 +383,6 @@ metrics:
i18n:
zh-CN: 元组信息
en-US: Tuple Info
ja-JP: 組情報
priority: 7
fields:
- field: fetched
@@ -432,31 +390,26 @@ metrics:
i18n:
zh-CN: 获取次数
en-US: Fetched
ja-JP: フェッチ回数
- field: returned
type: 0
i18n:
zh-CN: 返回次数
en-US: Returned
ja-JP: 戻る回数
- field: inserted
type: 0
i18n:
zh-CN: 插入次数
en-US: Inserted
ja-JP: インサート回数
- field: updated
type: 0
i18n:
zh-CN: 更新次数
en-US: Updated
ja-JP: 更新回数
- field: deleted
type: 0
i18n:
zh-CN: 删除次数
en-US: Deleted
ja-JP: 削除回数
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -474,7 +427,6 @@ metrics:
i18n:
zh-CN: 临时文件
en-US: Temp File
ja-JP: 一時ファイル
priority: 8
fields:
- field: db_name
@@ -483,20 +435,17 @@ metrics:
i18n:
zh-CN: 数据库名称
en-US: Database Name
ja-JP: データベース名
- field: num
type: 0
i18n:
zh-CN: 次数
en-US: Num
ja-JP: 数量
- field: Size
- field: size
type: 0
unit: B
i18n:
zh-CN: 大小
en-US: Size
ja-JP: サイズ
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -514,7 +463,6 @@ metrics:
i18n:
zh-CN: 锁信息
en-US: Lock Info
ja-JP: ロック情報
priority: 9
fields:
- field: db_name
@@ -523,21 +471,18 @@ metrics:
i18n:
zh-CN: 数据库名称
en-US: Database Name
ja-JP: データベース名
- field: conflicts
type: 0
unit: times
i18n:
zh-CN: 冲突次数
en-US: Conflicts
ja-JP: コンフリクト回数
- field: deadlocks
type: 0
unit: times
i18n:
zh-CN: 死锁次数
en-US: Deadlocks
ja-JP: デッドロック回数
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -555,7 +500,6 @@ metrics:
i18n:
zh-CN: 慢查询
en-US: Slow Sql
ja-JP: スローSQL
priority: 10
fields:
- field: sql_text
@@ -564,33 +508,28 @@ metrics:
i18n:
zh-CN: SQL语句
en-US: SQL Text
ja-JP: SQL文のテキスト
- field: calls
type: 0
i18n:
zh-CN: 调用次数
en-US: Calls
ja-JP: コール回数
- field: rows
type: 0
i18n:
zh-CN: 行数
en-US: Rows
ja-JP:
- field: avg_time
type: 0
unit: ms
i18n:
zh-CN: 平均时间
en-US: Avg Time
ja-JP: 平均時間
- field: total_time
type: 0
unit: ms
i18n:
zh-CN: 总时间
en-US: Total Time
ja-JP: 合計時間
aliasFields:
- query
- calls
@@ -618,7 +557,6 @@ metrics:
i18n:
zh-CN: 事务信息
en-US: Transaction Info
ja-JP: トランザクション情報
priority: 11
fields:
- field: db_name
@@ -627,21 +565,18 @@ metrics:
i18n:
zh-CN: 数据库名称
en-US: Database Name
ja-JP: データベース名
- field: commits
type: 0
unit: times
i18n:
zh-CN: 提交次数
en-US: Commits
ja-JP: コミット回数
- field: rollbacks
type: 0
unit: times
i18n:
zh-CN: 回滚次数
en-US: Rollbacks
ja-JP: ロールバック回数
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -659,7 +594,6 @@ metrics:
i18n:
zh-CN: 冲突信息
en-US: Conflicts Info
ja-JP: コンフリクト情報
priority: 12
fields:
- field: db_name
@@ -668,37 +602,31 @@ metrics:
i18n:
zh-CN: 数据库名称
en-US: Database Name
ja-JP: データベース名
- field: tablespace
type: 0
i18n:
zh-CN: 表空间
en-US: Tablespace
ja-JP: 表領域
- field: lock
type: 0
i18n:
zh-CN:
en-US: Lock
ja-JP: ロック
- field: snapshot
type: 0
i18n:
zh-CN: 快照
en-US: Snapshot
ja-JP: スナップショット
- field: bufferpin
type: 0
i18n:
zh-CN: 缓冲区
en-US: Bufferpin
ja-JP: バッファ
- field: deadlock
type: 0
i18n:
zh-CN: 死锁
en-US: Deadlock
ja-JP: デッドロック
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -716,7 +644,6 @@ metrics:
i18n:
zh-CN: 缓存命中率
en-US: Cache Hit Ratio
ja-JP: キャッシュ命中率
priority: 13
fields:
- field: db_name
@@ -725,14 +652,12 @@ metrics:
i18n:
zh-CN: 数据库名称
en-US: Database Name
ja-JP: データベース名
- field: ratio
type: 0
unit: '%'
i18n:
zh-CN: 命中率
en-US: Hit Ratio
ja-JP: 命中率
aliasFields:
- blks_hit
- blks_read
@@ -756,7 +681,6 @@ metrics:
i18n:
zh-CN: Checkpoint信息
en-US: Checkpoint Info
ja-JP: チェックポイント情報
priority: 14
fields:
- field: checkpoint_sync_time
@@ -765,14 +689,12 @@ metrics:
i18n:
zh-CN: Checkpoint同步时间
en-US: Checkpoint Sync Time
ja-JP: チェックポイント同期時間
- field: checkpoint_write_time
type: 0
unit: ms
i18n:
zh-CN: Checkpoint写入时间
en-US: Checkpoint Write Time
ja-JP: Checkpoint書き込まれた時間
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -790,7 +712,6 @@ metrics:
i18n:
zh-CN: Buffer信息
en-US: Buffer Info
ja-JP: バッファ情報
priority: 15
fields:
- field: allocated
@@ -798,31 +719,26 @@ metrics:
i18n:
zh-CN: 已分配
en-US: Allocated
ja-JP: 割り当てバッファ
- field: fsync_calls_by_backend
type: 0
i18n:
zh-CN: 后端进程直接执行的文件同步调用次数
en-US: Fsync Calls By Backend
ja-JP: バックエンド同期コール回数
- field: written_directly_by_backend
type: 0
i18n:
zh-CN: 后台写入到数据文件
en-US: Written Directly By Backend
ja-JP: バックエンドによる直接書き込まれたファイル
- field: written_by_background_writer
type: 0
i18n:
zh-CN: 后台写入
en-US: Written By Background Writer
ja-JP: バックグラウンドライターに書き込まれた
- field: written_during_checkpoints
type: 0
i18n:
zh-CN: 检查点期间写入
en-US: Written During Checkpoints
ja-JP: チェックポイント中の書き込み
protocol: jdbc
jdbc:
host: ^_^host^_^
@@ -21,13 +21,11 @@ app: windows
name:
zh-CN: Windows操作系统
en-US: OS Windows
ja-JP: Windowsオーエス
# The description and help of this monitoring type
help:
zh-CN: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-snmp'> SNMP 协议</a> 对 Windows操作系统 的通用指标(用户数、进程数量、响应时间等)进行采集监控。<br><span class='help_module_span'>注意⚠️Windows 服务器需要开启 SNMP 服务,<a class='help_module_content' href='https://learn.microsoft.com/zh-cn/troubleshoot/windows-server/networking/configure-snmp-service'>点击查看开启步骤</a>。</span>您可以点击 “<i>新建 Windows操作系统</i>” 并进行配置SNMP相关参数添加,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat uses <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-snmp'> SNMP Protocol</a> to monitoring OS Windows general performance metrics such as number of users, number of processes, response time. <br><span class='help_module_span'>Note⚠️:Windows server need enable the SNMP services <a class='help_module_content' href='https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-snmp-service'>Click here to view the specific steps.</a></span> You can click the "<i>New OS Windows</i>" button and config snmp params to add monitor or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: Hertzbeat 使用 <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-snmp'> SNMP 协议</a> 对 Windows操作系统 的通用指标(用户数、进程数量、响应时间等)进行采集监控。<br><span class='help_module_span'>注意⚠️Windows 服务器需要开启 SNMP 服务,<a class='help_module_content' href='https://learn.microsoft.com/zh-cn/troubleshoot/windows-server/networking/configure-snmp-service'>点击查看开启步骤</a>。</span>您可以点击 “<i>新建 Windows操作系统</i>” 并进行配置SNMP相关参数添加,或者选择“<i>更多操作</i>”,导入已有配置。
ja-JP: Hertzbeat は <a class='help_module_content' href='https://hertzbeat.apache.org/docs/advanced/extend-snmp'> SNMP プロトコルを介して</a> Windowsオーエスの一般的なメトリクスを監視します。<br><span class='help_module_span'>注意⚠️Windowsサーバー で SNMP サービスを有効にする必要があります,<a class='help_module_content' href='https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-snmp-service'>クリックしてガイドを見ます</a>。<br>「<i>新規 Windowsオーエス</i>」をクリックしてSNMPなどのパラメタを設定した後、新規することができます。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/windows
en-US: https://hertzbeat.apache.org/docs/help/windows
@@ -39,7 +37,6 @@ params:
name:
zh-CN: 目标Host
en-US: Target Host
ja-JP: 目標ホスト
# type-param field type(most mapping the html input type)
type: host
# required-true or false
@@ -50,7 +47,6 @@ params:
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
@@ -65,7 +61,6 @@ params:
name:
zh-CN: SNMP 版本
en-US: SNMP Version
ja-JP: SNMPバージョン
# type-param field type(radio mapping the html radio tag)
type: radio
# required-true or false
@@ -82,7 +77,6 @@ params:
name:
zh-CN: SNMP 团体字
en-US: SNMP Community
ja-JP: SNMPコミュニティ
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
@@ -102,7 +96,6 @@ params:
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
ja-JP: タイムアウト(ms)
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
@@ -120,7 +113,6 @@ metrics:
i18n:
zh-CN: 系统
en-US: System
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
@@ -130,56 +122,47 @@ metrics:
i18n:
zh-CN: 名称
en-US: Name
ja-JP: 名前
- field: descr
type: 1
i18n:
zh-CN: 描述
en-US: Description
ja-JP: 説明
- field: uptime
type: 1
i18n:
zh-CN: 运行时间
en-US: Uptime
ja-JP: アップタイム
- field: numUsers
type: 0
i18n:
zh-CN: 用户数
en-US: Number of Users
ja-JP: ユーザー数
- field: services
type: 0
i18n:
zh-CN: 服务数
en-US: Number of Services
ja-JP: サービス数
- field: processes
type: 0
i18n:
zh-CN: 进程数
en-US: Number of Processes
ja-JP: プロセス数
- field: responseTime
type: 0
i18n:
zh-CN: 响应时间
en-US: Response Time
ja-JP: 応答時間
unit: ms
- field: location
type: 1
i18n:
zh-CN: 位置
en-US: Location
ja-JP: 位置
- field: memory
type: 0
i18n:
zh-CN: 内存
en-US: Memory
ja-JP: メモリ
unit: GB
units:
- memory=KB->GB
@@ -205,7 +188,6 @@ metrics:
i18n:
zh-CN: 进程
en-US: Processes
ja-JP: プロセス
priority: 1
fields:
- field: hrSWRunIndex
@@ -213,57 +195,48 @@ metrics:
i18n:
zh-CN: 编号
en-US: Index
ja-JP: 番号
- field: hrSWRunName
type: 1
i18n:
zh-CN: 进程名称
en-US: Process Name
ja-JP: プロセス名
label: true
- field: hrSWRunID
type: 1
i18n:
zh-CN: 进程 ID
en-US: Process ID
ja-JP: プロセスID
- field: hrSWRunPath
type: 1
i18n:
zh-CN: 进程路径
en-US: Process Path
ja-JP: プロセスパス
- field: hrSWRunParameters
type: 1
i18n:
zh-CN: 进程参数
en-US: Process Parameters
ja-JP: プロセスパラメータ
- field: hrSWRunType
type: 0
i18n:
zh-CN: 进程类型
en-US: Process Type
ja-JP: プロセスタイプ
- field: hrSWRunStatus
type: 0
i18n:
zh-CN: 进程状态
en-US: Process Status
ja-JP: プロセス状態
- field: hrSWRunPerfCPU
type: 0
i18n:
zh-CN: 进程占用 CPU
en-US: Process CPU
ja-JP: プロセスが使用したCPU
unit: 's'
- field: hrSWRunPerfMem
type: 0
i18n:
zh-CN: 进程占用内存
en-US: Process Memory
ja-JP: プロセスが使用したメモリ
unit: 'KB'
calculates:
- hrSWRunPerfCPU = hrSWRunPerfCPU / 100
@@ -290,7 +263,6 @@ metrics:
i18n:
zh-CN: 服务
en-US: Services
ja-JP: サービス
priority: 2
fields:
- field: svSvcName
@@ -298,32 +270,27 @@ metrics:
i18n:
zh-CN: 服务名称
en-US: Service Name
ja-JP: サービス名
label: true
- field: svSvcInstalledState
type: 0
i18n:
zh-CN: 服务安装状态
en-US: Service Installed State
ja-JP: サービスのインストール状態
- field: svSvcOperatingState
type: 0
i18n:
zh-CN: 服务运行状态
en-US: Service Operating State
ja-JP: サービスの実行状態
- field: svSvcCanBeUninstalled
type: 0
i18n:
zh-CN: 服务是否可以被卸载
en-US: Service Can Be Uninstalled
ja-JP: サービスはアンインストールできる
- field: svSvcCanBePaused
type: 0
i18n:
zh-CN: 服务是否可以被暂停
en-US: Service Can Be Paused
ja-JP: サービスは一時停止できる
protocol: snmp
snmp:
host: ^_^host^_^
@@ -343,7 +310,6 @@ metrics:
i18n:
zh-CN: 安装
en-US: Installed
ja-JP: インストール
priority: 3
fields:
- field: hrSWInstalledIndex
@@ -351,26 +317,22 @@ metrics:
i18n:
zh-CN: 编号
en-US: Index
ja-JP: 番号
- field: hrSWInstalledName
type: 1
i18n:
zh-CN: 安装名称
en-US: Installed Name
ja-JP: インストール名
label: true
- field: hrSWInstalledID
type: 1
i18n:
zh-CN: 安装 ID
en-US: Installed ID
ja-JP: インストールID
- field: hrSWInstalledType
type: 0
i18n:
zh-CN: 安装类型
en-US: Installed Type
ja-JP: インストールタイプ
protocol: snmp
snmp:
host: ^_^host^_^
@@ -389,7 +351,6 @@ metrics:
i18n:
zh-CN: 存储
en-US: Storages
ja-JP: ストレージ
priority: 5
fields:
- field: index
@@ -397,19 +358,16 @@ metrics:
i18n:
zh-CN: 编号
en-US: Index
ja-JP: 番号
- field: descr
type: 1
i18n:
zh-CN: 存储描述
en-US: Storage Description
ja-JP: ストレージ説明
label: true
- field: Size
i18n:
zh-CN: 存储大小
en-US: Storage Size
ja-JP: ストレージサイズ
type: 0
unit: Mb
- field: free
@@ -417,21 +375,18 @@ metrics:
i18n:
zh-CN: 存储空闲
en-US: Storage Free
ja-JP: 空きストレージ
unit: Mb
- field: used
type: 0
i18n:
zh-CN: 存储占用
en-US: Storage Used
ja-JP: 使用したストレージ
unit: Mb
- field: usage
type: 0
i18n:
zh-CN: 存储使用率
en-US: Storage Usage
ja-JP: ストレージ使用率
unit: '%'
# (Not required) Monitor indicator alias, which maps to the indicator name above. The field used to collect interface data is not directly the final indicator name, and this alias is required for mapping translation
aliasFields:
@@ -473,7 +428,6 @@ metrics:
i18n:
zh-CN: 接口详情
en-US: Interfaces Detail
ja-JP: ネットワークカード詳細
priority: 8
fields:
- field: index
@@ -481,77 +435,65 @@ metrics:
i18n:
zh-CN: 编号
en-US: Index
ja-JP: 番号
- field: descr
type: 1
label: true
i18n:
zh-CN: 接口名称
en-US: Interface Name
ja-JP: ネットワークカード名
- field: speed
type: 0
unit: 'Mbps'
i18n:
zh-CN: 接口速率
en-US: Interface Speed
ja-JP: ネットワークカード速度
- field: in_octets
type: 0
unit: 'Kbps'
i18n:
zh-CN: 入流量
en-US: In Octets
ja-JP: 受信されたバイト数
- field: out_octets
type: 0
unit: 'Kbps'
i18n:
zh-CN: 出流量
en-US: Out Octets
ja-JP: 転送されたバイト数
- field: admin_status
type: 1
i18n:
zh-CN: 配置状态
en-US: Config Status
ja-JP: 設定ステータス
- field: oper_status
type: 1
i18n:
zh-CN: 当前状态
en-US: Current Status
ja-JP: 現在のステータス
- field: mtu
type: 0
i18n:
zh-CN: MTU
en-US: MTU
ja-JP: MTU
- field: in_discards
type: 0
i18n:
zh-CN: 入丢包数
en-US: In Discards
ja-JP: 受信されたパケットのロス数
- field: in_errors
type: 0
i18n:
zh-CN: 入错包数
en-US: In Errors
ja-JP: 受信異常パケット数
- field: out_discards
type: 0
i18n:
zh-CN: 出丢包数
en-US: Out Discards
ja-JP: 転送されたパケットロス数
- field: out_errors
type: 0
i18n:
zh-CN: 出错包数
en-US: Out Errors
ja-JP: 転送された異常パケット数
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- ifIndex
@@ -613,7 +555,6 @@ metrics:
i18n:
zh-CN: 设备
en-US: Devices
ja-JP: デバイス
priority: 9
fields:
- field: index
@@ -621,20 +562,17 @@ metrics:
i18n:
zh-CN: 编号
en-US: Index
ja-JP: 番号
label: true
- field: descr
type: 1
i18n:
zh-CN: 描述
en-US: Description
ja-JP: 説明
- field: status
type: 1
i18n:
zh-CN: 状态
en-US: Status
ja-JP: 状態
aliasFields:
- hrDeviceIndex
- hrDeviceDescr
@@ -21,13 +21,11 @@ app: yarn
name:
zh-CN: Apache Yarn
en-US: Apache Yarn
ja-JP: Apache Yarn
# The description and help of this monitoring type
help:
zh-CN: Hertzbeat 对 Yarn 节点监控指标进行监控。<br>您可以点击 “<i>新建 Apache Yarn</i>” 并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: Hertzbeat monitors the Yarn metrics. <br>You can click "<i>New Apache Yarn</i>" to configure, or select "<i>More Actions</i>" to import an existing configuration.
zh-TW: Hertzbeat 對 Yarn 節點監控指標進行監控。<br>您可以點擊 “<i>新建 Apache Yarn</i>” 並進行配置,或者選擇“<i>更多操作</i>”,導入已有配置。
ja-JP: Hertzbeat は Yarnノードの一般的なメトリクスを監視します。<br>「<i>新規 Yarn</i>」をクリックしてパラメタを設定した後、新規することができます。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/yarn/
@@ -40,7 +38,6 @@ params:
name:
zh-CN: 目标Host
en-US: Target Host
ja-JP: 目標ホスト
# type-param field type(most mapping the html input type)
type: host
# required-true or false
@@ -51,7 +48,6 @@ params:
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
@@ -66,7 +62,6 @@ params:
name:
zh-CN: 查询超时时间
en-US: Query Timeout
ja-JP: クエリタイムアウト
# type-param field type(most mapping the html input type)
type: number
# required-true or false
@@ -79,10 +74,6 @@ params:
metrics:
# metrics - Server
- name: ClusterMetrics
i18n:
zh-CN: 集群指标
en-US: Cluster 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
@@ -94,35 +85,30 @@ metrics:
i18n:
zh-CN: 当前存活的 NodeManager 个数
en-US: NumActiveNMs
ja-JP: アクティブなNodeManager総数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: NumDecommissionedNMs
type: 0
i18n:
zh-CN: 当前 Decommissioned 的 NodeManager 个数
en-US: NumDecommissionedNMs
ja-JP: オフラインしたNodeManager数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: NumDecommissioningNMs
type: 0
i18n:
zh-CN: 集群正在下线的节点数
en-US: NumDecommissioningNMs
ja-JP: オフライン中のNodeManager数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: NumLostNMs
type: 0
i18n:
zh-CN: 集群丢失的节点数
en-US: NumLostNMs
ja-JP: ロストしたNodeManager数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: NumUnhealthyNMs
type: 0
i18n:
zh-CN: 集群不健康的节点数
en-US: NumUnhealthyNMs
ja-JP: 不健全なNodeManager数
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- $.NumActiveNMs
@@ -150,10 +136,6 @@ metrics:
parseType: jsonPath
parseScript: '$.beans[?(@.name == "Hadoop:service=ResourceManager,name=ClusterMetrics")]'
- name: JvmMetrics
i18n:
zh-CN: JVM指标
en-US: Jvm Metrics
ja-JP: Java仮想マシンのメトリクス
# 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: 1
@@ -167,7 +149,6 @@ metrics:
i18n:
zh-CN: JVM当前非堆内存大小已提交大小
en-US: MemNonHeapCommittedM
ja-JP: コミットされたノンヒープメモリのサイズ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: MemNonHeapMaxM
type: 0
@@ -175,7 +156,6 @@ metrics:
i18n:
zh-CN: JVM非堆最大可用内存
en-US: MemNonHeapMaxM
ja-JP: 使用可能なノンヒープメモリの最大サイズ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: MemNonHeapUsedM
type: 0
@@ -183,7 +163,6 @@ metrics:
i18n:
zh-CN: JVM当前已使用的非堆内存大小
en-US: MemNonHeapUsedM
ja-JP: 使用したノンヒープメモリのサイズ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: MemHeapCommittedM
type: 0
@@ -191,7 +170,6 @@ metrics:
i18n:
zh-CN: JVM当前已使用堆内存大小
en-US: MemHeapCommittedM
ja-JP: コミットされたヒープメモリのサイズ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: MemHeapMaxM
type: 0
@@ -199,7 +177,6 @@ metrics:
i18n:
zh-CN: JVM堆内存最大可用内存
en-US: MemHeapMaxM
ja-JP: 配置のヒープメモリのサイズ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: MemHeapUsedM
type: 0
@@ -207,21 +184,18 @@ metrics:
i18n:
zh-CN: JVM当前已使用堆内存大小
en-US: MemHeapUsedM
ja-JP: 使用したヒープメモリのサイズ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: GcTimeMillis
type: 0
i18n:
zh-CN: JVM GC时间
en-US: GcTimeMillis
ja-JP: GC時間
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: GcCount
type: 0
i18n:
zh-CN: JVM GC次数
en-US: GcCount
ja-JP: GC回数
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- $.MemNonHeapCommittedM
@@ -251,10 +225,6 @@ metrics:
parseType: jsonPath
parseScript: '$.beans[?(@.name == "Hadoop:service=ResourceManager,name=JvmMetrics")]'
- name: QueueMetrics
i18n:
zh-CN: 队列指标
en-US: Queue 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: 2
@@ -268,35 +238,30 @@ metrics:
i18n:
zh-CN: 队列名称
en-US: queue
ja-JP: キュー
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AllocatedVCores
type: 0
i18n:
zh-CN: 分配的虚拟核数(已分配)
en-US: AllocatedVCores
ja-JP: 割り当てられたコア数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: ReservedVCores
type: 0
i18n:
zh-CN: 预留核数
en-US: ReservedVCores
ja-JP: 予約されているコア数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AvailableVCores
type: 0
i18n:
zh-CN: 可用核数(尚未分配)
en-US: AvailableVCores
ja-JP: 利用可能なコア数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: PendingVCores
type: 0
i18n:
zh-CN: 阻塞调度核数
en-US: PendingVCores
ja-JP: 保留中のコア数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AllocatedMB
type: 0
@@ -304,7 +269,6 @@ metrics:
i18n:
zh-CN: 已分配(已用)的内存大小
en-US: AllocatedMB
ja-JP: 割り当てられたメモリ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AvailableMB
type: 0
@@ -312,7 +276,6 @@ metrics:
i18n:
zh-CN: 可用内存(尚未分配)
en-US: AvailableMB
ja-JP: 使用可能なメモリ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: PendingMB
type: 0
@@ -320,7 +283,6 @@ metrics:
i18n:
zh-CN: 阻塞调度内存
en-US: PendingMB
ja-JP: 保留中のメモリ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: ReservedMB
type: 0
@@ -328,112 +290,96 @@ metrics:
i18n:
zh-CN: 预留内存
en-US: ReservedMB
ja-JP: 予約されているメモリ
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AllocatedContainers
type: 0
i18n:
zh-CN: 已分配(已用)的container数
en-US: AllocatedContainers
ja-JP: 割り当てられたコンテナ数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: PendingContainers
type: 0
i18n:
zh-CN: 阻塞调度container个数
en-US: PendingContainers
ja-JP: 保留中のコンテナ数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: ReservedContainers
type: 0
i18n:
zh-CN: 预留container数
en-US: ReservedContainers
ja-JP: 予約されているコンテナ数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AggregateContainersAllocated
type: 0
i18n:
zh-CN: 累积的container分配总数
en-US: AggregateContainersAllocated
ja-JP: 割り当てられたコンテナ総数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AggregateContainersReleased
type: 0
i18n:
zh-CN: 累积的container释放总数
en-US: AggregateContainersReleased
ja-JP: リリースされたコンテナ総数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AppsCompleted
type: 0
i18n:
zh-CN: 完成的任务数
en-US: AppsCompleted
ja-JP: 完了したタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AppsKilled
type: 0
i18n:
zh-CN: 被杀掉的任务数
en-US: AppsKilled
ja-JP: 終了したタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AppsFailed
type: 0
i18n:
zh-CN: 失败的任务数
en-US: AppsFailed
ja-JP: 失敗したタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AppsPending
type: 0
i18n:
zh-CN: 阻塞的任务数
en-US: AppsPending
ja-JP: ブロックされたタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AppsRunning
type: 0
i18n:
zh-CN: 提正在运行的任务数
en-US: AppsRunning
ja-JP: 実行中のタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: AppsSubmitted
type: 0
i18n:
zh-CN: 提交过的任务数
en-US: AppsSubmitted
ja-JP: 提出されたタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: running_0
type: 0
i18n:
zh-CN: 运行时间小于60分钟的作业个数
en-US: running_0
ja-JP: 実行時間60分未満のタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: running_60
type: 0
i18n:
zh-CN: 运行时间介于60~300分钟的作业个数
en-US: running_60
ja-JP: 実行時間が60分以上300分未満のタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: running_300
type: 0
i18n:
zh-CN: 运行时间介于300~1440分钟的作业个数
en-US: running_300
ja-JP: 実行時間が300分以上1440分未満のタスク数
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: running_1440
type: 0
i18n:
zh-CN: 运行时间大于1440分钟的作业个数
en-US: running_1440
ja-JP: 実行時間が1440分以上のタスク数
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- $.['tag.Queue']
@@ -496,10 +442,6 @@ metrics:
parseScript: '$.beans[?(@.name =~ /Hadoop:service=ResourceManager,name=QueueMetrics.*/)]'
- name: runtime
i18n:
zh-CN: 运行时信息
en-US: Runtime
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: 3
@@ -511,7 +453,6 @@ metrics:
i18n:
zh-CN: 启动时间戳
en-US: StartTime
ja-JP: 起動時間
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- $.StartTime
@@ -72,6 +72,7 @@ resourceRole:
# rule: api===method
# eg: /api/v1/source3===get means /api/v1/source3===get can be access by anyone, no need auth.
excludedResource:
- /api/alerts/report/**===*
- /api/alert/sse/**===*
- /api/account/auth/**===*
- /api/i18n/**===get
@@ -25,10 +25,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import java.util.Collections;
import java.util.List;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.manager.StatusPageComponent;
import org.apache.hertzbeat.common.entity.manager.StatusPageIncident;
@@ -221,10 +219,14 @@ class StatusPageControllerTest {
@Test
public void testQueryStatusPageIncident() throws Exception {
mockMvc.perform(get("/api/status/page/incident?pageIndex=0&pageSize=10"))
List<StatusPageIncident> incidents = Collections.singletonList(new StatusPageIncident());
when(statusPageService.queryStatusPageIncidents()).thenReturn(incidents);
mockMvc.perform(get("/api/status/page/incident")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value((int) CommonConstants.SUCCESS_CODE))
.andReturn();
.andExpect(jsonPath("$.code").value((int) CommonConstants.SUCCESS_CODE));
}
}
@@ -22,11 +22,10 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import java.util.Collections;
import java.util.List;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.entity.manager.StatusPageIncident;
import org.apache.hertzbeat.common.entity.manager.StatusPageOrg;
import org.apache.hertzbeat.manager.pojo.dto.ComponentStatus;
import org.apache.hertzbeat.manager.service.StatusPageService;
@@ -111,7 +110,11 @@ class StatusPagePublicControllerTest {
@Test
public void testQueryStatusPageIncident() throws Exception {
mockMvc.perform(get("/api/status/page/public/incident"))
List<StatusPageIncident> incidents = Collections.singletonList(new StatusPageIncident());
when(statusPageService.queryStatusPageIncidents()).thenReturn(incidents);
mockMvc.perform(get("/api/status/page/public/incident")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value((int) CommonConstants.SUCCESS_CODE));
}
@@ -18,15 +18,11 @@
package org.apache.hertzbeat.manager.service;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.List;
import org.apache.hertzbeat.common.entity.manager.StatusPageComponent;
import org.apache.hertzbeat.common.entity.manager.StatusPageIncident;
import org.apache.hertzbeat.common.entity.manager.StatusPageOrg;
@@ -42,9 +38,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.domain.Sort;
/**
* test case for {@link StatusPageServiceImpl}
@@ -127,8 +121,13 @@ class StatusPageServiceTest {
@Test
void testQueryStatusPageIncidents() {
when(statusPageIncidentDao.findAll(any(Specification.class), any(PageRequest.class))).thenReturn(Page.empty());
assertNotNull(statusPageService.queryStatusPageIncidents(null, null, null, 1, 10));
StatusPageIncident incident = new StatusPageIncident();
when(statusPageIncidentDao.findAll(Sort.by(Sort.Direction.DESC, "startTime"))).thenReturn(List.of(incident));
List<StatusPageIncident> incidents = statusPageService.queryStatusPageIncidents();
assertEquals(1, incidents.size());
assertEquals(incident, incidents.get(0));
}
@Test
+1 -1
View File
@@ -96,4 +96,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
+23 -23
View File
@@ -39,28 +39,28 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
+1
View File
@@ -56,4 +56,5 @@
</dependency>
</dependencies>
</project>
-6
View File
@@ -83,12 +83,6 @@
</exclusion>
</exclusions>
</dependency>
<!-- QuestDB -->
<dependency>
<groupId>org.questdb</groupId>
<artifactId>questdb</artifactId>
<version>${questdb.version}</version>
</dependency>
<!-- influxdb Here, support for version 1.7, use influxdb-java, Full support for version 2.x requires influxdb-client-java -->
<dependency>
<groupId>org.influxdb</groupId>
@@ -44,8 +44,6 @@ public interface WarehouseConstants {
String VM = "victoria-metrics";
String VM_CLUSTER = "victoria-metrics.cluster";
String QUEST_DB = "questdb";
}
/**
@@ -1,412 +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.
*/
package org.apache.hertzbeat.warehouse.store.history.tsdb.questdb;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.time.Instant;
import java.util.Base64;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import com.google.common.collect.Maps;
import io.questdb.client.Sender;
import lombok.extern.slf4j.Slf4j;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.hertzbeat.common.constants.CommonConstants;
import org.apache.hertzbeat.common.constants.MetricDataConstants;
import org.apache.hertzbeat.common.constants.NetworkConstants;
import org.apache.hertzbeat.common.entity.arrow.RowWrapper;
import org.apache.hertzbeat.common.entity.dto.Value;
import org.apache.hertzbeat.common.entity.message.CollectRep;
import org.apache.hertzbeat.common.util.JsonUtil;
import org.apache.hertzbeat.warehouse.store.history.tsdb.AbstractHistoryDataStorage;
import org.apache.http.ssl.SSLContexts;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
/**
* HistoryQuestdbDataStorage class
*/
@Component
@ConditionalOnProperty(prefix = "warehouse.store.questdb", name = "enabled", havingValue = "true")
@Slf4j
public class QuestdbDataStorage extends AbstractHistoryDataStorage {
private static final String QUERY_HISTORY_SQL = "SELECT timestamp AS ts, instance, %s AS value FROM \"%s\" WHERE timestamp >= %s ORDER BY timestamp DESC";
private static final String QUERY_HISTORY_SQL_WITH_INSTANCE = "SELECT timestamp AS ts, instance, %s AS value FROM \"%s\" WHERE instance = '%s' AND timestamp >= %s ORDER BY timestamp DESC";
private static final String QUERY_HISTORY_INTERVAL_WITH_INSTANCE_SQL =
"SELECT timestamp AS ts, first(%s) AS origin, avg(%s) AS mean, max(%s) AS max, min(%s) AS min FROM \"%s\" WHERE instance = '%s' AND timestamp >= %s SAMPLE BY 4h";
private static final String QUERY_INSTANCE_SQL = "SELECT DISTINCT instance FROM \"%s\"";
private Sender sender;
private OkHttpClient client;
private String queryBaseUrl;
private QuestdbProperties questdbProperties;
public QuestdbDataStorage(QuestdbProperties questdbProperties) {
this.questdbProperties = questdbProperties;
this.initQuestDb(questdbProperties);
}
public void initQuestDb(QuestdbProperties questdbProperties) {
String ilpAddress = questdbProperties.url(); // e.g., "localhost:9009"
this.sender = Sender.builder(Sender.Transport.HTTP)
.address(ilpAddress)
.httpUsernamePassword(questdbProperties.username(), questdbProperties.password())
.build();
// Parse host and set query base URL (assuming HTTP port is 9000)
String[] parts = ilpAddress.split(":");
String host = parts[0];
String queryPort = "9000"; // Default QuestDB HTTP port
this.queryBaseUrl = "http://" + host + ":" + queryPort + "/exec?query=";
this.client = new OkHttpClient.Builder()
.readTimeout(NetworkConstants.HttpClientConstants.READ_TIME_OUT, TimeUnit.SECONDS)
.writeTimeout(NetworkConstants.HttpClientConstants.WRITE_TIME_OUT, TimeUnit.SECONDS)
.connectTimeout(NetworkConstants.HttpClientConstants.CONNECT_TIME_OUT, TimeUnit.SECONDS)
.connectionPool(new ConnectionPool(
NetworkConstants.HttpClientConstants.MAX_IDLE_CONNECTIONS,
NetworkConstants.HttpClientConstants.KEEP_ALIVE_TIMEOUT,
TimeUnit.SECONDS)
).sslSocketFactory(defaultSslSocketFactory(), defaultTrustManager())
.hostnameVerifier(noopHostnameVerifier())
.retryOnConnectionFailure(true)
.build();
this.serverAvailable = this.checkConnection();
}
private boolean checkConnection() {
// Test query to check if server is available
Map<String, Object> result = executeQuery("SELECT 1");
return result != null && result.containsKey("dataset");
}
@Override
public void saveData(CollectRep.MetricsData metricsData) {
if (!isServerAvailable() || metricsData.getCode() != CollectRep.Code.SUCCESS || metricsData.getValues().isEmpty()) {
return;
}
String table = this.generateTable(metricsData.getApp(), metricsData.getMetrics(), metricsData.getId());
try {
RowWrapper rowWrapper = metricsData.readRow();
while (rowWrapper.hasNextRow()) {
rowWrapper = rowWrapper.nextRow();
// Wrap the construction of each row in a try-catch block
// to prevent one bad row from corrupting the sender's state.
try {
// 1. Set the table for the new row.
sender.table(table);
// 2. Process and write all symbols FIRST.
Map<String, String> labels = Maps.newHashMapWithExpectedSize(8);
rowWrapper.cellStream()
.filter(cell -> cell.getMetadataAsBoolean(MetricDataConstants.LABEL))
.forEach(cell -> labels.put(cell.getField().getName(), cell.getValue()));
if (!labels.isEmpty()) {
sender.symbol("instance", JsonUtil.toJson(labels));
} else {
sender.symbol("instance", metricsData.getApp()
+ "_" + metricsData.getMetrics());
}
// 3. Now, process and write all other columns (fields).
rowWrapper.cellStream().forEach(cell -> {
if (CommonConstants.NULL_VALUE.equals(cell.getValue())) {
return;
}
String fieldName = cell.getField().getName();
String fieldValue = cell.getValue();
Byte type = cell.getMetadataAsByte(MetricDataConstants.TYPE);
if (type == CommonConstants.TYPE_NUMBER) {
sender.doubleColumn(fieldName, Double.parseDouble(fieldValue));
} else if (type == CommonConstants.TYPE_STRING) {
sender.stringColumn(fieldName, fieldValue);
}
});
// 4. Finally, set the timestamp to commit the row.
sender.atNow();
} catch (Exception e) {
log.error("[warehouse questdb]--Could not process a row, cancelling it. Error: {}", e.getMessage());
// IMPORTANT: Cancel the partially built row to reset the sender's state.
sender.cancelRow();
}
}
sender.flush();
} catch (Exception e) {
log.error("[warehouse questdb]--Error during batch save: {}", e.getMessage(), e);
}
}
@Override
public Map<String, List<Value>> getHistoryMetricData(Long monitorId, String app, String metrics, String metric, String label, String history) {
String table = this.generateTable(app, metrics, monitorId);
String dateAdd = getDateAdd(history);
String selectSql = label == null ? String.format(QUERY_HISTORY_SQL, metric, table, dateAdd)
: String.format(QUERY_HISTORY_SQL_WITH_INSTANCE, metric, table, label.replace("'", "\\'"), dateAdd);
Map<String, List<Value>> instanceValueMap = new HashMap<>(8);
try {
Map<String, Object> selectResult = executeQuery(selectSql);
if (selectResult == null || !selectResult.containsKey("dataset")) {
return instanceValueMap;
}
List<Map<String, String>> columns = (List<Map<String, String>>) selectResult.get("columns");
List<List<Object>> dataset = (List<List<Object>>) selectResult.get("dataset");
Map<String, Integer> colMap = new HashMap<>();
for (int i = 0; i < columns.size(); i++) {
colMap.put(columns.get(i).get("name"), i);
}
int tsIdx = colMap.get("ts");
int instanceIdx = colMap.get("instance");
int valueIdx = colMap.get("value");
for (List<Object> row : dataset) {
String tsStr = (String) row.get(tsIdx);
long time = Instant.parse(tsStr).toEpochMilli();
String instanceValue = row.get(instanceIdx) == null ? "" : (String) row.get(instanceIdx);
Object valObj = row.get(valueIdx);
String strValue = valObj == null ? null : this.parseDoubleValue(valObj.toString());
if (strValue == null) {
continue;
}
List<Value> valueList = instanceValueMap.computeIfAbsent(instanceValue, k -> new LinkedList<>());
valueList.add(new Value(strValue, time));
}
} catch (Exception e) {
log.error("select history metric data in questdb error, sql:{}, msg: {}", selectSql, e.getMessage());
}
return instanceValueMap;
}
@Override
public Map<String, List<Value>> getHistoryIntervalMetricData(Long monitorId, String app, String metrics, String metric, String label, String history) {
String table = this.generateTable(app, metrics, monitorId);
String dateAdd = getDateAdd(history);
Map<String, List<Value>> instanceValueMap = new HashMap<>(8);
Set<String> instances = new HashSet<>(8);
if (label != null) {
instances.add(label);
}
if (instances.isEmpty()) {
// query the instance
String queryInstanceSql = String.format(QUERY_INSTANCE_SQL, table);
Map<String, Object> instanceQueryResult = executeQuery(queryInstanceSql);
if (instanceQueryResult != null && instanceQueryResult.containsKey("dataset")) {
List<List<Object>> dataset = (List<List<Object>>) instanceQueryResult.get("dataset");
for (List<Object> row : dataset) {
if (!row.isEmpty() && row.get(0) != null) {
instances.add(row.get(0).toString());
}
}
}
}
try {
if (instances.isEmpty()) {
instances.add("");
}
for (String instanceValue : instances) {
String selectSql = String.format(QUERY_HISTORY_INTERVAL_WITH_INSTANCE_SQL, metric, metric, metric, metric, table, instanceValue.replace("'", "\\'"), dateAdd);
Map<String, Object> selectResult = executeQuery(selectSql);
if (selectResult == null || !selectResult.containsKey("dataset")) {
continue;
}
List<Map<String, String>> columns = (List<Map<String, String>>) selectResult.get("columns");
List<List<Object>> dataset = (List<List<Object>>) selectResult.get("dataset");
Map<String, Integer> colMap = new HashMap<>();
for (int i = 0; i < columns.size(); i++) {
colMap.put(columns.get(i).get("name"), i);
}
int tsIdx = colMap.get("ts");
int originIdx = colMap.get("origin");
int meanIdx = colMap.get("mean");
int maxIdx = colMap.get("max");
int minIdx = colMap.get("min");
for (List<Object> row : dataset) {
String tsStr = (String) row.get(tsIdx);
long time = Instant.parse(tsStr).toEpochMilli();
Value.ValueBuilder valueBuilder = Value.builder().time(time);
Object originObj = row.get(originIdx);
if (originObj != null) {
valueBuilder.origin(this.parseDoubleValue(originObj.toString()));
} else {
continue;
}
Object meanObj = row.get(meanIdx);
if (meanObj != null) {
valueBuilder.mean(this.parseDoubleValue(meanObj.toString()));
} else {
continue;
}
Object maxObj = row.get(maxIdx);
if (maxObj != null) {
valueBuilder.max(this.parseDoubleValue(maxObj.toString()));
} else {
continue;
}
Object minObj = row.get(minIdx);
if (minObj != null) {
valueBuilder.min(this.parseDoubleValue(minObj.toString()));
} else {
continue;
}
List<Value> valueList = instanceValueMap.computeIfAbsent(instanceValue, k -> new LinkedList<>());
valueList.add(valueBuilder.build());
}
}
} catch (Exception e) {
log.error("select history interval metric data in questdb error, msg: {}", e.getMessage());
}
return instanceValueMap;
}
private Map<String, Object> executeQuery(String sql) {
try {
String encodedSql = URLEncoder.encode(sql, StandardCharsets.UTF_8);
String url = queryBaseUrl + encodedSql + "&timestamptype=rfc3339";
String authHeader = "Basic " + Base64.getEncoder().encodeToString(
(questdbProperties.username() + ":" + questdbProperties.password())
.getBytes(StandardCharsets.UTF_8)
);
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization", authHeader)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
log.error("QuestDB query failed: {} - {}", response.code(), response.message());
return null;
}
String body = response.body().string();
return JsonUtil.fromJson(body, Map.class);
}
} catch (Exception e) {
log.error("Error executing QuestDB query: {} - {}", sql, e.getMessage());
return null;
}
}
private String getDateAdd(String history) {
history = history.toLowerCase();
char unitChar = history.charAt(history.length() - 1);
int count = Integer.parseInt(history.substring(0, history.length() - 1));
String unit;
switch (unitChar) {
case 'd':
unit = "d";
break;
case 'h':
unit = "h";
break;
case 'm': // minute
unit = "m";
break;
case 's':
unit = "s";
break;
default: throw new IllegalArgumentException("Invalid history unit: " + unitChar);
}
return String.format("dateadd('%s', %d, now())", unit, -count);
}
private String generateTable(String app, String metrics, Long monitorId) {
return app + "_" + metrics + "_" + monitorId;
}
private String parseDoubleValue(String value) {
return (new BigDecimal(value)).setScale(4, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
}
private static X509TrustManager defaultTrustManager() {
return new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
};
}
private static SSLSocketFactory defaultSslSocketFactory() {
try {
SSLContext sslContext = SSLContexts.createDefault();
sslContext.init(null, new TrustManager[]{
defaultTrustManager()
}, new SecureRandom());
return sslContext.getSocketFactory();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static HostnameVerifier noopHostnameVerifier() {
return (s, sslSession) -> true;
}
@Override
public void destroy() throws Exception {
if (this.sender != null) {
this.sender.close();
}
if (this.client != null) {
this.client.dispatcher().executorService().shutdown();
}
}
}
@@ -1,39 +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.
*/
package org.apache.hertzbeat.warehouse.store.history.tsdb.questdb;
import org.apache.hertzbeat.common.constants.ConfigConstants;
import org.apache.hertzbeat.common.constants.SignConstants;
import org.apache.hertzbeat.warehouse.constants.WarehouseConstants;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.DefaultValue;
/**
* QuestDB configuration information
*/
@ConfigurationProperties(prefix = ConfigConstants.FunctionModuleConstants.WAREHOUSE
+ SignConstants.DOT
+ WarehouseConstants.STORE
+ SignConstants.DOT
+ WarehouseConstants.HistoryName.QUEST_DB)
public record QuestdbProperties(@DefaultValue("false") boolean enabled,
String url,
String username,
String password) {
}
+1
View File
@@ -3,6 +3,7 @@ title: Cloud Monitoring System HertzBeat v1.0 Officially Released
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: Cloud Monitoring System HertzBeat v1.1.0 Released! Start Your Monitoring
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: HertzBeat Monitoring System v1.1.0 Released! Start Your Monitoring Journe
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: HertzBeat v1.1.1 is Publish
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: Cloud monitoring system HertzBeat v1.1.3 released!
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: Best Practices for SSL Certificate Expiration Monitoring
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource, practice]
---
+1
View File
@@ -3,6 +3,7 @@ title: HertzBeat v1.2.0 Released! Easy-to-use and friendly open source real-time
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: HertzBeat v1.2.2Support K8S Monitor And More.
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: 恭喜 HertzBeat 迎来了两位新晋社区Committer
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: HertzBeat v1.2.3Support Prometheus,ShenYu and IotDb
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: Use HertzBeat Monitoring IoTDB
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource, practice]
---
+1
View File
@@ -3,6 +3,7 @@ title: HertzBeat's Monitoring Practice for API Gateway Apache ShenYu
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource, practice]
---
@@ -3,6 +3,7 @@ title: Monitoring Practices for DynamicTp Thread Pooling Framework with HertzBea
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource, practice]
---
+1
View File
@@ -3,6 +3,7 @@ title: Welcome two new Committers from HertzBeat
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource]
---
+1
View File
@@ -3,6 +3,7 @@ title: Use the open source real-time monitoring tool HertzBeat to monitor and al
author: tom
author_title: tom
author_url: https://github.com/tomsun28
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
tags: [opensource, practice]
Keywords: [Open source monitoring tool, open source database monitoring, Mysql database monitoring]
---

Some files were not shown because too many files have changed in this diff Show More