logagent 根据 IP 获取配置
1 上一个版本的问题
- 每台服务器上的 logagent 的收集项可能都不一致,我们需要让 logagent 去 etcd 中根据 IP 地址获取自己的配置
2 如何获取本机的 IP
2.1 net.InterfaceAddrs
1 | func GetLocalIP() (ip string, err error) { |
2.2 net.Dial
1 | // Get preferred outbound ip of this machine |
3 logagent 中集成根据 ip 拉取配置
1 | func GetCollectConfig(ip string) (config []common.CollectConfigEntry, err error) { |
- 根据本机 ip 计算出在 etcd 配置中心的 key,从而取出配置项