From d6d6d3c81e0bcad9bf1b85199e6495ffde75bbe7 Mon Sep 17 00:00:00 2001 From: YuLuo Date: Sun, 19 May 2024 07:34:34 +0800 Subject: [PATCH 1/7] [chore] optimize code style (#2000) Signed-off-by: yuluo-yx Co-authored-by: tomsun28 --- hip/README.md | 2 +- hip/TEMPLATE.md | 2 +- hip/hip-01.md | 2 +- .../src/main/java/org/apache/hertzbeat/plugin/Plugin.java | 5 ++--- .../org/apache/hertzbeat/plugin/impl/DemoPluginImpl.java | 7 ++++--- .../META-INF/services/org.apache.hertzbeat.plugin.Plugin | 2 +- push/src/main/resources/META-INF/spring.factories | 2 +- .../java/org/apache/hertzbeat/remoting/RemotingServer.java | 4 ++++ script/docker/server/README.md | 1 - .../org/apache/hertzbeat/warehouse/dao/HistoryDao.java | 1 - .../listener/WareHouseApplicationReadyListener.java | 4 +--- .../warehouse/store/history/HistoryDataReader.java | 2 +- .../warehouse/store/history/HistoryDataWriter.java | 2 +- .../history/vm/VictoriaMetricsClusterDataStorage.java | 2 -- warehouse/src/main/resources/META-INF/spring.factories | 2 +- .../hertzbeat/warehouse/store/MemoryDataStorageTest.java | 2 +- .../warehouse/store/MetricsDataRedisCodecTest.java | 2 +- .../hertzbeat/warehouse/store/RedisDataStorageTest.java | 2 +- .../hertzbeat/warehouse/store/TdEngineDataStorageTest.java | 2 +- 19 files changed, 23 insertions(+), 25 deletions(-) diff --git a/hip/README.md b/hip/README.md index d52077b7566..038d2a9cb2f 100644 --- a/hip/README.md +++ b/hip/README.md @@ -90,4 +90,4 @@ It is advised to create a master GitHub issue to formulate the execution plan an - Merged PR means the HIP was accepted. - Closed PR means the HIP was rejected. - Open PR means the HIP was submitted and is in the process of discussion. -2. You can also take a look at the file in the `hip` folder. Each one is an approved HIP. \ No newline at end of file +2. You can also take a look at the file in the `hip` folder. Each one is an approved HIP. diff --git a/hip/TEMPLATE.md b/hip/TEMPLATE.md index 2dafb39ab21..29689aed402 100644 --- a/hip/TEMPLATE.md +++ b/hip/TEMPLATE.md @@ -140,4 +140,4 @@ If there are alternatives that were already considered by the authors or, after Updated afterwards --> * Mailing List discussion thread: -* Mailing List voting thread: \ No newline at end of file +* Mailing List voting thread: diff --git a/hip/hip-01.md b/hip/hip-01.md index b2f1fd9e310..51fdc5af460 100644 --- a/hip/hip-01.md +++ b/hip/hip-01.md @@ -51,4 +51,4 @@ Supplement the relevant unit tests. Updated afterwards --> * Mailing List discussion thread: https://lists.apache.org/thread/cvvo7xg35fxq7kml5ggdrcdygrx6yvyj -* Mailing List voting thread: https://lists.apache.org/thread/1s7dhrb27qfdx1gsh29dvmo8frjbt619 \ No newline at end of file +* Mailing List voting thread: https://lists.apache.org/thread/1s7dhrb27qfdx1gsh29dvmo8frjbt619 diff --git a/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java b/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java index 33739770625..d72632925b5 100644 --- a/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java +++ b/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java @@ -15,7 +15,6 @@ * limitations under the License. */ - package org.apache.hertzbeat.plugin; import org.apache.hertzbeat.common.entity.alerter.Alert; @@ -25,8 +24,8 @@ */ public interface Plugin { - /* - * execute when alert + /** + * execute when alert */ void alert(Alert alert); } diff --git a/plugin/src/main/java/org/apache/hertzbeat/plugin/impl/DemoPluginImpl.java b/plugin/src/main/java/org/apache/hertzbeat/plugin/impl/DemoPluginImpl.java index 94f90664dee..f263b172ed7 100644 --- a/plugin/src/main/java/org/apache/hertzbeat/plugin/impl/DemoPluginImpl.java +++ b/plugin/src/main/java/org/apache/hertzbeat/plugin/impl/DemoPluginImpl.java @@ -15,7 +15,6 @@ * limitations under the License. */ - package org.apache.hertzbeat.plugin.impl; import lombok.extern.slf4j.Slf4j; @@ -27,11 +26,13 @@ */ @Slf4j public class DemoPluginImpl implements Plugin { - /* - * execute when alert + + /** + * execute when alert */ @Override public void alert(Alert alert) { log.info("DemoPluginImpl alert: {}", alert); } + } diff --git a/plugin/src/main/resources/META-INF/services/org.apache.hertzbeat.plugin.Plugin b/plugin/src/main/resources/META-INF/services/org.apache.hertzbeat.plugin.Plugin index af4bfd73bb2..8da17400556 100644 --- a/plugin/src/main/resources/META-INF/services/org.apache.hertzbeat.plugin.Plugin +++ b/plugin/src/main/resources/META-INF/services/org.apache.hertzbeat.plugin.Plugin @@ -1 +1 @@ -org.apache.hertzbeat.plugin.impl.DemoPluginImpl \ No newline at end of file +org.apache.hertzbeat.plugin.impl.DemoPluginImpl diff --git a/push/src/main/resources/META-INF/spring.factories b/push/src/main/resources/META-INF/spring.factories index f95f2645b66..a433ed2b39b 100644 --- a/push/src/main/resources/META-INF/spring.factories +++ b/push/src/main/resources/META-INF/spring.factories @@ -14,4 +14,4 @@ # limitations under the License. org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.hertzbeat.push.config.PushAutoConfiguration \ No newline at end of file +org.apache.hertzbeat.push.config.PushAutoConfiguration diff --git a/remoting/src/main/java/org/apache/hertzbeat/remoting/RemotingServer.java b/remoting/src/main/java/org/apache/hertzbeat/remoting/RemotingServer.java index 0927e441423..35fdd1d48fd 100644 --- a/remoting/src/main/java/org/apache/hertzbeat/remoting/RemotingServer.java +++ b/remoting/src/main/java/org/apache/hertzbeat/remoting/RemotingServer.java @@ -51,5 +51,9 @@ public interface RemotingServer extends RemotingService { */ ClusterMsg.Message sendMsgSync(Channel channel, ClusterMsg.Message request, int timeoutMillis); + /** + * register hook. + * @param nettyHookList hook list + */ void registerHook(List nettyHookList); } diff --git a/script/docker/server/README.md b/script/docker/server/README.md index 4cfc50fcddb..df4aca922c1 100644 --- a/script/docker/server/README.md +++ b/script/docker/server/README.md @@ -25,5 +25,4 @@ $ docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/her # Inspect the image info $ docker buildx imagetools inspect apache/hertzbeat:v1.0.0 - ``` diff --git a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/dao/HistoryDao.java b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/dao/HistoryDao.java index 7fb60c2f637..d00bec8e4ff 100644 --- a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/dao/HistoryDao.java +++ b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/dao/HistoryDao.java @@ -17,7 +17,6 @@ package org.apache.hertzbeat.warehouse.dao; - import org.apache.hertzbeat.common.entity.warehouse.History; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; diff --git a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/listener/WareHouseApplicationReadyListener.java b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/listener/WareHouseApplicationReadyListener.java index a611358b535..ba7501071c7 100644 --- a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/listener/WareHouseApplicationReadyListener.java +++ b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/listener/WareHouseApplicationReadyListener.java @@ -24,10 +24,8 @@ import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - - /** - * + * WareHouseApplicationReadyListener */ @Slf4j @Component diff --git a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/HistoryDataReader.java b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/HistoryDataReader.java index c8250262bba..b98a6e0f8bd 100644 --- a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/HistoryDataReader.java +++ b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/HistoryDataReader.java @@ -22,7 +22,7 @@ import org.apache.hertzbeat.common.entity.dto.Value; /** - * + * history data reader */ public interface HistoryDataReader { diff --git a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/HistoryDataWriter.java b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/HistoryDataWriter.java index e606886a72a..6ea065bb178 100644 --- a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/HistoryDataWriter.java +++ b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/HistoryDataWriter.java @@ -20,7 +20,7 @@ import org.apache.hertzbeat.common.entity.message.CollectRep; /** - * + * history data writer */ public interface HistoryDataWriter { diff --git a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/vm/VictoriaMetricsClusterDataStorage.java b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/vm/VictoriaMetricsClusterDataStorage.java index 4a779c71584..cd25dd1f748 100644 --- a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/vm/VictoriaMetricsClusterDataStorage.java +++ b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/vm/VictoriaMetricsClusterDataStorage.java @@ -17,7 +17,6 @@ package org.apache.hertzbeat.warehouse.store.history.vm; - import com.fasterxml.jackson.databind.JsonNode; import java.math.BigDecimal; import java.math.RoundingMode; @@ -59,7 +58,6 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; - /** * tdengine data storage */ diff --git a/warehouse/src/main/resources/META-INF/spring.factories b/warehouse/src/main/resources/META-INF/spring.factories index f155fb8251a..2df923ea4c1 100644 --- a/warehouse/src/main/resources/META-INF/spring.factories +++ b/warehouse/src/main/resources/META-INF/spring.factories @@ -14,4 +14,4 @@ # limitations under the License. org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.hertzbeat.warehouse.WarehouseAutoConfiguration \ No newline at end of file +org.apache.hertzbeat.warehouse.WarehouseAutoConfiguration diff --git a/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/MemoryDataStorageTest.java b/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/MemoryDataStorageTest.java index ba3a206621b..da0e1f4dfc1 100644 --- a/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/MemoryDataStorageTest.java +++ b/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/MemoryDataStorageTest.java @@ -37,4 +37,4 @@ void getCurrentMetricsData() { @Test void destroy() { } -} \ No newline at end of file +} diff --git a/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/MetricsDataRedisCodecTest.java b/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/MetricsDataRedisCodecTest.java index dd265d8d682..b42fe9dff68 100644 --- a/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/MetricsDataRedisCodecTest.java +++ b/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/MetricsDataRedisCodecTest.java @@ -45,4 +45,4 @@ void encodeKey() { @Test void encodeValue() { } -} \ No newline at end of file +} diff --git a/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/RedisDataStorageTest.java b/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/RedisDataStorageTest.java index 2beae5064ec..163a26ccd4d 100644 --- a/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/RedisDataStorageTest.java +++ b/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/RedisDataStorageTest.java @@ -37,4 +37,4 @@ void getCurrentMetricsData() { @Test void destroy() { } -} \ No newline at end of file +} diff --git a/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/TdEngineDataStorageTest.java b/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/TdEngineDataStorageTest.java index dc1cfdef22a..15ac3155154 100644 --- a/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/TdEngineDataStorageTest.java +++ b/warehouse/src/test/java/org/apache/hertzbeat/warehouse/store/TdEngineDataStorageTest.java @@ -49,4 +49,4 @@ void getHistoryMetricData() { @Test void getHistoryIntervalMetricData() { } -} \ No newline at end of file +} From 7190bb3ad44eb7b76657d647b63e8504385db842 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 19 May 2024 07:37:49 +0800 Subject: [PATCH 2/7] [improve] bump up eslint-plugin-jsdoc to 48.2.5 to support node 20+ (#2005) Co-authored-by: tomsun28 --- web-app/.eslintrc.js | 8 ++- web-app/package.json | 2 +- web-app/yarn.lock | 135 +++++++++++++++++++++++++++++++++---------- 3 files changed, 112 insertions(+), 33 deletions(-) diff --git a/web-app/.eslintrc.js b/web-app/.eslintrc.js index 78aaeb78d5f..4edcdce4652 100644 --- a/web-app/.eslintrc.js +++ b/web-app/.eslintrc.js @@ -20,7 +20,13 @@ module.exports = { ], rules: { 'prettier/prettier': ['error', prettierConfig], - 'jsdoc/newline-after-description': 1, + 'jsdoc/tag-lines': [ + 'error', + 'any', + { + startLines: 1, + }, + ], '@angular-eslint/component-class-suffix': [ 'error', { diff --git a/web-app/package.json b/web-app/package.json index b0c9e8bff1a..844648b5d7f 100644 --- a/web-app/package.json +++ b/web-app/package.json @@ -92,7 +92,7 @@ "eslint-config-prettier": "8.6.0", "eslint-plugin-deprecation": "1.3.3", "eslint-plugin-import": "2.26.0", - "eslint-plugin-jsdoc": "39.7.5", + "eslint-plugin-jsdoc": "48.2.5", "eslint-plugin-prefer-arrow": "1.2.3", "eslint-plugin-prettier": "4.2.1", "husky": "7.0.4", diff --git a/web-app/yarn.lock b/web-app/yarn.lock index b71b37836fe..9e8bb57cd60 100644 --- a/web-app/yarn.lock +++ b/web-app/yarn.lock @@ -1430,14 +1430,17 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== -"@es-joy/jsdoccomment@~0.36.1": - version "0.36.1" - resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.36.1.tgz#c37db40da36e4b848da5fd427a74bae3b004a30f" - integrity sha512-922xqFsTpHs6D0BUiG4toiyPOMc8/jafnWKxz1KWgS4XzKPy2qXf1Pe6UFuNSCQqt6tOuhAWXBNuuyUhJmw9Vg== - dependencies: - comment-parser "1.3.1" - esquery "^1.4.0" - jsdoc-type-pratt-parser "~3.1.0" +"@es-joy/jsdoccomment@~0.43.0": + version "0.43.0" + resolved "https://registry.npmmirror.com/@es-joy/jsdoccomment/-/jsdoccomment-0.43.0.tgz#35c295cadd0a939d1a3a6cd1548f66ec76d38870" + integrity sha512-Q1CnsQrytI3TlCB1IVWXWeqUIPGVEKGaE7IbVdt13Nq/3i0JESAkQQERrfiQkmlpijl+++qyqPgaS31Bvc1jRQ== + dependencies: + "@types/eslint" "^8.56.5" + "@types/estree" "^1.0.5" + "@typescript-eslint/types" "^7.2.0" + comment-parser "1.4.1" + esquery "^1.5.0" + jsdoc-type-pratt-parser "~4.0.0" "@esbuild/android-arm64@0.17.8": version "0.17.8" @@ -1970,7 +1973,15 @@ "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*": +"@types/eslint@^8.56.5": + version "8.56.10" + resolved "https://registry.npmmirror.com/@types/eslint/-/eslint-8.56.10.tgz#eb2370a73bf04a901eeba8f22595c7ee0f7eb58d" + integrity sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*", "@types/estree@^1.0.5": version "1.0.5" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== @@ -2296,6 +2307,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f" integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ== +"@typescript-eslint/types@^7.2.0": + version "7.9.0" + resolved "https://registry.npmmirror.com/@typescript-eslint/types/-/types-7.9.0.tgz#b58e485e4bfba055659c7e683ad4f5f0821ae2ec" + integrity sha512-oZQD9HEWQanl9UfsbGVcZ2cGaR0YT5476xfWE0oE5kQa2sNK2frxOlkeacLOTh9po4AlUT5rtkGyYM5kew0z5w== + "@typescript-eslint/typescript-estree@5.48.2": version "5.48.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.2.tgz#6e206b462942b32383582a6c9251c05021cc21b0" @@ -2754,6 +2770,11 @@ anymatch@~3.1.2: resolved "https://registry.yarnpkg.com/aproba/-/aproba-2.0.0.tgz#52520b8ae5b569215b354efc0caa3fe1e45a8adc" integrity sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ== +are-docs-informative@^0.0.2: + version "0.0.2" + resolved "https://registry.npmmirror.com/are-docs-informative/-/are-docs-informative-0.0.2.tgz#387f0e93f5d45280373d387a59d34c96db321963" + integrity sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig== + are-we-there-yet@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz#372e0e7bd279d8e94c653aaa1f67200884bf3e1c" @@ -3231,6 +3252,11 @@ buffer@^5.5.0: base64-js "^1.3.1" ieee754 "^1.1.13" +builtin-modules@^3.3.0: + version "3.3.0" + resolved "https://registry.npmmirror.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6" + integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw== + builtins@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/builtins/-/builtins-5.0.1.tgz#87f6db9ab0458be728564fa81d876d8d74552fa9" @@ -3717,10 +3743,10 @@ commander@^2.20.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -comment-parser@1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.3.1.tgz#3d7ea3adaf9345594aedee6563f422348f165c1b" - integrity sha512-B52sN2VNghyq5ofvUsqZjmk6YkihBX5vMSChmSK9v4ShjKf3Vk5Xcmgpw4o+iIgtrnM/u5FiMpz9VKb8lpBveA== +comment-parser@1.4.1: + version "1.4.1" + resolved "https://registry.npmmirror.com/comment-parser/-/comment-parser-1.4.1.tgz#bdafead37961ac079be11eb7ec65c4d021eaf9cc" + integrity sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg== commondir@^1.0.1: version "1.0.1" @@ -4695,18 +4721,20 @@ eslint-plugin-import@2.26.0: resolve "^1.22.0" tsconfig-paths "^3.14.1" -eslint-plugin-jsdoc@39.7.5: - version "39.7.5" - resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.7.5.tgz#473f9fd372a231a1dae5d55df70b1d0fb64f95da" - integrity sha512-6L90P0AnZcE4ra7nocolp9vTjgVr2wEZ7jPnEA/X30XAoQPk+wvnaq61n164Tf7Fg4QPpJtRSCPpApOsfWDdNA== +eslint-plugin-jsdoc@48.2.5: + version "48.2.5" + resolved "https://registry.npmmirror.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-48.2.5.tgz#66ec712632852faa15065a094342786858f13c49" + integrity sha512-ZeTfKV474W1N9niWfawpwsXGu+ZoMXu4417eBROX31d7ZuOk8zyG66SO77DpJ2+A9Wa2scw/jRqBPnnQo7VbcQ== dependencies: - "@es-joy/jsdoccomment" "~0.36.1" - comment-parser "1.3.1" + "@es-joy/jsdoccomment" "~0.43.0" + are-docs-informative "^0.0.2" + comment-parser "1.4.1" debug "^4.3.4" escape-string-regexp "^4.0.0" - esquery "^1.4.0" - semver "^7.3.8" - spdx-expression-parse "^3.0.1" + esquery "^1.5.0" + is-builtin-module "^3.2.1" + semver "^7.6.1" + spdx-expression-parse "^4.0.0" eslint-plugin-prefer-arrow@1.2.3: version "1.2.3" @@ -4810,7 +4838,7 @@ esprima@^4.0.0: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.4.0, esquery@^1.4.2: +esquery@^1.4.2, esquery@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b" integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg== @@ -6213,6 +6241,13 @@ is-buffer@^2.0.0: resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191" integrity sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ== +is-builtin-module@^3.2.1: + version "3.2.1" + resolved "https://registry.npmmirror.com/is-builtin-module/-/is-builtin-module-3.2.1.tgz#f03271717d8654cfcaf07ab0463faa3571581169" + integrity sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A== + dependencies: + builtin-modules "^3.3.0" + is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7: version "1.2.7" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" @@ -6712,10 +6747,10 @@ jsbn@~0.1.0: resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg== -jsdoc-type-pratt-parser@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-3.1.0.tgz#a4a56bdc6e82e5865ffd9febc5b1a227ff28e67e" - integrity sha512-MgtD0ZiCDk9B+eI73BextfRrVQl0oyzRG8B2BjORts6jbunj4ScKPcyXGTbB6eXL4y9TzxCm6hyeLq/2ASzNdw== +jsdoc-type-pratt-parser@~4.0.0: + version "4.0.0" + resolved "https://registry.npmmirror.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz#136f0571a99c184d84ec84662c45c29ceff71114" + integrity sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ== jsesc@^2.5.1: version "2.5.2" @@ -9558,6 +9593,11 @@ semver@^7.0.0, semver@^7.1.1, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semve dependencies: lru-cache "^6.0.0" +semver@^7.6.1: + version "7.6.2" + resolved "https://registry.npmmirror.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13" + integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w== + send@0.18.0: version "0.18.0" resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" @@ -10001,7 +10041,7 @@ spdx-exceptions@^2.1.0: resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz#5d607d27fc806f66d7b64a766650fa890f04ed66" integrity sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w== -spdx-expression-parse@^3.0.0, spdx-expression-parse@^3.0.1: +spdx-expression-parse@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== @@ -10009,6 +10049,14 @@ spdx-expression-parse@^3.0.0, spdx-expression-parse@^3.0.1: spdx-exceptions "^2.1.0" spdx-license-ids "^3.0.0" +spdx-expression-parse@^4.0.0: + version "4.0.0" + resolved "https://registry.npmmirror.com/spdx-expression-parse/-/spdx-expression-parse-4.0.0.tgz#a23af9f3132115465dac215c099303e4ceac5794" + integrity sha512-Clya5JIij/7C6bRR22+tnGXbc4VKlibKSVj2iHvVeX5iMW7s1SIQlqu699JkODJJIhh/pUu8L0/VLh8xflD+LQ== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + spdx-license-ids@^3.0.0: version "3.0.17" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.17.tgz#887da8aa73218e51a1d917502d79863161a93f9c" @@ -10139,7 +10187,16 @@ string-argv@0.3.2: resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6" integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q== -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -10217,7 +10274,7 @@ stringify-entities@^1.0.1: is-alphanumerical "^1.0.0" is-hexadecimal "^1.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -10238,6 +10295,13 @@ strip-ansi@^5.1.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -11478,7 +11542,7 @@ word@~0.3.0: resolved "https://registry.yarnpkg.com/word/-/word-0.3.0.tgz#8542157e4f8e849f4a363a288992d47612db9961" integrity sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -11496,6 +11560,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.0.1, wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" From 22086c6c3a893a7fe23e4fc5d12042bae0fa2d59 Mon Sep 17 00:00:00 2001 From: boatrainlsz Date: Sun, 19 May 2024 07:39:42 +0800 Subject: [PATCH 3/7] [doc] fix doc highlighting (#2006) Signed-off-by: boatrainlsz Co-authored-by: tomsun28 --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a3b43e4e99e..f7c9e37b12f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -205,7 +205,7 @@ Add WeChat account `tan-cloud` to pull you into the WeChat group. 6. 待本地后端启动后,在web-app目录下启动本地前端 `ng serve --open` -7. 浏览器访问 localhost:4200 即可开始,默认账号密码 admin/hertzbeat** +7. 浏览器访问 localhost:4200 即可开始,默认账号密码 *admin/hertzbeat* ### 寻找任务 From 074fcd4df028d19c8152da4ab91887fad24b0867 Mon Sep 17 00:00:00 2001 From: Bill Lau <656860993@qq.com> Date: Sun, 19 May 2024 08:04:31 +0800 Subject: [PATCH 4/7] [web-app] feature: case insensitive search (#2007) Co-authored-by: tomsun28 --- .../alert/alert-setting/alert-setting.component.html | 2 +- .../routes/alert/alert-setting/alert-setting.component.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html index e4cd5144dd3..18872aaf86c 100644 --- a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html +++ b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html @@ -194,7 +194,7 @@ required name="target" id="target" - [nzShowSearch]="true" + [nzShowSearch]="{ filter: caseInsensitiveFilter }" [nzPlaceHolder]="'alert.setting.target.place-holder' | i18n" [nzOptions]="appHierarchies" [(ngModel)]="cascadeValues" diff --git a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts index b96044be594..8d407656d6f 100644 --- a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts +++ b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts @@ -20,6 +20,7 @@ import { Component, Inject, OnInit } from '@angular/core'; import { I18NService } from '@core'; import { ALAIN_I18N_TOKEN } from '@delon/theme'; +import { NzCascaderFilter } from 'ng-zorro-antd/cascader'; import { ModalButtonOptions, NzModalService } from 'ng-zorro-antd/modal'; import { NzNotificationService } from 'ng-zorro-antd/notification'; import { NzTableQueryParams } from 'ng-zorro-antd/table'; @@ -396,6 +397,12 @@ export class AlertSettingComponent implements OnInit { currentMetrics: any[] = []; alertRules: any[] = [{}]; isExpr = false; + caseInsensitiveFilter: NzCascaderFilter = (i, p) => { + return p.some(o => { + const label = o.label; + return !!label && label.toLowerCase().indexOf(i.toLowerCase()) !== -1; + }); + }; cascadeOnChange(values: string[]): void { if (values == null || values.length != 3) { return; From f9a2d9a3e0e669802c3d70372a6c3532e92a479b Mon Sep 17 00:00:00 2001 From: liutianyou Date: Mon, 20 May 2024 11:32:35 +0800 Subject: [PATCH 5/7] [feature] Support time calculation expressions. (#2009) --- .../collect/http/HttpCollectImpl.java | 18 +-- .../collector/util/TimeExpressionUtil.java | 128 ++++++++++++++++++ .../util/TimeExpressionUtilTest.java | 80 +++++++++++ .../src/main/resources/define/app-openai.yml | 3 + 4 files changed, 213 insertions(+), 16 deletions(-) create mode 100644 collector/src/main/java/org/apache/hertzbeat/collector/util/TimeExpressionUtil.java create mode 100644 collector/src/test/java/org/apache/hertzbeat/collector/util/TimeExpressionUtilTest.java diff --git a/collector/src/main/java/org/apache/hertzbeat/collector/collect/http/HttpCollectImpl.java b/collector/src/main/java/org/apache/hertzbeat/collector/collect/http/HttpCollectImpl.java index 886e3baed96..ed5f18f9056 100644 --- a/collector/src/main/java/org/apache/hertzbeat/collector/collect/http/HttpCollectImpl.java +++ b/collector/src/main/java/org/apache/hertzbeat/collector/collect/http/HttpCollectImpl.java @@ -28,8 +28,6 @@ import java.net.ConnectException; import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -53,6 +51,7 @@ import org.apache.hertzbeat.collector.dispatch.DispatchConstants; import org.apache.hertzbeat.collector.util.CollectUtil; import org.apache.hertzbeat.collector.util.JsonPathParser; +import org.apache.hertzbeat.collector.util.TimeExpressionUtil; import org.apache.hertzbeat.common.constants.CollectorConstants; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.job.Metrics; @@ -92,11 +91,6 @@ */ @Slf4j public class HttpCollectImpl extends AbstractCollect { - - public static final String OpenAIHost = "api.openai.com"; - public static final String OpenAIUsageAPI = "/dashboard/billing/usage"; - public static final String startDate = "start_date"; - public static final String endDate = "end_date"; private static final Map EXPORTER_PARSER_TABLE = new ConcurrentHashMap<>(); private final Set defaultSuccessStatusCodes = Stream.of(HttpStatus.SC_OK, HttpStatus.SC_CREATED, HttpStatus.SC_ACCEPTED, HttpStatus.SC_MULTIPLE_CHOICES, HttpStatus.SC_MOVED_PERMANENTLY, @@ -499,18 +493,10 @@ public HttpUriRequest createHttpRequest(HttpProtocol httpProtocol) { if (params != null && !params.isEmpty()) { for (Map.Entry param : params.entrySet()) { if (StringUtils.hasText(param.getValue())) { - requestBuilder.addParameter(param.getKey(), param.getValue()); + requestBuilder.addParameter(param.getKey(), TimeExpressionUtil.calculate(param.getValue())); } } } - // OpenAI /dashboard/billing/usage - if (OpenAIHost.equalsIgnoreCase(httpProtocol.getHost()) && OpenAIUsageAPI.equalsIgnoreCase(httpProtocol.getUrl())) { - LocalDate today = LocalDate.now(); - LocalDate tomorrow = LocalDate.now().plusDays(1); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - requestBuilder.addParameter(startDate, today.format(formatter)); - requestBuilder.addParameter(endDate, tomorrow.format(formatter)); - } // The default request header can be overridden if customized // keep-alive requestBuilder.addHeader(HttpHeaders.CONNECTION, "keep-alive"); diff --git a/collector/src/main/java/org/apache/hertzbeat/collector/util/TimeExpressionUtil.java b/collector/src/main/java/org/apache/hertzbeat/collector/util/TimeExpressionUtil.java new file mode 100644 index 00000000000..69f16ca3c6c --- /dev/null +++ b/collector/src/main/java/org/apache/hertzbeat/collector/util/TimeExpressionUtil.java @@ -0,0 +1,128 @@ +/* + * 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.util; + +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalUnit; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; + +/** + * time expression deal util + */ +public class TimeExpressionUtil { + + private TimeExpressionUtil() { + } + + + /** + * localDatetime formatter + */ + private static final Map> FORMATTER = new LinkedHashMap<>(); + /** + * unit string mapping to TemporalUnit + */ + private static final Map UNIT_MAP = new HashMap<>(); + + private static final String FORMATTER_NAMES; + private static final String UNIT_NAMES; + + + static { + FORMATTER.put("now", date -> DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(date)); + FORMATTER.put("date", date -> DateTimeFormatter.ofPattern("yyyy-MM-dd").format(date)); + FORMATTER.put("timestamp10", date -> String.valueOf(date.toEpochSecond(ZoneOffset.UTC))); + FORMATTER.put("timestamp", date -> String.valueOf(date.toInstant(ZoneOffset.UTC).toEpochMilli())); + FORMATTER.put("time", date -> DateTimeFormatter.ofPattern("HH:mm:ss").format(date)); + FORMATTER.put("year", date -> DateTimeFormatter.ofPattern("yyyy").format(date)); + FORMATTER.put("month", date -> DateTimeFormatter.ofPattern("MM").format(date)); + FORMATTER.put("day", date -> DateTimeFormatter.ofPattern("dd").format(date)); + FORMATTER.put("hour", date -> DateTimeFormatter.ofPattern("HH").format(date)); + FORMATTER.put("minute", date -> DateTimeFormatter.ofPattern("mm").format(date)); + FORMATTER.put("millisecond", date -> DateTimeFormatter.ofPattern("SSS").format(date)); + FORMATTER.put("second", date -> DateTimeFormatter.ofPattern("ss").format(date)); + + UNIT_MAP.put('y', ChronoUnit.YEARS); + UNIT_MAP.put('M', ChronoUnit.MONTHS); + UNIT_MAP.put('d', ChronoUnit.DAYS); + UNIT_MAP.put('H', ChronoUnit.HOURS); + UNIT_MAP.put('m', ChronoUnit.MINUTES); + UNIT_MAP.put('s', ChronoUnit.SECONDS); + UNIT_MAP.put('w', ChronoUnit.WEEKS); + + FORMATTER_NAMES = String.join("|", FORMATTER.keySet()); + UNIT_NAMES = UNIT_MAP.keySet().stream().map(String::valueOf).collect(Collectors.joining("")); + } + + + public static String calculate(String template) { + return calculate(template, LocalDateTime.now()); + } + + public static String calculate(String template, LocalDateTime now) { + if (StringUtils.isBlank(template)) { + return template; + } + final String regex = "\\$\\{(@(" + FORMATTER_NAMES + ")(\\s*[-+]\\s*\\d+[" + UNIT_NAMES + "])*)}"; + + final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); + final Matcher matcher = pattern.matcher(template); + + while (matcher.find()) { + String part = matcher.group(0); + String expression = matcher.group(1); + template = template.replace(part, calculateExpression(expression, now)); + + } + return template; + } + + + private static String calculateExpression(String expression, LocalDateTime now) { + expression = expression.replaceAll("\\s", ""); + final String regex = "(@(" + FORMATTER_NAMES + "))|([-+]\\d+[" + UNIT_NAMES + "])"; + final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); + final Matcher matcher = pattern.matcher(expression); + List elements = new ArrayList<>(); + while (matcher.find()) { + elements.add(matcher.group(0)); + } + LocalDateTime result = now; + for (int i = 1; i < elements.size(); i++) { + String element = elements.get(i); + int operator = element.charAt(0) == '-' ? -1 : 1; + int duration = Integer.parseInt(element.substring(1, element.length() - 1)); + char unit = element.charAt(element.length() - 1); + result = result.plus(operator * duration, UNIT_MAP.get(unit)); + + } + return FORMATTER.get(elements.get(0).substring(1)).apply(result); + } +} diff --git a/collector/src/test/java/org/apache/hertzbeat/collector/util/TimeExpressionUtilTest.java b/collector/src/test/java/org/apache/hertzbeat/collector/util/TimeExpressionUtilTest.java new file mode 100644 index 00000000000..f0cc04ce9fd --- /dev/null +++ b/collector/src/test/java/org/apache/hertzbeat/collector/util/TimeExpressionUtilTest.java @@ -0,0 +1,80 @@ +/* + * 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.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.time.LocalDateTime; +import org.junit.jupiter.api.Test; + +/** + * test for TimeExpressionUtil + */ +class TimeExpressionUtilTest { + + + LocalDateTime now = LocalDateTime.of(2022, 4, 24, 2, 40, 0); + + @Test + void testBlankTemplate() { + assertEquals("", TimeExpressionUtil.calculate("", LocalDateTime.now())); + assertNull(TimeExpressionUtil.calculate(null, LocalDateTime.now())); + } + + @Test + void testErrorTemplate() { + assertEquals("hello", TimeExpressionUtil.calculate("hello", LocalDateTime.now())); + assertEquals("${}", TimeExpressionUtil.calculate("${}", LocalDateTime.now())); + assertEquals("${@current-24m}", TimeExpressionUtil.calculate("${@current-24m}", LocalDateTime.now())); + } + + @Test + void testWithSpace() { + assertEquals("2022-04-24 02:40:01", TimeExpressionUtil.calculate("${@now + 1s}", now)); + } + + @Test + void testCalculate() { + assertEquals("2022-04-24 02:40:00", TimeExpressionUtil.calculate("${@now}", now)); + assertEquals("2022-04-24", TimeExpressionUtil.calculate("${@date}", now)); + assertEquals("02:40:00", TimeExpressionUtil.calculate("${@time}", now)); + assertEquals("1650768000000", TimeExpressionUtil.calculate("${@timestamp}", now)); + assertEquals("1650768000", TimeExpressionUtil.calculate("${@timestamp10}", now)); + assertEquals("2022", TimeExpressionUtil.calculate("${@year}", now)); + assertEquals("04", TimeExpressionUtil.calculate("${@month}", now)); + assertEquals("24", TimeExpressionUtil.calculate("${@day}", now)); + assertEquals("02", TimeExpressionUtil.calculate("${@hour}", now)); + assertEquals("40", TimeExpressionUtil.calculate("${@minute}", now)); + assertEquals("00", TimeExpressionUtil.calculate("${@second}", now)); + assertEquals("000", TimeExpressionUtil.calculate("${@millisecond}", now)); + + assertEquals("2022-04-24 02:25:00", TimeExpressionUtil.calculate("${@now-15m}", now)); + assertEquals("2022-05-01 02:40:00", TimeExpressionUtil.calculate("${@now+1w}", now)); + assertEquals("2022-05-01 02:25:00", TimeExpressionUtil.calculate("${@now+1w-15m}", now)); + assertEquals("2022-04-25 02:40:00", TimeExpressionUtil.calculate("${@now+1d}", now)); + assertEquals("02:40:00", TimeExpressionUtil.calculate("${@time+1d}", now)); + assertEquals("2023-04-24 02:40:00", TimeExpressionUtil.calculate("${@now+1y}", now)); + } + + @Test + void testComplexTemplate() { + assertEquals("Three days after 2022-04-24 , is 2022-04-27", TimeExpressionUtil.calculate("Three days after ${@date} , is ${@date+3d}", now)); + assertEquals("2022年04月24日 02:40:00", TimeExpressionUtil.calculate("${@year}年${@month}月${@day}日 ${@time}", now)); + } +} diff --git a/manager/src/main/resources/define/app-openai.yml b/manager/src/main/resources/define/app-openai.yml index e8ab201fee5..e6def2e24ad 100644 --- a/manager/src/main/resources/define/app-openai.yml +++ b/manager/src/main/resources/define/app-openai.yml @@ -313,6 +313,9 @@ metrics: method: GET # if enabled https ssl: false + params: + start_date: ${@date} + end_date: ${@date+1d} # http auth authorization: # http auth type: Basic Auth, Digest Auth, Bearer Token From 066091dc2948db982da3d88cd9c1dd99f0237d77 Mon Sep 17 00:00:00 2001 From: liutianyou Date: Mon, 20 May 2024 11:34:43 +0800 Subject: [PATCH 6/7] [doc] add document for time expression (#2012) Co-authored-by: tomsun28 --- home/docs/advanced/extend-http.md | 1 + home/docs/help/api.md | 2 + home/docs/help/time_expression.md | 64 ++++++++++++++++++ .../current/advanced/extend-http.md | 1 + .../current/help/api.md | 2 + .../current/help/time_expression.md | 66 +++++++++++++++++++ home/sidebars.json | 3 +- 7 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 home/docs/help/time_expression.md create mode 100644 home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/time_expression.md diff --git a/home/docs/advanced/extend-http.md b/home/docs/advanced/extend-http.md index a69b54e84d0..edc0ee623fb 100644 --- a/home/docs/advanced/extend-http.md +++ b/home/docs/advanced/extend-http.md @@ -195,6 +195,7 @@ metrics: method: GET headers: apiVersion: v1 + # query params,support time expression params: param1: param1 param2: param2 diff --git a/home/docs/help/api.md b/home/docs/help/api.md index ed92a722091..4d93f38e088 100644 --- a/home/docs/help/api.md +++ b/home/docs/help/api.md @@ -19,6 +19,8 @@ keywords: [open source monitoring tool, monitoring http api] | Enable HTTPS | Whether to access the website through HTTPS. Note⚠️When HTTPS is enabled, the default corresponding port needs to be changed to 443 | | Username | User name used for interface Basic authentication or Digest authentication | | Password | Password used for interface Basic authentication or Digest authentication | +| Headers | HTTP request headers | +| Params | HTTP query params, support [time expression](time_expression) | | Content-Type | Set the resource type when carrying the BODY request body data request | | Request BODY | Set the carry BODY request body data, which is valid when PUT or POST request method is used | | Collection interval | Interval time of monitor periodic data collection, unit: second, and the minimum interval that can be set is 30 seconds | diff --git a/home/docs/help/time_expression.md b/home/docs/help/time_expression.md new file mode 100644 index 00000000000..e2cb0928b05 --- /dev/null +++ b/home/docs/help/time_expression.md @@ -0,0 +1,64 @@ +--- +id: time_expression +title: Time Expression +sidebar_label: Time Expression +keywords: [ dynamic time, time expressions ] +--- + +### Introduction + +HertzBeat supports using expressions to calculate relative time during monitoring collection, allowing for more flexible time definitions in monitoring templates. + +### Syntax + +``` +${FORMATTER [{ + | - } ]} +``` + +- `FORMATTER`: Determines the format of the expression's result +- `DURATION`: Size of the time period, a positive integer +- `TIME_UNIT`: Unit of the time period + +### Supported Formatting Types + +> Example outputs are based on the current time being `2022-04-24 02:40:00.123` + +| Name | Description | Example | +|---------------|------------------------------------|------------------------| +| @now | Formats as `yyyy-MM-dd HH:mm:ss` | 2022-04-24 02:40:00 | +| @date | Formats as `yyyy-MM-dd` | 2022-04-24 | +| @timestamp10 | Returns 10-digit timestamp | 1650768000 | +| @timestamp | Returns 13-digit timestamp | 1650768000000 | +| @time | Formats as `HH:mm:ss` | 02:40:00 | +| @year | Formats as `yyyy` | 2022 | +| @month | Formats as `MM` | 04 | +| @day | Formats as `dd` | 24 | +| @hour | Formats as `HH` | 02 | +| @minute | Formats as `mm` | 40 | +| @millisecond | Formats as `SSS` | 123 | +| @second | Formats as `ss` | 00 | + +### Supported Time Units + +| Name | Description | +|------|-------------| +| y | Year | +| M | Month | +| d | Day | +| H | Hour | +| m | Minute | +| s | Second | +| w | Week | + +#### Where to Use + +- Request parameters for HTTP protocol monitoring types + +#### Usage Examples + +1. Simple expression + - `${now}` gets the current time and formats it as `yyyy-MM-dd HH:mm:ss` + - `${time+1h}` calculates the time one hour from now and formats it as `HH:mm:ss` + - `${time+1h+15s+30s}` calculates the time one hour, 15 minutes, and 30 seconds from now and formats it as `HH:mm:ss` +2. Complex expression template (if the built-in formatter does not meet your needs, you can combine multiple expressions) + - `${@year}年${@month}月${@day}日` returns the current date formatted as yyyy年MM月dd日 diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/advanced/extend-http.md b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/advanced/extend-http.md index c4175928195..c5c6763bc48 100644 --- a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/advanced/extend-http.md +++ b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/advanced/extend-http.md @@ -194,6 +194,7 @@ metrics: method: GET headers: apiVersion: v1 + # 查询参数,支持使用时间表达式 params: param1: param1 param2: param2 diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/api.md b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/api.md index 0714499be71..6a39ef5977b 100644 --- a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/api.md +++ b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/api.md @@ -19,6 +19,8 @@ keywords: [开源监控系统, 开源网站监控, HTTP API监控] | 启用HTTPS | 是否通过HTTPS访问网站,注意⚠️开启HTTPS一般默认对应端口需要改为443 | | 用户名 | 接口Basic认证或Digest认证时使用的用户名 | | 密码 | 接口Basic认证或Digest认证时使用的密码 | +| 请求Headers | HTTP 请求头 | +| 查询Params | HTTP查询参数,支持[时间表达式](time_expression) | | Content-Type | 设置携带BODY请求体数据请求时的资源类型 | | 请求BODY | 设置携带BODY请求体数据,PUT POST请求方式时有效 | | 采集间隔 | 监控周期性采集数据间隔时间,单位秒,可设置的最小间隔为30秒 | diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/time_expression.md b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/time_expression.md new file mode 100644 index 00000000000..f03ebfab25e --- /dev/null +++ b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/time_expression.md @@ -0,0 +1,66 @@ +--- +id: time_expression +title: 时间表达式 +sidebar_label: 时间表达式 +keywords: [ 动态时间,时间表达式 ] +--- + +### 简介 + +HertzBeat支持使用表达式计算监控采集时的相对时间,支持更加灵活的在监控模板中定义时间。 + +### 语法 + +``` +${FORMATTER [{ + | - } ]} +``` + +- `FORMATTER` : 决定表达式计算的结果的格式 +- `DURATION` : 时间段大小,正整数 +- `TIME_UNIT` : 时间段单位 + +### 支持的格式化类型 + +> 示例输出以当前时间为 `2022-04-24 02:40:00.123` + +| 名称 | 描述 | 示例 | +|--------------|----------------------------|---------------------| +| @now | 格式化为 `yyyy-MM-dd HH:mm:ss` | 2022-04-24 02:40:00 | +| @date | 格式化为 `yyyy-MM-dd` | 2022-04-24 | +| @timestamp10 | 返回10位时间戳 | 1650768000 | +| @timestamp | 返回13位时间戳 | 1650768000000 | +| @time | 格式化为 `HH:mm:ss` | 02:40:00 | +| @year | 格式化为 `yyyy` | 2022 | +| @month | 格式化为 `MM` | 04 | +| @day | 格式化为 `dd` | 24 | +| @hour | 格式化为 `HH` | 02 | +| @minute | 格式化为 `mm` | 40 | +| @millisecond | 格式化为 `SSS` | 123 | +| @second | 格式化为 `ss` | 00 | + +### 支持的时间单位 + +| 名称 | 描述 | +|----|----| +| y | 年 | +| M | 月 | +| d | 日 | +| H | 小时 | +| m | 分钟 | +| s | 秒 | +| w | 周 | + +#### 在哪里可以使用 + +- HTTP协议监控类型的请求参数 + +#### 使用示例 + +1. 简单表达式 + - `${now}` 获取当前时间,并格式化为 `yyyy-MM-dd HH:mm:ss` + - `${time+1h}` 计算当前时间一小时之后的时间,并格式化为 `HH:mm:ss` + - `${time+1h+15s+30s}` 计算当前时间一小时15分钟30秒之后的时间,并格式化为 `HH:mm:ss` +2. 复杂表达式模板(如果内置的格式化器无法满足需要,可以组合使用多个表达式) + - `${@year}年${@month}月${@day}日`,获取当前日期并按照 yyyy年MM月dd日格式返回 + + diff --git a/home/sidebars.json b/home/sidebars.json index bc7655c4d50..02966b270da 100755 --- a/home/sidebars.json +++ b/home/sidebars.json @@ -310,7 +310,8 @@ ] }, "help/issue", - "help/plugin" + "help/plugin", + "help/time_expression" ] }, { From 7c9b3988fbd7edcfc91ccc7af9cabdfe6b85cc53 Mon Sep 17 00:00:00 2001 From: Jast <745925668@qq.com> Date: Mon, 20 May 2024 12:06:01 +0800 Subject: [PATCH 7/7] [feature] add Apache Pulsar monitor (#2013) Co-authored-by: zhangshenghang Co-authored-by: tomsun28 --- home/docs/help/pulsar.md | 76 +++++ .../current/help/pulsar.md | 152 +++++++++ home/sidebars.json | 3 +- .../src/main/resources/define/app-pulsar.yml | 295 ++++++++++++++++++ 4 files changed, 525 insertions(+), 1 deletion(-) create mode 100644 home/docs/help/pulsar.md create mode 100644 home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/pulsar.md create mode 100644 manager/src/main/resources/define/app-pulsar.yml diff --git a/home/docs/help/pulsar.md b/home/docs/help/pulsar.md new file mode 100644 index 00000000000..2cc520d6189 --- /dev/null +++ b/home/docs/help/pulsar.md @@ -0,0 +1,76 @@ +--- +id: pulsar +title: Monitoring Pulsar Monitoring +sidebar_label: Apache Pulsar +keywords: [open-source monitoring system, open-source database monitoring, HbaseMaster monitoring] +--- +> Collecting and monitoring general performance metrics of Pulsar + +**Protocol Used: HTTP** + +## Configuration Parameters + + +| Parameter Name | Description | +| ------------------- | ---------------------------------------------------------------------------------------------------------------------------- | +| Target Host | The monitored endpoint's IPV4, IPV6, or domain name. Note⚠️: Do not include the protocol header (e.g., https://, http://). | +| Port | The webServicePort value of Pulsar, default is 8080. | +| Task Name | The name identifying this monitoring task, must be unique. | +| Query Timeout | Set the connection timeout in milliseconds, default is 3000 milliseconds. | +| Monitoring Interval | Interval time for periodic data collection, in seconds, minimum interval is 30 seconds. | +| Binding Tags | Used for categorizing monitoring resources. | +| Description/Remarks | Additional notes and descriptions for this monitoring task. Users can add more information here. | + +### Collected Metrics + +#### Metric Set: Version Information + + +| Metric Name | Unit | Description | +| ------------ | ---- | ------------------- | +| Version Info | NONE | Version Information | + +#### Metric Set: process_start_time_seconds + + +| Metric Name | Unit | Description | +| ------------------ | ---- | ------------------ | +| Process Start Time | NONE | Process Start Time | + +#### Metric Set: process_open_fds + + +| Metric Name | Unit | Description | +| --------------------- | ---- | ------------------------------- | +| Open File Descriptors | NONE | Number of Open File Descriptors | + +#### Metric Set: process_max_fds + + +| Metric Name | Unit | Description | +| -------------------- | ---- | ---------------------------------- | +| Max File Descriptors | NONE | Maximum Number of File Descriptors | + +#### Metric Set: jvm_memory_pool_allocated_bytes + +Number of bytes of memory allocated in a specific memory pool in the Java Virtual Machine (JVM). In Pulsar, this typically refers to the amount of memory allocated for various purposes in the JVM (such as heap memory, non-heap memory, etc.). + +#### Metric Set: jvm_memory_pool_used_bytes + +Unlike allocated_bytes, this metric shows the actual used memory, not just the allocated memory. + +#### Metric Set: jvm_memory_pool_committed_bytes + +Number of bytes of memory committed in a specific memory pool in the JVM. In the JVM, committed memory is the amount of memory guaranteed to be available for the application to use. This portion of memory is typically locked by the operating system to reduce swapping or garbage collection. + +#### Metric Set: jvm_memory_pool_max_bytes + +Maximum number of bytes of memory that can be allocated in a specific memory pool in the JVM. This is the upper limit on memory usage for that memory pool and helps in setting the memory usage cap. + +#### Metric Set: pulsar_broker_publish_latency + +Message publishing latency on the broker side. + +#### Metric Set: pulsar_metadata_store_ops_latency_ms + +Latency of metadata store operations on the broker side. diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/pulsar.md b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/pulsar.md new file mode 100644 index 00000000000..be83c9ff5f7 --- /dev/null +++ b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/pulsar.md @@ -0,0 +1,152 @@ +--- +id: pulsar +title: 监控:Pulsar监控 +sidebar_label: A--- +id: pulsar +title: 监控:Pulsar监控 +sidebar_label: Apache Pulsar +keywords: [开源监控系统, 开源数据库监控, HbaseMaster监控] +--- +> 对Pulsar的通用性能指标进行采集监控 + +**使用协议:HTTP** + +## 配置参数 + + +| 参数名称 | 参数帮助描述 | +| ------------ | ------------------------------------------------------------------------- | +| 目标Host | 被监控的对端IPV4,IPV6或域名。注意⚠️不带协议头(eg: https://, http://)。 | +| 端口 | Pulsar的webServiceProt值,默认为8080。 | +| 任务名称 | 标识此监控的名称,名称需要保证唯一性。 | +| 查询超时时间 | 设置连接的超时时间,单位ms毫秒,默认3000毫秒。 | +| 监控周期 | 监控周期性采集数据间隔时间,单位秒,可设置的最小间隔为30秒 | +| 绑定标签 | 用于对监控资源进行分类管理 | +| 描述备注 | 更多标识和描述此监控的备注信息,用户可以在这里备注信息 | + +### 采集指标 + +#### 指标集合:版本信息 + + +| 指标名称 | 指标单位 | 指标帮助描述 | +| ------------ | -------- | ------------ | +| Version Info | 无 | 版本信息 | + +#### 指标集合:process_start_time_seconds + + +| 指标名称 | 指标单位 | 指标帮助描述 | +| ------------------ | -------- | ------------ | +| Process Start Time | 无 | 进程启动时间 | + +#### 指标集合:process_open_fds + + +| 指标名称 | 指标单位 | 指标帮助描述 | +| --------------------- | -------- | ---------------- | +| Open File Descriptors | 无 | 打开的文件描述符 | + +#### 指标集合:process_max_fds + + +| 指标名称 | 指标单位 | 指标帮助描述 | +| -------------------- | -------- | -------------- | +| Max File Descriptors | 无 | 最大文件描述符 | + +#### 指标集合: jvm_memory_pool_allocated_bytes + +Java虚拟机(JVM)中特定内存池已分配的内存字节数。在Pulsar中,这通常指的是用于各种目的的JVM内存(如堆内存、非堆内存等)中已经分配出去的内存量。 + +#### 指标集合:jvm_memory_pool_used_bytes + +与allocated_bytes不同,这个指标会显示实际使用的内存,而不仅仅是分配的内存。 + +#### 指标集合:jvm_memory_pool_committed_bytes + +JVM中特定内存池已承诺的内存字节数。在JVM中,承诺的内存是指虚拟机保证可供应用程序使用的内存量,通常这部分内存会被操作系统锁定,以减少交换或垃圾回收的可能性。 + +#### 指标集合:jvm_memory_pool_max_bytes + +JVM中特定内存池可分配的最大内存字节数。这是该内存池允许的最大内存限制,有助于设置内存使用的上限。 + +#### 指标集合:pulsar_broker_publish_latency + +Broker端消息发布延迟 + +#### 指标集合:pulsar_metadata_store_ops_latency_ms + +Broker端元数据存储操作延迟 +pache Pulsar +keywords: [开源监控系统, 开源数据库监控, HbaseMaster监控] +--- +> 对Pulsar的通用性能指标进行采集监控 + +**使用协议:HTTP** + +## 配置参数 + + +| 参数名称 | 参数帮助描述 | +| ------------ | ------------------------------------------------------------------------- | +| 目标Host | 被监控的对端IPV4,IPV6或域名。注意⚠️不带协议头(eg: https://, http://)。 | +| 端口 | Pulsar的webServiceProt值,默认为8080。 | +| 任务名称 | 标识此监控的名称,名称需要保证唯一性。 | +| 查询超时时间 | 设置连接的超时时间,单位ms毫秒,默认3000毫秒。 | +| 监控周期 | 监控周期性采集数据间隔时间,单位秒,可设置的最小间隔为30秒 | +| 绑定标签 | 用于对监控资源进行分类管理 | +| 描述备注 | 更多标识和描述此监控的备注信息,用户可以在这里备注信息 | + +### 采集指标 + +#### 指标集合:版本信息 + + +| 指标名称 | 指标单位 | 指标帮助描述 | +| ------------ | -------- | ------------ | +| Version Info | 无 | 版本信息 | + +#### 指标集合:process_start_time_seconds + + +| 指标名称 | 指标单位 | 指标帮助描述 | +| ------------------ | -------- | ------------ | +| Process Start Time | 无 | 进程启动时间 | + +#### 指标集合:process_open_fds + + +| 指标名称 | 指标单位 | 指标帮助描述 | +| --------------------- | -------- | ---------------- | +| Open File Descriptors | 无 | 打开的文件描述符 | + +#### 指标集合:process_max_fds + + +| 指标名称 | 指标单位 | 指标帮助描述 | +| -------------------- | -------- | -------------- | +| Max File Descriptors | 无 | 最大文件描述符 | + +#### 指标集合: jvm_memory_pool_allocated_bytes + +Java虚拟机(JVM)中特定内存池已分配的内存字节数。在Pulsar中,这通常指的是用于各种目的的JVM内存(如堆内存、非堆内存等)中已经分配出去的内存量。 + +#### 指标集合:jvm_memory_pool_used_bytes + +与allocated_bytes不同,这个指标会显示实际使用的内存,而不仅仅是分配的内存。 + +#### 指标集合:jvm_memory_pool_committed_bytes + +JVM中特定内存池已承诺的内存字节数。在JVM中,承诺的内存是指虚拟机保证可供应用程序使用的内存量,通常这部分内存会被操作系统锁定,以减少交换或垃圾回收的可能性。 + +#### 指标集合:jvm_memory_pool_max_bytes + +JVM中特定内存池可分配的最大内存字节数。这是该内存池允许的最大内存限制,有助于设置内存使用的上限。 + +#### 指标集合:pulsar_broker_publish_latency + +Broker端消息发布延迟 + +#### 指标集合:pulsar_metadata_store_ops_latency_ms + +Broker端元数据存储操作延迟 diff --git a/home/sidebars.json b/home/sidebars.json index 02966b270da..10d0c4e8465 100755 --- a/home/sidebars.json +++ b/home/sidebars.json @@ -220,7 +220,8 @@ "help/rocketmq", "help/spring_gateway", "help/nacos", - "help/kafka" + "help/kafka", + "help/pulsar" ] }, { diff --git a/manager/src/main/resources/define/app-pulsar.yml b/manager/src/main/resources/define/app-pulsar.yml new file mode 100644 index 00000000000..80f8ae945bb --- /dev/null +++ b/manager/src/main/resources/define/app-pulsar.yml @@ -0,0 +1,295 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The monitoring type category: service-application service monitoring, db-database monitoring, custom-custom monitoring. +category: mid +# The monitoring application type name (consistent with the file name) +app: pulsar +name: + zh-CN: Pulsar + en-US: Pulsar +# The description and help of this monitoring type +help: + zh-CN: Hertzbeat 从 Pulsar WebService接口查询到 Pulsar 的通用指标数据来进行监控。
您可以点击 “新建 Pulsar” 并进行配置,或者选择“更多操作”,导入已有配置。 + en-US: Hertzbeat queries general metric data from Pulsar through the Pulsar WebService interface for monitoring. You can click "Create Pulsar" to configure a new monitoring task, or select "More Actions" to import existing configurations. + zh-TW: Hertzbeat 從 Pulsar WebService接口查詢到 Pulsar 的通用指標數據來進行監控。
您可以點擊 “新建 Pulsar” 並進行配置,或者選擇“更多操作”,導入已有配置。 +helpLink: + zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/pulsar + en-US: https://hertzbeat.apache.org/docs/help/pulsar +# 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 + # type-param field type(most mapping the html input type) + type: host + # required-true or false + required: true + - field: port + name: + zh-CN: 端口 + en-US: Port + # type-param field type(most mapping the html input type) + type: number + # when type is number, range is required + range: '[0,65535]' + # default value + defaultValue: 8030 + required: true + - field: timeout + name: + zh-CN: 查询超时时间 + en-US: Query Timeout + type: number + required: false + # hide param-true or false + hide: true + defaultValue: 6000 +metrics: + - name: pulsar_version_info + i18n: + zh-CN: 版本信息 + en-US: Version Info + priority: 0 + fields: + - field: version + i18n: + zh-CN: 版本信息 + en-US: Version Info + type: 1 + label: false + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: process_start_time_seconds + priority: 0 + fields: + - field: value + i18n: + zh-CN: 进程启动时间 + en-US: Process Start Time + type: 0 + label: false + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: process_open_fds + priority: 0 + fields: + - field: value + type: 0 + i18n: + zh-CN: 打开的文件描述符 + en-US: Open File Descriptors + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: process_max_fds + priority: 0 + fields: + - field: value + type: 0 + i18n: + zh-CN: 最大文件描述符 + en-US: Max File Descriptors + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: jvm_memory_pool_allocated_bytes + priority: 0 + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + fields: + - field: .name + type: 1 + i18n: + zh-CN: 指标名称 + en-US: Metric Name + - field: pool + type: 1 + - field: value + type: 0 + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: jvm_memory_pool_bytes_used + priority: 0 + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + fields: + - field: pool + type: 1 + - field: value + type: 0 + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: jvm_memory_pool_bytes_committed + priority: 0 + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + fields: + - field: pool + type: 1 + - field: value + type: 0 + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: jvm_memory_pool_bytes_max + priority: 0 + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + fields: + - field: pool + type: 1 + - field: value + type: 0 + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: pulsar_broker_publish_latency + priority: 0 + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + fields: + - field: .name + type: 1 + i18n: + zh-CN: 指标名称 + en-US: Metric Name + - field: cluster + type: 1 + - field: quantile + type: 1 + - field: value + type: 0 + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus + - name: pulsar_metadata_store_ops_latency_ms + priority: 0 + # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk + protocol: http + fields: + - field: .name + type: 1 + i18n: + zh-CN: 指标名称 + en-US: Metric Name + - field: cluster + type: 1 + - field: name + type: 1 + - field: type + type: 1 + - field: status + type: 1 + - field: le + type: 0 + # the config content when protocol is http + http: + # http host: ipv4 ipv6 domain + host: ^_^host^_^ + # port + port: ^_^port^_^ + # url request interface path + url: '/metrics' + timeout: ^_^timeout^_^ + method: GET + parseType: prometheus \ No newline at end of file