fix: sql query with elasticsearch version 6.x (#158)

* fix: sql query with version 6.x

* docs: update release notes

* docs: typo release notes

---------

Co-authored-by: hardy <luohf@infinilabs.com>
This commit is contained in:
Hardy 2025-02-21 15:06:10 +08:00 committed by GitHub
parent 1e2f8c2520
commit ca52a5b00d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View File

@ -18,8 +18,9 @@ Information about release notes of INFINI Console is provided here.
### Bug fix
- Fixed the error when querying empty metric data (#144)
- Fixed empty host when setup step finishes (#147)
- Fixed the error of obtaining suggestions of field's value in discover
- Fixed the wrong display of heatmap's data in alerting message
- Fixed the error of obtaining suggestions of field's value in discover (#151)
- Fixed the wrong display of heatmap's data in alerting message (#157)
- Fixed Devtools `_sql` support for elasticsearch 6.x (#158)
### Improvements
- Update agent config with cluster name (#148)

View File

@ -18,8 +18,9 @@ title: "版本历史"
### Bug fix
- 修复指标数据为空时的查询错误 (#144)
- 修复初始化结束步骤中主机显示为错误的问题 (#147)
- 修复数据探索中获取字段值建议的错误
- 修复告警消息热图数据显示错误的问题
- 修复数据探索中获取字段值建议的错误 (#151)
- 修复告警消息热图数据显示错误的问题 (#157)
- 修复开发工具 `_sql` 查询支撑 Elasticsearch 6.x 版本 (#158)
### Improvements
- 优化下发给 Agent 的配置,增加集群名称 (#148)

View File

@ -80,6 +80,7 @@ func (h *APIHandler) HandleProxyAction(w http.ResponseWriter, req *http.Request,
}
if strings.Trim(newURL.Path, "/") == "_sql" {
distribution := esClient.GetVersion().Distribution
version := esClient.GetVersion().Number
indexName, err := rewriteTableNamesOfSqlRequest(req, distribution)
if err != nil {
h.WriteError(w, err.Error(), http.StatusInternalServerError)
@ -92,6 +93,15 @@ func (h *APIHandler) HandleProxyAction(w http.ResponseWriter, req *http.Request,
q, _ := url.ParseQuery(newURL.RawQuery)
hasFormat := q.Has("format")
switch distribution {
case elastic.Elasticsearch:
if !hasFormat {
q.Add("format", "txt")
}
if large, _ := util.VersionCompare(version, "7.0.0"); large > 0 {
path = "_sql?" + q.Encode()
} else {
path = "_xpack/_sql?" + q.Encode()
}
case elastic.Opensearch:
path = "_plugins/_sql?format=raw"
case elastic.Easysearch: