From 8d2ce2b1a42cc979f19dd51a6a84f7d35fb8aa37 Mon Sep 17 00:00:00 2001 From: sadadw1 Date: Wed, 29 May 2024 17:20:57 +0800 Subject: [PATCH 1/5] fix: delete unused annotation --- .../mone/monitor/service/model/prometheus/MetricDetailQuery.java | 1 - 1 file changed, 1 deletion(-) diff --git a/ozhera-monitor/ozhera-monitor-service/src/main/java/com/xiaomi/mone/monitor/service/model/prometheus/MetricDetailQuery.java b/ozhera-monitor/ozhera-monitor-service/src/main/java/com/xiaomi/mone/monitor/service/model/prometheus/MetricDetailQuery.java index 7a5d57316..5733c723a 100644 --- a/ozhera-monitor/ozhera-monitor-service/src/main/java/com/xiaomi/mone/monitor/service/model/prometheus/MetricDetailQuery.java +++ b/ozhera-monitor/ozhera-monitor-service/src/main/java/com/xiaomi/mone/monitor/service/model/prometheus/MetricDetailQuery.java @@ -229,7 +229,6 @@ public String convertDorisSqlCount(){ } /** - * //TODO 添加子类别(区分慢查询/异常 等待丁涛)、sql(对应url),errorCode,耗时-duration * @return */ public Map convertEsParam(String exceptionTraceDomain){ From 071822462d2c4746b08b83cc2366afc76e095c53 Mon Sep 17 00:00:00 2001 From: dingtao Date: Mon, 10 Jun 2024 19:53:43 +0800 Subject: [PATCH 2/5] fix: upgrade app-api and app-common version to 3 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4b8e888e1..e75e3a344 100644 --- a/pom.xml +++ b/pom.xml @@ -525,12 +525,12 @@ run.mone app-api - 1.4-jdk21-2 + 1.4-jdk21-3 run.mone app-common - 1.4-jdk21-1 + 1.4-jdk21-3 run.mone From 9821721f0d99318ea658f0ffc5aac74e2a9d2a08 Mon Sep 17 00:00:00 2001 From: sadadw1 Date: Thu, 20 Jun 2024 15:25:20 +0800 Subject: [PATCH 3/5] feat: add ozhera-intelligence module --- ozhera-intelligence/README.md | 5 ++++ ozhera-intelligence/README_cn.md | 8 +++++ .../ozhera-intelligence-server/pom.xml | 23 +++++++++++++++ .../bootstrap/IntelligenceBootStrap.java | 19 ++++++++++++ ozhera-intelligence/pom.xml | 29 +++++++++++++++++++ pom.xml | 1 + 6 files changed, 85 insertions(+) create mode 100644 ozhera-intelligence/README.md create mode 100644 ozhera-intelligence/README_cn.md create mode 100644 ozhera-intelligence/ozhera-intelligence-server/pom.xml create mode 100644 ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/bootstrap/IntelligenceBootStrap.java create mode 100644 ozhera-intelligence/pom.xml diff --git a/ozhera-intelligence/README.md b/ozhera-intelligence/README.md new file mode 100644 index 000000000..a6227d1f0 --- /dev/null +++ b/ozhera-intelligence/README.md @@ -0,0 +1,5 @@ +# Overview ++ A system for data extraction, loading, and transformation. ++ Currently, trace-etl mainly consists of four modules: trace-etl-server, trace-etl-es, trace-etl-manager, and trace-etl-nginx. + +# Module Introduction diff --git a/ozhera-intelligence/README_cn.md b/ozhera-intelligence/README_cn.md new file mode 100644 index 000000000..1c27be461 --- /dev/null +++ b/ozhera-intelligence/README_cn.md @@ -0,0 +1,8 @@ +# 概述 ++ ozhera智能化平台,负责产生智能化相关功能。 + +# 模块功能介绍 + +## ozhera-intelligence-server + ++ 智能化功能启动服务。 diff --git a/ozhera-intelligence/ozhera-intelligence-server/pom.xml b/ozhera-intelligence/ozhera-intelligence-server/pom.xml new file mode 100644 index 000000000..c1ad4a5e6 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-server/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + run.mone + ozhera-intelligence + 1.4.0-jdk21-SNAPSHOT + + + ozhera-intelligence-server + + + 21 + 21 + UTF-8 + + + + + + \ No newline at end of file diff --git a/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/bootstrap/IntelligenceBootStrap.java b/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/bootstrap/IntelligenceBootStrap.java new file mode 100644 index 000000000..3d47a17df --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/bootstrap/IntelligenceBootStrap.java @@ -0,0 +1,19 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.bootstrap; + +public class IntelligenceBootStrap { +} diff --git a/ozhera-intelligence/pom.xml b/ozhera-intelligence/pom.xml new file mode 100644 index 000000000..b9bef4e6d --- /dev/null +++ b/ozhera-intelligence/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + run.mone + ozhera + 1.4.0-jdk21-SNAPSHOT + + + ozhera-intelligence + 1.0.0 + pom + + + ozhera-intelligence-server + + + + 21 + 21 + UTF-8 + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 87b86e400..32af8507b 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ ozhera-webhook prometheus-starter-all trace-etl + ozhera-intelligence From 6427c12c091f1de62819129ca0298ea7909d32e3 Mon Sep 17 00:00:00 2001 From: sadadw1 Date: Thu, 20 Jun 2024 20:22:16 +0800 Subject: [PATCH 4/5] feat: add the method definition for trace analysis in the intelligence service --- ozhera-intelligence/README.md | 11 +- ozhera-intelligence/README_cn.md | 4 +- .../ozhera-intelligence-domain/pom.xml | 27 ++++ .../domain/rootanalysis/LogParam.java | 38 ++++++ .../domain/rootanalysis/LogPromptResult.java | 25 ++++ .../domain/rootanalysis/MarkDownParam.java | 40 ++++++ .../rootanalysis/MetricsPromptResult.java | 27 ++++ .../rootanalysis/MetricsQueryParam.java | 38 ++++++ .../rootanalysis/TracePromptResult.java | 49 +++++++ .../domain/rootanalysis/TraceQueryParam.java | 29 ++++ .../ozhera-intelligence-server/pom.xml | 74 +++++++++- .../bootstrap/IntelligenceBootStrap.java | 16 +++ .../controller/RootAnalysisController.java | 39 ++++++ .../src/main/resources/application.properties | 6 + .../config/opensource-outer.properties | 6 + .../src/main/resources/logback.xml | 58 ++++++++ .../ozhera-intelligence-service/pom.xml | 73 ++++++++++ .../hera/intelligence/service/LogService.java | 32 +++++ .../intelligence/service/MetricsService.java | 35 +++++ .../intelligence/service/PromptService.java | 73 ++++++++++ .../service/RootAnalysisConst.java | 23 ++++ .../service/RootAnalysisService.java | 61 +++++++++ .../intelligence/service/TraceService.java | 32 +++++ ozhera-intelligence/pom.xml | 128 +++++++++++++++++- 24 files changed, 937 insertions(+), 7 deletions(-) create mode 100644 ozhera-intelligence/ozhera-intelligence-domain/pom.xml create mode 100644 ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/LogParam.java create mode 100644 ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/LogPromptResult.java create mode 100644 ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MarkDownParam.java create mode 100644 ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MetricsPromptResult.java create mode 100644 ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MetricsQueryParam.java create mode 100644 ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/TracePromptResult.java create mode 100644 ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/TraceQueryParam.java create mode 100644 ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/controller/RootAnalysisController.java create mode 100644 ozhera-intelligence/ozhera-intelligence-server/src/main/resources/application.properties create mode 100644 ozhera-intelligence/ozhera-intelligence-server/src/main/resources/config/opensource-outer.properties create mode 100644 ozhera-intelligence/ozhera-intelligence-server/src/main/resources/logback.xml create mode 100644 ozhera-intelligence/ozhera-intelligence-service/pom.xml create mode 100644 ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/LogService.java create mode 100644 ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/MetricsService.java create mode 100644 ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/PromptService.java create mode 100644 ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/RootAnalysisConst.java create mode 100644 ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/RootAnalysisService.java create mode 100644 ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/TraceService.java diff --git a/ozhera-intelligence/README.md b/ozhera-intelligence/README.md index a6227d1f0..49fd48180 100644 --- a/ozhera-intelligence/README.md +++ b/ozhera-intelligence/README.md @@ -1,5 +1,12 @@ # Overview -+ A system for data extraction, loading, and transformation. -+ Currently, trace-etl mainly consists of four modules: trace-etl-server, trace-etl-es, trace-etl-manager, and trace-etl-nginx. ++ OzHera Intelligence Platform is responsible for generating intelligent-related functionalities. ++ Currently, features are under development. ++ Planned features to be developed: + + Root cause analysis, including trace, alerts, and topology-based intelligent analysis at the application level. # Module Introduction + +## ozhera-intelligence-server + ++ Service to initiate intelligent functionalities. + diff --git a/ozhera-intelligence/README_cn.md b/ozhera-intelligence/README_cn.md index 1c27be461..fe30dfc4f 100644 --- a/ozhera-intelligence/README_cn.md +++ b/ozhera-intelligence/README_cn.md @@ -1,6 +1,8 @@ # 概述 + ozhera智能化平台,负责产生智能化相关功能。 - ++ 目前功能开发中 ++ 计划将要开发的功能 + + 根因分析。包括Trace、报警、应用层面的基于拓扑图的智能分析。 # 模块功能介绍 ## ozhera-intelligence-server diff --git a/ozhera-intelligence/ozhera-intelligence-domain/pom.xml b/ozhera-intelligence/ozhera-intelligence-domain/pom.xml new file mode 100644 index 000000000..3b9bb6a74 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-domain/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + run.mone + ozhera-intelligence + 1.0.0 + + + ozhera-intelligence-domain + + + 21 + 21 + UTF-8 + + + + + org.projectlombok + lombok + provided + + + \ No newline at end of file diff --git a/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/LogParam.java b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/LogParam.java new file mode 100644 index 000000000..d0e72ffd6 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/LogParam.java @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.domain.rootanalysis; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class LogParam { + + private String application; + + private String envId; + + private String traceId; + + private String startTime; + + private String duration; + + private String env; + + private String level; +} diff --git a/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/LogPromptResult.java b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/LogPromptResult.java new file mode 100644 index 000000000..bcba2ecc1 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/LogPromptResult.java @@ -0,0 +1,25 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.domain.rootanalysis; + +import lombok.Data; + +@Data +public class LogPromptResult { + private boolean root; + + private String logReason; +} diff --git a/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MarkDownParam.java b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MarkDownParam.java new file mode 100644 index 000000000..aeb708611 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MarkDownParam.java @@ -0,0 +1,40 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.domain.rootanalysis; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class MarkDownParam { + + private String traceReason; + + private String application; + + private String logReason; + + private String metricsReason; + + private String simpleReason; + + private String traceId; + + private String timestamp; + + private String env; +} diff --git a/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MetricsPromptResult.java b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MetricsPromptResult.java new file mode 100644 index 000000000..004f9f3c1 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MetricsPromptResult.java @@ -0,0 +1,27 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.domain.rootanalysis; + +import lombok.Data; + +@Data +public class MetricsPromptResult { + + private boolean root; + + private String metricsReason; + +} diff --git a/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MetricsQueryParam.java b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MetricsQueryParam.java new file mode 100644 index 000000000..408ddbddc --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/MetricsQueryParam.java @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.domain.rootanalysis; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class MetricsQueryParam { + + private String env; + + private String application; + + private String ip; + + private String startTime; + + private String duration; + + // The error margin between the start time and end time, + // the actual query time range is [startTime - gap, endTime + gap] + private String gap; +} diff --git a/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/TracePromptResult.java b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/TracePromptResult.java new file mode 100644 index 000000000..e41c86425 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/TracePromptResult.java @@ -0,0 +1,49 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.domain.rootanalysis; + +import lombok.Data; + +@Data +public class TracePromptResult { + // Detailed description of the exception reason, using professional Chinese terminology + private String traceReason; + + // Name of the application that caused the exception, + // obtained from process.serviceName of the problem node + private String application; + + // Whether it is the root cause, determined based on analysis + private boolean root; + + // Environment ID of the application, + // obtained from the value of service.env.id in process.tags of the problem node + private String envId; + + // Start time of the root cause Span, + // must use the original value without any conversion + private String startTime; + + // Duration of the root cause node, obtained from the duration of the root cause node, + // must use the original value without any conversion + private String duration; + + // Span ID of what you believe to be the root cause node + private String spanId; + + // Value of process.ip for the node where the spanId is located + private String ip; +} diff --git a/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/TraceQueryParam.java b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/TraceQueryParam.java new file mode 100644 index 000000000..a16800e6d --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-domain/src/main/java/run/mone/hera/intelligence/domain/rootanalysis/TraceQueryParam.java @@ -0,0 +1,29 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.domain.rootanalysis; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +public class TraceQueryParam { + private String traceId; + private String env; + private List timeStamp; +} diff --git a/ozhera-intelligence/ozhera-intelligence-server/pom.xml b/ozhera-intelligence/ozhera-intelligence-server/pom.xml index c1ad4a5e6..6cceaacb4 100644 --- a/ozhera-intelligence/ozhera-intelligence-server/pom.xml +++ b/ozhera-intelligence/ozhera-intelligence-server/pom.xml @@ -6,7 +6,7 @@ run.mone ozhera-intelligence - 1.4.0-jdk21-SNAPSHOT + 1.0.0 ozhera-intelligence-server @@ -18,6 +18,76 @@ - + + run.mone + ozhera-intelligence-service + ${ozhera.intelligence.version} + + + + + + + src/main/resources + true + + + src/main/resources/META-INF + true + + app.properties + + META-INF/ + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 21 + 21 + 21 + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.7.15 + + com.xiaomi.hera.trace.etl.bootstrap.TraceEtlBootstrap + + + + + repackage + + + + + + + + + + + + + opensource-outer + + opensource-outer + + + + src/main/resources/config/opensource-outer.properties + + + + + \ No newline at end of file diff --git a/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/bootstrap/IntelligenceBootStrap.java b/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/bootstrap/IntelligenceBootStrap.java index 3d47a17df..18fbee2bf 100644 --- a/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/bootstrap/IntelligenceBootStrap.java +++ b/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/bootstrap/IntelligenceBootStrap.java @@ -15,5 +15,21 @@ */ package run.mone.hera.intelligence.bootstrap; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; + +@EnableAutoConfiguration +@ComponentScan(basePackages = {"run.mone.hera.intelligence"}) +@Slf4j public class IntelligenceBootStrap { + public static void main(String... args) { + try { + SpringApplication.run(IntelligenceBootStrap.class, args); + } catch (Throwable throwable) { + log.error(throwable.getMessage(), throwable); + System.exit(-1); + } + } } diff --git a/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/controller/RootAnalysisController.java b/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/controller/RootAnalysisController.java new file mode 100644 index 000000000..bcc806b74 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-server/src/main/java/run/mone/hera/intelligence/controller/RootAnalysisController.java @@ -0,0 +1,39 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.controller; + +import com.xiaomi.youpin.infra.rpc.Result; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import run.mone.hera.intelligence.domain.rootanalysis.TraceQueryParam; +import run.mone.hera.intelligence.service.RootAnalysisService; + +@RestController +@RequestMapping("/analysis") +@Slf4j +public class RootAnalysisController { + + @Autowired + private RootAnalysisService rootAnalysisService; + + @GetMapping("/trace") + public Result traceRootAnalysis(TraceQueryParam param) { + return rootAnalysisService.traceRootAnalysis(param); + } +} diff --git a/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/application.properties b/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/application.properties new file mode 100644 index 000000000..8cdaacb7d --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/application.properties @@ -0,0 +1,6 @@ +#server +app.name=${app.name} +server.type=${server.type} +server.port=${server.port} + +log.path=${log.path} \ No newline at end of file diff --git a/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/config/opensource-outer.properties b/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/config/opensource-outer.properties new file mode 100644 index 000000000..75e2a3d9e --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/config/opensource-outer.properties @@ -0,0 +1,6 @@ +#server +app.name=ozhera-intelligence +server.type=staging +server.port=8080 + +log.path=/tmp/work/log \ No newline at end of file diff --git a/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/logback.xml b/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/logback.xml new file mode 100644 index 000000000..d439b157c --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-server/src/main/resources/logback.xml @@ -0,0 +1,58 @@ + + + + + + + + + ${log.path}/intelligence/server.log + + %d|%-5level|%thread|%logger{40}|%L|%msg%n + + + ${log.path}/intelligence/server.log.%d{yyyy-MM-dd-HH} + ${MAX_HISTORY} + + + + + 0 + 60000 + + + + + + ${log.path}/intelligence/error.log + + %d|%-5level|%thread|%logger{40}|%L|%msg%n + + + ${log.path}/intelligence/error.log.%d{yyyy-MM-dd-HH} + ${MAX_HISTORY} + + + ERROR + ACCEPT + DENY + + + + + + %d|%-5level|%thread|%logger{40}|%L|%msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ozhera-intelligence/ozhera-intelligence-service/pom.xml b/ozhera-intelligence/ozhera-intelligence-service/pom.xml new file mode 100644 index 000000000..e5ea71572 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-service/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + run.mone + ozhera-intelligence + 1.0.0 + + + ozhera-intelligence-service + + + 21 + 21 + UTF-8 + + + + + run.mone + ozhera-intelligence-domain + ${ozhera.intelligence.version} + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + + + + org.springframework + spring-beans + + + + org.springframework + spring-core + + + + org.springframework + spring-context + + + + org.springframework + spring-test + + + + + run.mone + trace-etl-domain + + + + run.mone + infra-result + + + + org.projectlombok + lombok + + + \ No newline at end of file diff --git a/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/LogService.java b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/LogService.java new file mode 100644 index 000000000..ffaa058b8 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/LogService.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.service; + +import org.springframework.stereotype.Service; +import run.mone.hera.intelligence.domain.rootanalysis.LogParam; + +@Service +public class LogService { + + /** + * Query logs based on the specified log query conditions. + * @param param + * @return + */ + public String queryLogRootAnalysis(LogParam param){ + return null; + } +} diff --git a/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/MetricsService.java b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/MetricsService.java new file mode 100644 index 000000000..f37b101c6 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/MetricsService.java @@ -0,0 +1,35 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.service; + +import org.springframework.stereotype.Service; +import run.mone.hera.intelligence.domain.rootanalysis.MetricsQueryParam; + +/** + * + */ +@Service +public class MetricsService { + + /** + * Query metrics based on the specified metric query conditions. + * @param param + * @return + */ + public String queryMetricsRootAnalysis(MetricsQueryParam param){ + return null; + } +} diff --git a/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/PromptService.java b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/PromptService.java new file mode 100644 index 000000000..67915e0a5 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/PromptService.java @@ -0,0 +1,73 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.service; + +import org.springframework.stereotype.Service; +import run.mone.hera.intelligence.domain.rootanalysis.LogPromptResult; +import run.mone.hera.intelligence.domain.rootanalysis.MetricsPromptResult; +import run.mone.hera.intelligence.domain.rootanalysis.TracePromptResult; + +@Service +public class PromptService { + + /** + * Conduct large model analysis based on trace data + * + * @param trace + * @return + */ + public TracePromptResult traceAnalysis(String trace) { + // Retrieve the corresponding prompt + // Invoke the large model for analysis + return null; + } + + /** + * Conduct large model analysis based on log data + * + * @param log + * @return + */ + public LogPromptResult logAnalysis(String log) { + // Retrieve the corresponding prompt + // Invoke the large model for analysis + return null; + } + + /** + * Conduct large model analysis based on metrics data + * + * @param metrics + * @return + */ + public MetricsPromptResult metricsAnalysis(String metrics) { + // Retrieve the corresponding prompt + // Invoke the large model for analysis + return null; + } + + /** + * Summarize a clear and concise root cause based on the analysis results from trace, log, and metrics. + * @param traceReason + * @param logReason + * @param metricsReason + * @return + */ + public String getSimpleReason(String traceReason, String logReason, String metricsReason) { + // Invoke the large model for analysis + return null; + } +} diff --git a/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/RootAnalysisConst.java b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/RootAnalysisConst.java new file mode 100644 index 000000000..18d1f2b31 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/RootAnalysisConst.java @@ -0,0 +1,23 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.service; + +public class RootAnalysisConst { + + public static final String LOG_PARAM_LEVEL = "ERROR"; + + public static final int METRICS_PARAM_GAP = 180000; +} diff --git a/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/RootAnalysisService.java b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/RootAnalysisService.java new file mode 100644 index 000000000..921864a0d --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/RootAnalysisService.java @@ -0,0 +1,61 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.service; + +import com.xiaomi.youpin.infra.rpc.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import run.mone.hera.intelligence.domain.rootanalysis.LogParam; +import run.mone.hera.intelligence.domain.rootanalysis.MarkDownParam; +import run.mone.hera.intelligence.domain.rootanalysis.TracePromptResult; +import run.mone.hera.intelligence.domain.rootanalysis.TraceQueryParam; + +@Service +public class RootAnalysisService { + + @Autowired + private TraceService traceService; + + @Autowired + private LogService logService; + + @Autowired + private MetricsService metricsService; + + @Autowired + private PromptService promptService; + + /** + * Root cause analysis based on trace, utilizing a large model to analyze the fundamental causes of trace issues. + * First, analyze based on trace data; if unsuccessful, analyze using logs. + * If the issue still cannot be identified, then analyze using metrics. + * Finally, aggregate the results and output them to the frontend. + * + * @return + */ + public Result traceRootAnalysis(TraceQueryParam param) { + return null; + } + + /** + * Generate the results required by the frontend in markdown format based on the summarized content. + * @param param + * @return + */ + private String generateMarkDownResult(MarkDownParam param){ + return null; + } +} diff --git a/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/TraceService.java b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/TraceService.java new file mode 100644 index 000000000..93a0ff623 --- /dev/null +++ b/ozhera-intelligence/ozhera-intelligence-service/src/main/java/run/mone/hera/intelligence/service/TraceService.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.hera.intelligence.service; + +import org.springframework.stereotype.Service; +import run.mone.hera.intelligence.domain.rootanalysis.TraceQueryParam; + +@Service +public class TraceService { + + /** + * Query trace based on the specified trace query conditions. + * @param param + * @return + */ + public String queryTraceRootAnalysis(TraceQueryParam param){ + return null; + } +} diff --git a/ozhera-intelligence/pom.xml b/ozhera-intelligence/pom.xml index b9bef4e6d..6af7be482 100644 --- a/ozhera-intelligence/pom.xml +++ b/ozhera-intelligence/pom.xml @@ -15,15 +15,139 @@ ozhera-intelligence-server + ozhera-intelligence-service + ozhera-intelligence-domain 21 21 + 5.3.29 + 1.0.1-jdk21 + 1.0.0 UTF-8 + + ~ - + + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-test + ${spring.version} + + + org.springframework + spring-jdbc + ${spring.version} + + + run.mone + trace-etl-domain + ${trace.etl.domain.version} + + + - + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.2.0 + + + copy-license + prepare-package + + copy-resources + + + target/classes/META-INF + + + ${maven.jcommonDirectory} + + LICENSE.txt + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 21 + 21 + 21 + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1 + + true + + + + compile + + jar + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.5.0 + + false + + + + attach-javadocs + + jar + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + deploy + + sign + + + gpg + your-gpg-key + + + + + + \ No newline at end of file From bb529d484576a60aae1f6b125656facf7c654f60 Mon Sep 17 00:00:00 2001 From: sadadw1 Date: Thu, 20 Jun 2024 20:29:53 +0800 Subject: [PATCH 5/5] feat: add ozhera-intelligence github action --- .../workflows/ozhera-intelligence-package.yml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/ozhera-intelligence-package.yml diff --git a/.github/workflows/ozhera-intelligence-package.yml b/.github/workflows/ozhera-intelligence-package.yml new file mode 100644 index 000000000..2a614a423 --- /dev/null +++ b/.github/workflows/ozhera-intelligence-package.yml @@ -0,0 +1,27 @@ +# This is a basic workflow to help you get started with Actions + +name: ozhera-intelligence test + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + pull_request: + paths: + - 'ozhera-intelligence/**' + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + check-build-21: + name: ozhera-intelligence test + runs-on: ubuntu-latest + steps: + - name: Setup Maven Action + uses: s4u/setup-maven-action@v1.7.0 + with: + java-version: 21 + #settings-properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]' + + - run: echo ' false ossrh ossrh-snapshot https://s01.oss.sonatype.org/content/repositories/snapshots ossrh ossrh-snapshot https://s01.oss.sonatype.org/content/repositories/snapshots artifactory artifactory github ${env.GITHUB_ACTOR} ${env.GITHUB_TOKEN} ' > ~/.m2/settings.xml + + - run: cd ozhera-intelligence; mvn -U clean package