Skip to content

Conversation

@myysophia
Copy link
Owner

  • 新增 HTTP API 数据源类型,支持从 RESTful API 获取 JSON 数据
  • 实现 JSON 路径解析功能,支持嵌套路径(如 main.mqttAuthUrl)
  • 添加 HTTP API 客户端(internal/datasource/http.go)
  • 更新配置结构,支持 HTTP API 连接配置
  • 集成到指标采集服务,支持 HTTP API 指标采集
  • 更新前端 UI,支持 HTTP API 数据源配置和管理
  • 添加 HTTP API 连接测试和查询预览功能
  • 更新配置示例文件,添加 HTTP API 使用示例

示例:

- 新增 HTTP API 数据源类型,支持从 RESTful API 获取 JSON 数据
- 实现 JSON 路径解析功能,支持嵌套路径(如 main.mqttAuthUrl)
- 添加 HTTP API 客户端(internal/datasource/http.go)
- 更新配置结构,支持 HTTP API 连接配置
- 集成到指标采集服务,支持 HTTP API 指标采集
- 更新前端 UI,支持 HTTP API 数据源配置和管理
- 添加 HTTP API 连接测试和查询预览功能
- 更新配置示例文件,添加 HTTP API 使用示例

示例:
- 数据源: http_api
- URL: https://control.pingjl.com/mqtt/control/v1/
- JSON 路径: main.mqttAuthUrl
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 281 to 285
if jsonPath == "" {
return 0, fmt.Errorf("HTTP API 指标 %s 缺少 result_field(JSON 路径)", spec.Name)
}
log.Printf("执行 HTTP API 查询(连接=%s,JSON 路径=%s)", conn, jsonPath)
return client.QueryScalar(ctx, jsonPath)

Choose a reason for hiding this comment

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

P1 Badge Honor HTTP metric query URL during collection

In the HTTP branch of Service.queryMetric the code never reads spec.Query before calling client.QueryScalar, so every HTTP metric always hits the connection’s configured URL regardless of what was saved in the metric. The comment here even documents that the query field is supposed to carry an optional per-metric URL, but because it is ignored any metric that tries to override the endpoint will silently read data from the wrong API and expose incorrect values. Please use spec.Query (falling back to the connection URL when it is blank) when building the HTTP request.

Useful? React with 👍 / 👎.

修复 Service.queryMetric 中 HTTP API 分支的 bug:
- 之前代码忽略了 spec.Query 字段,始终使用连接配置的 URL
- 现在优先使用 spec.Query 作为 URL,如果为空则回退到连接配置的 URL
- 更新 QueryScalar 方法签名,支持可选的 URL 参数
- 更新日志输出,明确显示使用的 URL 来源

这确保了指标配置中的 URL 能够正确覆盖连接配置的默认 URL。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants