qikqiak.com icon indicating copy to clipboard operation
qikqiak.com copied to clipboard

在 Kubernetes 上搭建 EFK 日志收集系统

Open cnych opened this issue 6 years ago • 22 comments

https://www.qikqiak.com/post/install-efk-stack-on-k8s/

cnych avatar Jan 17 '19 09:01 cnych

hello,大佬如何关于日志收集的时间,或者持久化的时间段应该如何配置呢

yangjie1993 avatar Jan 23 '19 09:01 yangjie1993

@yangjie1993 这个需要去配置elasticsearch,默认情况下es应该没有这种配置,自己写一个脚本定期去删除以前的index就行了。

cnych avatar Jan 23 '19 10:01 cnych

hi 阳明 这样收集,如果是java 错误日志,收集起来被分行了。。能否处理恩 ?

hehua2018 avatar Feb 22 '19 05:02 hehua2018

@hehua2018 可以试一试fluent-plugin-tail-multiline这个插件应该可以解决分行的问题。

cnych avatar Feb 22 '19 13:02 cnych

请问使用NFS在IO上会不会有性能问题

LoadingZhang avatar Feb 26 '19 03:02 LoadingZhang

@LoadingZhang 肯定会有这方面的问题,我这里使用NFS只是为了演示方便,具体的线上用什么后端存储还是需要你们自己结合自己的习惯。

cnych avatar Mar 04 '19 00:03 cnych

你好,请问es中日志信息是存储在/usr/share/elasticsearch/data中吗,我看到挂载的持久化目录是这个,但是https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/fluentd-elasticsearch/es-statefulset.yaml 这里挂载的是根目录的/data,这个目录我也没看到有什么日志信息……

TheHati avatar Jul 09 '19 08:07 TheHati

@TheHati 这个应该和具体的镜像有关系,需要查看下镜像里面的Dockerfile~

cnych avatar Jul 09 '19 14:07 cnych

大佬好,有个问题请教下,我们目前使用的环境中 程序日志并没有输出到stdout和stderr中,是直接输出到文件中,使用flutend 收集比较困难,并且收集在kubana中无法看到对应的日志,这种情况下有什么好的方法解决吗,现在直接用fluented发现无法收集成功收集日志?

MikelPan avatar Nov 09 '19 10:11 MikelPan

已将文章更新到最新的 7.6.2 版本的 Elasticsearch,支持各种编程语言异常情况下的多行日志收集,增加日志分析和基于日志的报警内容。

本文节选至 K8S训练营 直播课程内容,更多内容欢迎你来发现~。

cnych avatar Apr 28 '20 07:04 cnych

照着这个来,只是把路径改为 /var/lib/docker/containers ,但是收集不到日志,咋排查呢? fluentd就一个日志```` [warn]: [elasticsearch] Detected ES 7.x: `_doc` will be used as the document `_type`.

fsckzy avatar Apr 30 '20 10:04 fsckzy

@fsckzy 仔细看,我这里是过滤了的,只会收集具有 logging=true 这个标签的 Pod 日志。

cnych avatar Apr 30 '20 10:04 cnych

@cnych @fsckzy 仔细看,我这里是过滤了的,只会收集具有 logging=true 这个标签的 Pod 日志。

上面不是做了个counter.yaml吗?我也照着做了呀

fsckzy avatar May 06 '20 01:05 fsckzy

大佬好,我执行到这一步(kubectl get pods -n logging),为什么没有出现3个节点。

caolaoban666 avatar Jun 12 '20 03:06 caolaoban666

@fsckzy 照着这个来,只是把路径改为 /var/lib/docker/containers ,但是收集不到日志,咋排查呢? fluentd就一个日志```` [warn]: [elasticsearch] Detected ES 7.x: `_doc` will be used as the document `_type`.

我也出现了你这个问题,请问你解决了吗?我猜是不是镜像版本的问题?

Jalins avatar Aug 05 '20 01:08 Jalins

请教一个问题, 我按照你这里的做法部署了 elastalert ,因为我开启了 xpack, 我在配置中增加了 es_username es_password, 第一次部署的时候没问题,成功了,但是可能是因为email那块没配置好,收不到email, 就想删除掉重新部署, 删除后重新部署不管怎么部署都会报错,es中也清理了第一次创建的index, 报错如下,还请帮忙看看哈

