DEV Community

drake
drake

Posted on

log-pilot以容器的方式启动并且通过参数的方式登录ES失败

产生问题的启动方式

  • 启动方式一:
docker run --name mypilot --rm -it \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /:/host \
    --privileged  \
    -e PILOT_LOG_PREFIX=bitget \
    -e FLUENTD_OUTPUT=elasticsearch \
    -e LOGGING_OUTPUT=elasticsearch \
    -e ELASTICSEARCH_HOSTS=108.182.1.238:9200 \
    -e ELASTICSEARCH_USER="elastic" \
    -e ELASTICSEARCH_PASSWORD="#x@xxxxxxxx" \
    registry.cn-hangzhou.aliyuncs.com/acs-sample/log-pilot:latest
Enter fullscreen mode Exit fullscreen mode
  • 启动方式二:
 docker run --name mypilot --rm -it \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /:/host \
    -v /etc/localtime:/etc/localtime \
    --privileged  \
    -e PILOT_LOG_PREFIX=bitget \
    -e LOGGING_OUTPUT=elasticsearch \
    -e ELASTICSEARCH_HOSTS=http://108.182.1.238:9200 \
    -e ELASTICSEARCH_USER=elastic \
    -e ELASTICSEARCH_PASSWORD=#x@xxxxxxxx \
    registry.cn-hangzhou.aliyuncs.com/acs/log-pilot:0.9.7-filebeat
Enter fullscreen mode Exit fullscreen mode

问题背景

基于上面的容器启动方式是无法连接需要鉴权的ES的,尝试了各种方案,排查了各种可能得问题,搞了2-3天,没搞出来就是连不上ES;
且容器日志没有任何可供参考的报错信息,官方文档,已经其他可供搜索的资料和案例非常少,基本等于盲猜bug;
于是乎各种search, re search 各种尝试,无果;
最后今天傍晚没招了;我实在找不到可以尝试的方案了;
只能当阿里云(该工具是阿里云开源的日志只能收集工具)是傻逼了,我账号密码没错,但是密码含有特殊字符可能会导致程序异常;


问题解决

  • 上面说了尝试了各种方案无果,其实遗漏了一个很关键的方案,就是我密码的格式log-pilot不支持,为什么遗漏?因为我们很多时候都会带着有色眼镜看人,就像遇到个清华毕业生你根本不会怀疑他不会做小学数学题;
  • 这种有色眼镜会先入为主,直接忽略这种优秀团队不会犯得sb错误;于是针对这种sb错误的尝试方案就忽略了;
  • 这个sb错误就是 工具无法解析含有特殊字符的密码;
  • 我实在没辙了,只能尝试下不大可能的方案,会不会是我的密码含有特殊字符#x@ 导致 log-pilot 无法解析
  • 于是我删除了特殊字符;将参数-e ELASTICSEARCH_PASSWORD=#x@xxxxxxxx \ 改为 -e ELASTICSEARCH_PASSWORD=xxxxxxxx \ 就成了!!!!!
  • 完整的启动命令:
 docker run --name mypilot --rm -it \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /:/host \
    -v /etc/localtime:/etc/localtime \
    --privileged  \
    -e PILOT_LOG_PREFIX=bitget \
    -e LOGGING_OUTPUT=elasticsearch \
    -e ELASTICSEARCH_HOSTS=http://108.182.1.238:9200 \
    -e ELASTICSEARCH_USER=elastic \
    -e ELASTICSEARCH_PASSWORD=xxxxxxxx \
    registry.cn-hangzhou.aliyuncs.com/acs/log-pilot:0.9.7-filebeat
Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay