diff --git a/config/setup/common/data/task_config_tpl.dat b/config/setup/common/data/task_config_tpl.dat index 4ea796c9..d41d6d91 100644 --- a/config/setup/common/data/task_config_tpl.dat +++ b/config/setup/common/data/task_config_tpl.dat @@ -6,6 +6,8 @@ elasticsearch: name: $[[TASK_ID]] cluster_uuid: $[[CLUSTER_UUID]] enabled: true + distribution: $[[CLUSTER_DISTRIBUTION]] + version: $[[CLUSTER_VERSION]] endpoints: $[[CLUSTER_ENDPOINT]] discovery: enabled: false diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md index 2d70da26..e76aaa8d 100644 --- a/docs/content.en/docs/release-notes/_index.md +++ b/docs/content.en/docs/release-notes/_index.md @@ -26,6 +26,7 @@ Information about release notes of INFINI Console is provided here. - Add credential settings for agent in enrolling agent - Add collection mode to cluster editing - 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) diff --git a/docs/content.zh/docs/release-notes/_index.md b/docs/content.zh/docs/release-notes/_index.md index 19271bc9..33c35549 100644 --- a/docs/content.zh/docs/release-notes/_index.md +++ b/docs/content.zh/docs/release-notes/_index.md @@ -24,6 +24,7 @@ title: "版本历史" - 在集群编辑中新增采集模式 - 当使用 Easysearch 存储指标时,自动为系统集群创建 Agent 指标写入最小权限用户 (#120) - 修复 LDAP 用户映射增加默认权限组 (#114) (#130) +- Agent 连接 Easysearch 的配置信息中增加 `version` 和 `distribution` 来解决启动时退出问题 (#131) ## 1.28.1 (2025-01-24) diff --git a/modules/agent/api/remote_config.go b/modules/agent/api/remote_config.go index ed8d82d6..b8badf2f 100644 --- a/modules/agent/api/remote_config.go +++ b/modules/agent/api/remote_config.go @@ -197,22 +197,30 @@ func getAgentIngestConfigs(instance string, items map[string]BindingItem) (strin var username = "" var password = "" + var version = "" + var distribution = "" - if metadata.Config.AgentCredentialID != "" { - credential, err := common2.GetCredential(metadata.Config.AgentCredentialID) - if err != nil { - log.Error(err) - continue - } - var dv interface{} - dv, err = credential.Decode() - if err != nil { - log.Error(err) - continue - } - if auth, ok := dv.(model.BasicAuth); ok { - username = auth.Username - password = auth.Password.Get() + if metadata.Config != nil { + + version = metadata.Config.Version + distribution = metadata.Config.Distribution + + if metadata.Config.AgentCredentialID != "" { + credential, err := common2.GetCredential(metadata.Config.AgentCredentialID) + if err != nil { + log.Error(err) + continue + } + var dv interface{} + dv, err = credential.Decode() + if err != nil { + 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 - buffer.Write([]byte(fmt.Sprintf("\n - name: \"%v\"\n path: ./config/task_config.tpl\n "+ "variable:\n "+ "TASK_ID: %v\n "+ "CLUSTER_ID: %v\n "+ "CLUSTER_UUID: %v\n "+ "NODE_UUID: %v\n "+ + "CLUSTER_VERSION: %v\n "+ + "CLUSTER_DISTRIBUTION: %v\n "+ "CLUSTER_ENDPOINT: [\"%v\"]\n "+ "CLUSTER_USERNAME: \"%v\"\n "+ "CLUSTER_PASSWORD: \"%v\"\n "+ "CLUSTER_LEVEL_TASKS_ENABLED: %v\n "+ "NODE_LEVEL_TASKS_ENABLED: %v\n "+ "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())