Elastic Version: 7.6.2 Reading Elastic 6 index mappings: Reading index mapping 'es_mappings/6/silence.json' Reading index mapping 'es_mappings/6/elastalert_status.json' Reading index mapping 'es_mappings/6/elastalert.json' Reading index mapping 'es_mappings/6/past_elastalert.json' Reading index mapping 'es_mappings/6/elastalert_error.json' Traceback (most recent call last): File "/usr/local/bin/elastalert-create-index", line 8, in sys.exit(main()) File "/usr/local/lib/python3.6/site-packages/elastalert/create_index.py", line 264, in main create_index_mappings(es_client=es, ea_index=index, recreate=args.recreate, old_ea_index=old_index) File "/usr/local/lib/python3.6/site-packages/elastalert/create_index.py", line 30, in create_index_mappings if es_index.exists(ea_index): File "/usr/local/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped return func(*args, params=params, **kwargs) File "/usr/local/lib/python3.6/site-packages/elasticsearch/client/indices.py", line 257, in exists return self.transport.perform_request("HEAD", _make_path(index), params=params) File "/usr/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 318, in perform_request status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout) File "/usr/local/lib/python3.6/site-packages/elasticsearch/connection/http_requests.py", line 91, in perform_request self._raise_error(response.status_code, raw_data) File "/usr/local/lib/python3.6/site-packages/elasticsearch/connection/base.py", line 131, in _raise_error raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info) elasticsearch.exceptions.AuthorizationException: AuthorizationException(403, '')

snycloud avatar Sep 07 '20 12:09 snycloud

其他的做完都没问题,但我要怎么和ES交互呢,我直接 curl -XGET "localhost:9200/?pretty" 出错 curl -XGET "http://elasticsearch:9200/?pretty"也出错 这我要怎么访问ES?求教。

gesions avatar Sep 18 '20 05:09 gesions

hi 阳明
docker 容器日志 把我的 java错误日志分成了 这种 json格式 怎么能合并呢?

{"log":"\u0009at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)\n","stream":"stdout","time":"2020-09-18T02:46:37.025644666Z"}
{"log":"\u0009at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)\n","stream":"stdout","time":"2020-09-18T02:46:37.025647965Z"}
{"log":"\u0009at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)\n","stream":"stdout","time":"2020-09-18T02:46:37.025650786Z"}
{"log":"\u0009at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)\n","stream":"stdout","time":"2020-09-18T02:46:37.025653551Z"}
{"log":"\u0009at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)\n","stream":"stdout","time":"2020-09-18T02:46:37.025656287Z"}
{"log":"\u0009at com.neux.utils.log.Aspect.LogAspect.doAround(LogAspect.java:58)\n","stream":"stdout","time":"2020-09-18T02:46:37.025659068Z"}
{"log":"\u0009at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n","stream":"stdout","time":"2020-09-18T02:46:37.02566182Z"}
{"log":"\u0009at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n","stream":"stdout","time":"2020-09-18T02:46:37.025664567Z"}
{"log":"\u0009at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n","stream":"stdout","time":"2020-09-18T02:46:37.025671874Z"}
{"log":"\u0009at java.lang.reflect.Method.invoke(Method.java:498)\n","stream":"stdout","time":"2020-09-18T02:46:37.025675242Z"}
{"log":"\u0009at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)\n","stream":"stdout","time":"2020-09-18T02:46:37.025677994Z"}

Sherlock-Harden avatar Sep 18 '20 05:09 Sherlock-Harden

感谢作者再次更新,我添加了链接至参考文章,感兴趣的同学可以点击浏览 开源日志管理方案 ELK 和 EFK 的区别 - https://wsgzao.github.io/post/efk/

wsgzao avatar Nov 03 '20 03:11 wsgzao

  • name: varlog hostPath: path: /var/log - name: varlibdockercontainers hostPath: path: /data/docker/containers - name: config-volume configMap: name: fluentd-config

您好博主 请教下 把主机下的/var/log挂载fluentd里面的意思是可以监控log目录下所有的日志么? 不知道理解是否正确

menkeyi avatar Nov 19 '21 05:11 menkeyi

ELK太重了,有没有轻量一些的 我只需要收集k3s的事件日志

MagicStarTrace avatar Nov 30 '21 10:11 MagicStarTrace

我这边使用的loki,如果你有需求,可以直接联系我!

| | Mr.Pan | | @.*** | 签名由网易邮箱大师定制

在2021年11月30日 @.***> 写道:

ELK太重了,有没有轻量一些的 我只需要收集k3s的事件日志

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

MikelPan avatar Nov 30 '21 10:11 MikelPan