fix(log): ES 7.2.0 time format .SSSZ + index dropdown + demo always visible
- ES query 502 fix: remove +00:00 conversion, use native .SSSZ format (ES 7.2.0 date_time = strict_date_optional_time only, rejects +00:00/epoch) - parseLogTime: use time.RFC3339Nano for fractional seconds - new API GET /log-datasources/indices to list ES indices via proxy - LogDatasourceDialog: add '获取索引' button + Select dropdown for ES - LogDatasourcePage: always show demo sources alongside real ones
This commit is contained in:
1 parent
2e179ef7f4
commit
a04d815efe
7 files changed
+308
-15
No files matched your search
@@ -149,10 +149,7 @@ func (h *LogProxyHandler) QueryES(c *gin.Context) {
|
||||
},
|
||||
}
|
||||
if req.Start != "" || req.End != "" {
|
||||
// ES 7.2 date_time 格式要求 +00:00 而非 Z;兼容 @timestamp 与 timestamp // Logan.Li
|
||||
buildRangeVal := func(v string) string {
|
||||
return strings.Replace(v, "Z", "+00:00", 1)
|
||||
}
|
||||
// ES 7.2 date_time 仅接受 .SSSZ 格式;兼容 @timestamp 与 timestamp // Logan.Li
|
||||
rangeCond := map[string]interface{}{
|
||||
"bool": map[string]interface{}{
|
||||
"should": []interface{}{
|
||||
@@ -167,10 +164,10 @@ func (h *LogProxyHandler) QueryES(c *gin.Context) {
|
||||
for _, v := range rng {
|
||||
r := v.(map[string]string)
|
||||
if req.Start != "" {
|
||||
r["gte"] = buildRangeVal(req.Start)
|
||||
r["gte"] = req.Start
|
||||
}
|
||||
if req.End != "" {
|
||||
r["lte"] = buildRangeVal(req.End)
|
||||
r["lte"] = req.End
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,9 +214,8 @@ func parseLogTime(s string) (time.Time, error) {
|
||||
}
|
||||
return time.Unix(n, 0), nil
|
||||
}
|
||||
// ES 7.2 date_time 不接受 Z,转 +00:00
|
||||
s = strings.Replace(s, "Z", "+00:00", 1)
|
||||
return time.Parse(time.RFC3339, s)
|
||||
// 解析 ISO8601(含 .SSSZ 毫秒后缀,如 2026-06-20T09:33:17.000Z)
|
||||
return time.Parse(time.RFC3339Nano, s)
|
||||
}
|
||||
|
||||
func defaultESQuery(q string) string {
|
||||
|
||||
Reference in new issue
Block a user