Skip to content

Conversation

KomachiSion
Copy link
Collaborator

@KomachiSion KomachiSion commented May 19, 2025

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

Fix #13321

Brief changelog

XX

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

Copy link

Thanks for your this PR. 🙏
Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration.
If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io


感谢您提交的PR。 🙏
请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。
如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

@KomachiSion KomachiSion changed the title Fix prometheus metrics api can't accept. [ISSUE#13321] Fix prometheus metrics api can't accept. May 19, 2025
@KomachiSion KomachiSion added this to the 3.0.1 milestone May 19, 2025
@KomachiSion KomachiSion added the kind/bug Category issues or prs related to bug. label May 19, 2025
Copy link

lingma-agents bot commented May 19, 2025

新增Spring Boot Actuator依赖并调整指标导出配置

变更文件

文件路径 变更说明
bootstrap/​src/​main/​resources/​application.properties 将metrics.export配置迁移到新命名空间,新增management.elastic.metrics.export.enabled和management.influx.metrics.export.enabled配置项,同时禁用旧版配置项
core/pom.xml 引入spring-boot-starter-actuator依赖以支持健康检查和指标端点功能
config/pom.xml 移除对snakeyaml的排除限制,确保SnakeYAML库与Actuator组件兼容

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @Lingma-Agent 分析这个方法的性能瓶颈并提供优化建议。

  • @Lingma-Agent 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @Lingma-Agent 请总结上述讨论并提出解决方案。

  • @Lingma-Agent 请根据讨论内容生成优化代码。

Copy link

@lingma-agents lingma-agents bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 代码评审报告

🎯 评审意见概览

严重度 数量 说明
🔴 Blocker 1 阻断性问题,需立即修复。例如:系统崩溃、关键功能不可用或严重安全漏洞。
🟠 Critical 0 严重问题,高优先级修复。例如:核心功能异常或性能瓶颈影响用户体验。
🟡 Major 0 主要问题,建议修复。例如:非核心功能缺陷或代码维护性较差。
🟢 Minor 0 次要问题,酌情优化。例如:代码格式不规范或注释缺失。

总计: 1 个问题

⚠️ **需要立即关注的阻断性问题**

bootstrap/src/main/resources/application.properties


📋 评审意见详情

💡 单文件建议

以下是文件级别的代码建议,聚焦于代码的可读性、可维护性和潜在问题。
📄 bootstrap/src/main/resources/application.properties (1 💬)

🚀 跨文件建议

以下是对代码架构和设计的综合分析,聚焦于跨文件交互、系统一致性和潜在优化空间。
🔍 1. 配置项命名格式不一致导致监控功能失效风险

在application.properties文件中,新增的Elastic和InfluxDB监控配置项名称格式与Spring Boot规范不符。Spring Boot官方配置规范要求指标导出配置应为management.metrics.export.{store}.enabled,但PR中改为management.elastic.metrics.export.enabled和management.influx.metrics.export.enabled。这种命名格式偏差会导致配置无法被正确识别,进而导致监控导出功能失效。该问题需要与系统监控模块的设计规范保持一致,否则会影响Prometheus指标的正常收集。

📌 关键代码:

+management.elastic.metrics.export.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200
...
+management.influx.metrics.export.enabled=false

⚠️ 潜在风险: 监控配置失效将导致系统指标无法正常收集,运维团队无法获取关键性能数据,影响故障排查和系统优化

🔍 2. 依赖管理分散导致Actuator组件引用不一致

在pom.xml文件中存在依赖管理矛盾:config模块移除了spring-boot-starter-actuator依赖并排除了snakeyaml,而core模块又重新引入了actuator依赖。这种分散的依赖管理方式可能导致不同模块间依赖版本冲突,特别是在多模块项目中可能引发类路径污染。Actuator是Prometheus指标端点的必要组件,其依赖应统一管理而非分散在不同模块中。

📌 关键代码:

-<!--            <dependency>-->
-<!--                <groupId>org.springframework.boot</groupId>-->
-<!--                <artifactId>spring-boot-starter-actuator</artifactId>-->
...
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>

⚠️ 潜在风险: 可能导致Actuator功能失效或依赖版本冲突,引发指标端点不可用或运行时ClassNotFoundException

🔍 3. 监控配置与依赖引入的逻辑矛盾

application.properties中同时禁用Elastic/InfluxDB导出(设置了enabled=false),但在pom.xml中却引入了对应监控依赖。这种配置与依赖的矛盾可能导致资源浪费(加载无用依赖)和潜在配置冲突。应确保监控配置的启用状态与相关依赖引入保持逻辑一致。

📌 关键代码:

+management.elastic.metrics.export.enabled=false
+management.influx.metrics.export.enabled=false

⚠️ 潜在风险: 可能导致不必要的依赖加载,增加JVM内存占用和启动时间,同时存在配置冲突风险


💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @Lingma-Agent 分析这个方法的性能瓶颈并提供优化建议。

  • @Lingma-Agent 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @Lingma-Agent 请总结上述讨论并提出解决方案。

  • @Lingma-Agent 请根据讨论内容生成优化代码。

Comment on lines +46 to +50
management.elastic.metrics.export.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200

### Metrics for influx
management.metrics.export.influx.enabled=false
management.influx.metrics.export.enabled=false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

配置项名称格式错误可能导致监控导出功能失效

🔴 Blocker | 🐞 Bugs

📋 问题详情

新增配置项management.elastic.metrics.export.enabledmanagement.influx.metrics.export.enabled的命名不符合Spring Boot标准配置格式。Spring Boot标准配置项应为management.metrics.export.elastic.enabledmanagement.metrics.export.influx.enabled。错误的配置项名称会导致Elasticsearch和InfluxDB的指标导出配置无法生效,直接导致监控数据无法正常收集,属于严重功能缺陷。

💡 解决方案

需要将配置项名称调整为Spring Boot标准格式:

-management.elastic.metrics.export.enabled=false
+management.metrics.export.elastic.enabled=false
-management.influx.metrics.export.enabled=false
+management.metrics.export.influx.enabled=false

您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

有用意见👍无用意见👎错误意见❌

@wuyfee
Copy link

wuyfee commented May 19, 2025

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@wuyfee
Copy link

wuyfee commented May 19, 2025

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@wuyfee
Copy link

wuyfee commented May 19, 2025

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@wuyfee
Copy link

wuyfee commented May 19, 2025

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.40%. Comparing base (d15272c) to head (9dd7ca0).
Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             develop   #13388      +/-   ##
=============================================
+ Coverage      70.33%   70.40%   +0.06%     
- Complexity     11713    11715       +2     
=============================================
  Files           1592     1592              
  Lines          50984    50977       -7     
  Branches        5149     5148       -1     
=============================================
+ Hits           35862    35890      +28     
+ Misses         12693    12655      -38     
- Partials        2429     2432       +3     

see 38 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update acb967b...9dd7ca0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KomachiSion KomachiSion merged commit 29f9562 into alibaba:develop May 19, 2025
2 checks passed
@wuyfee
Copy link

wuyfee commented May 19, 2025

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@KomachiSion KomachiSion deleted the develop-#13321- branch May 21, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nacos 3.0.0 无法获取prometheus的metrics数据
3 participants