alibaba / ilogtail

Fast and Lightweight Observability Data Collector
https://ilogtail.gitbook.io/ilogtail-docs
Apache License 2.0
1.71k stars 384 forks source link

[BUG]:ilogtail 每次重启 app_info.json 里面的 instance_id 都会变动 #1405

Open wangzan18 opened 6 months ago

wangzan18 commented 6 months ago

Describe the bug A clear and concise description of what the bug is, ideally within 20 words. ilogtail 每次重启 app_info.json 里面的 instance_id 都会变动 iLogtail Running Environment Please provide the following information: Ubuntu 22.04 64位

root@test-sre-zhangyuan:/usr/local/ilogtail# cat app_info.json { "UUID" : "", "build_date" : "20240111", "compiler" : "GCC 9.3.1", "git_hash" : "48473de035a796d8235c6beb92015096dd41f649", "hostname" : "test-sre-zhangyuan", "instance_id" : "EF18CA38-E353-11EE-BAED-05EDAC7629781710566012", "ip" : "172.16.122.244", "logtail_version" : "2.0.0 Community Edition", "os" : "Linux; 5.15.0-56-generic; #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022; x86_64", "update_time" : "2024-03-16 13:13:32" } root@test-sre-zhangyuan:/usr/local/ilogtail# systemctl restart ilogtaild root@test-sre-zhangyuan:/usr/local/ilogtail# cat app_info.json { "UUID" : "", "build_date" : "20240111", "compiler" : "GCC 9.3.1", "git_hash" : "48473de035a796d8235c6beb92015096dd41f649", "hostname" : "test-sre-zhangyuan", "instance_id" : "40C67A10-E354-11EE-BAED-05EDAC762978__1710566149", "ip" : "172.16.122.244", "logtail_version" : "2.0.0 Community Edition", "os" : "Linux; 5.15.0-56-generic; #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022; x86_64", "update_time" : "2024-03-16 13:15:49" } root@test-sre-zhangyuan:/usr/local/ilogtail# systemctl restart ilogtaild root@test-sre-zhangyuan:/usr/local/ilogtail# cat app_info.json { "UUID" : "", "build_date" : "20240111", "compiler" : "GCC 9.3.1", "git_hash" : "48473de035a796d8235c6beb92015096dd41f649", "hostname" : "test-sre-zhangyuan", "instance_id" : "43E55E32-E354-11EE-BAED-05EDAC7629781710566155", "ip" : "172.16.122.244", "logtail_version" : "2.0.0 Community Edition", "os" : "Linux; 5.15.0-56-generic; #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022; x86_64", "update_time" : "2024-03-16 13:15:55" }

使用 configServer 同一台机器出现多个 image

yyuuttaaoo commented 6 months ago

这个行为是by design的,目前开源的config server对此没有处理好。

liangry commented 6 months ago

严格来说,不算是 bug,应该算主干分支 config server 没有实现的功能,没有心跳管理,已经离线的 agent 记录不能剔除。很久之前,已提交 PR

https://github.com/alibaba/ilogtail/pull/1016

nelsontang commented 3 months ago

需要固定可以换成dmi-uuid,下面写了一个实现

optional GetSystemUUID() {

if defined(linux)

{ ifstream uuidFile("/sys/class/dmi/id/product_uuid"); string uuid; if (uuidFile.is_open()) { getline(uuidFile, uuid); uuidFile.close(); return uuid; } return nullopt; }

elif defined(_MSC_VER)

{ HKEY hKey; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Cryptography", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { char uuidBuffer[255]; DWORD bufferSize = sizeof(uuidBuffer); if (RegQueryValueEx(hKey, "MachineGuid", nullptr, nullptr, (LPBYTE)uuidBuffer, &bufferSize) == ERROR_SUCCESS) { string uuid(uuidBuffer); return uuid; } RegCloseKey(hKey); } return nullopt; }

else

return nullopt;

endif

}