问题描述
我正在尝试使用原始适配器在远程机器上发送日志。在我的日志机上,我使用 ELK (logstash)。我在 go 模板中收到了容器名称,但我无法正确接收主机名。 “主机”字段是 ip 号而不是主机名。我尝试在 go-template 中接收主机名,并在 raw_format 变量中使用,如下所示:
"RAW_FORMAT={ "container": {{ toJSON .Container.Name }},"message": {{ toJSON .Data }},"hostname": {{ toJSON .Container.Config.Hostname }} }\n" but i receive "localhost"
这是我的 docker-compose.yaml 文件
networks:
logging:
services:
logspout:
image: gliderlabs/logspout:v3.2.12
command: 'raw+tcp://some.addres:5000'
environment:
- DEBUG=1
- "RAW_FORMAT={ "container": {{ toJSON .Container.Name }},"hostname": {{ toJSON .Container.Config.Hostname }} }\n"
volumes:
- /etc/hostname:/etc/hostname
- /etc/hosts:/etc/hosts
- /var/run/docker.sock:/var/run/docker.sock
networks:
- logging```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)