chore: add version and distribution for agent to avoid painc at start (#131)

* chore: add version and distribution for agent to avoid painc at start

* docs: add release notes

* docs: typo release notes

---------

Co-authored-by: hardy <luohf@infinilabs.com>
This commit is contained in:
Hardy 2025-02-14 11:26:49 +08:00 committed by GitHub
parent ea73bf9510
commit b44382327d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 17 deletions

View File

@ -6,6 +6,8 @@ elasticsearch:
name: $[[TASK_ID]] name: $[[TASK_ID]]
cluster_uuid: $[[CLUSTER_UUID]] cluster_uuid: $[[CLUSTER_UUID]]
enabled: true enabled: true
distribution: $[[CLUSTER_DISTRIBUTION]]
version: $[[CLUSTER_VERSION]]
endpoints: $[[CLUSTER_ENDPOINT]] endpoints: $[[CLUSTER_ENDPOINT]]
discovery: discovery:
enabled: false enabled: false

View File

@ -26,6 +26,7 @@ Information about release notes of INFINI Console is provided here.
- Add credential settings for agent in enrolling agent - Add credential settings for agent in enrolling agent
- Add collection mode to cluster editing - Add collection mode to cluster editing
- Add default roles to fix the issue (#114) (#130) - Add default roles to fix the issue (#114) (#130)
- Add agent connection config with `version` and `distribution` to avoid panic at start(#131)
## 1.28.1 (2025-01-24) ## 1.28.1 (2025-01-24)

View File

@ -24,6 +24,7 @@ title: "版本历史"
- 在集群编辑中新增采集模式 - 在集群编辑中新增采集模式
- 当使用 Easysearch 存储指标时,自动为系统集群创建 Agent 指标写入最小权限用户 (#120) - 当使用 Easysearch 存储指标时,自动为系统集群创建 Agent 指标写入最小权限用户 (#120)
- 修复 LDAP 用户映射增加默认权限组 (#114) (#130) - 修复 LDAP 用户映射增加默认权限组 (#114) (#130)
- Agent 连接 Easysearch 的配置信息中增加 `version``distribution` 来解决启动时退出问题 (#131)
## 1.28.1 (2025-01-24) ## 1.28.1 (2025-01-24)

View File

@ -197,22 +197,30 @@ func getAgentIngestConfigs(instance string, items map[string]BindingItem) (strin
var username = "" var username = ""
var password = "" var password = ""
var version = ""
var distribution = ""
if metadata.Config.AgentCredentialID != "" { if metadata.Config != nil {
credential, err := common2.GetCredential(metadata.Config.AgentCredentialID)
if err != nil { version = metadata.Config.Version
log.Error(err) distribution = metadata.Config.Distribution
continue
} if metadata.Config.AgentCredentialID != "" {
var dv interface{} credential, err := common2.GetCredential(metadata.Config.AgentCredentialID)
dv, err = credential.Decode() if err != nil {
if err != nil { log.Error(err)
log.Error(err) continue
continue }
} var dv interface{}
if auth, ok := dv.(model.BasicAuth); ok { dv, err = credential.Decode()
username = auth.Username if err != nil {
password = auth.Password.Get() log.Error(err)
continue
}
if auth, ok := dv.(model.BasicAuth); ok {
username = auth.Username
password = auth.Password.Get()
}
} }
} }
@ -238,20 +246,21 @@ func getAgentIngestConfigs(instance string, items map[string]BindingItem) (strin
} }
taskID := v.ClusterID + "_" + v.NodeUUID taskID := v.ClusterID + "_" + v.NodeUUID
buffer.Write([]byte(fmt.Sprintf("\n - name: \"%v\"\n path: ./config/task_config.tpl\n "+ buffer.Write([]byte(fmt.Sprintf("\n - name: \"%v\"\n path: ./config/task_config.tpl\n "+
"variable:\n "+ "variable:\n "+
"TASK_ID: %v\n "+ "TASK_ID: %v\n "+
"CLUSTER_ID: %v\n "+ "CLUSTER_ID: %v\n "+
"CLUSTER_UUID: %v\n "+ "CLUSTER_UUID: %v\n "+
"NODE_UUID: %v\n "+ "NODE_UUID: %v\n "+
"CLUSTER_VERSION: %v\n "+
"CLUSTER_DISTRIBUTION: %v\n "+
"CLUSTER_ENDPOINT: [\"%v\"]\n "+ "CLUSTER_ENDPOINT: [\"%v\"]\n "+
"CLUSTER_USERNAME: \"%v\"\n "+ "CLUSTER_USERNAME: \"%v\"\n "+
"CLUSTER_PASSWORD: \"%v\"\n "+ "CLUSTER_PASSWORD: \"%v\"\n "+
"CLUSTER_LEVEL_TASKS_ENABLED: %v\n "+ "CLUSTER_LEVEL_TASKS_ENABLED: %v\n "+
"NODE_LEVEL_TASKS_ENABLED: %v\n "+ "NODE_LEVEL_TASKS_ENABLED: %v\n "+
"NODE_LOGS_PATH: \"%v\"\n\n\n", taskID, taskID, "NODE_LOGS_PATH: \"%v\"\n\n\n", taskID, taskID,
v.ClusterID, v.ClusterUUID, v.NodeUUID, nodeEndPoint, username, password, clusterLevelEnabled, nodeLevelEnabled, pathLogs))) v.ClusterID, v.ClusterUUID, v.NodeUUID, version, distribution, nodeEndPoint, username, password, clusterLevelEnabled, nodeLevelEnabled, pathLogs)))
} }
hash := util.MD5digest(buffer.String()) hash := util.MD5digest(buffer.String())