KubeSphere使用外部ES进行日志收集(多行日志)

news2024/11/29 1:47:10

环境

kubesphere : v3.3.1

Docker:20.10.8

Fluent-Bit:2.0.6-2.0.8

ES+Kibana:7.9.3

Docker日志示例

{"log":"2023-01-10 11:32:50.021 -  INFO --- [scheduling-1] traceId: p6spy : 1|conn-0|statement|SELECT  fd_id AS id,fd_user_id AS userId,fd_specific_user AS specificUser,fd_home_assessment AS homeAssessment,fd_home_assessment_time AS homeAssessmentTime,fd_end_home_assessment AS endHomeAssessment,fd_end_home_assessment_time AS endHomeAssessmentTime,fd_daily_assessment AS dailyAssessment,fd_daily_count AS dailyCount,fd_daily_assessment_time AS dailyAssessmentTime,fd_sort AS sort,fd_delete_flag AS deleteFlag,fd_update_time AS updateTime,fd_create_time AS createTime,fd_version AS version,fd_org_id AS orgId  FROM t_patient_assessment     WHERE (fd_daily_assessment = 1) \n","stream":"stdout","time":"2023-01-10T03:32:50.021311904Z"}
{"log":"2023-01-10 11:32:50.022 -  INFO --- [scheduling-1] traceId: com.gjwlyy.covid.core.job.DailyReminderJob : \u003c\u003c\u003c 当前是用户1gkfb79bq39pe8mi37jknh81crt5k82m隔离的-23天 \n","stream":"stdout","time":"2023-01-10T03:32:50.023079165Z"}
{"log":"2023-01-10 11:32:50.025 - ERROR --- [scheduling-1] traceId: org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task java.lang.NumberFormatException: For input string: \"[{\"relation\":\"or\",\"rule\":\"=\",\"value\":\"0\"}]\"\n","stream":"stdout","time":"2023-01-10T03:32:50.025703129Z"}
{"log":"\u0009at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)\n","stream":"stdout","time":"2023-01-10T03:32:50.025727938Z"}
{"log":"\u0009at java.lang.Long.parseLong(Long.java:589)\n","stream":"stdout","time":"2023-01-10T03:32:50.025733862Z"}
{"log":"\u0009at java.lang.Long.parseLong(Long.java:631)\n","stream":"stdout","time":"2023-01-10T03:32:50.025737051Z"}
{"log":"\u0009at com.gjwlyy.covid.core.job.DailyReminderJob.lambda$dealPatientDailyJob$1(DailyReminderJob.java:116)\n","stream":"stdout","time":"2023-01-10T03:32:50.025740047Z"}
{"log":"\u0009at java.util.ArrayList.forEach(ArrayList.java:1257)\n","stream":"stdout","time":"2023-01-10T03:32:50.025743184Z"}
{"log":"\u0009at com.gjwlyy.covid.core.job.DailyReminderJob.lambda$dealPatientDailyJob$2(DailyReminderJob.java:110)\n","stream":"stdout","time":"2023-01-10T03:32:50.025747023Z"}
{"log":"\u0009at java.util.ArrayList.forEach(ArrayList.java:1257)\n","stream":"stdout","time":"2023-01-10T03:32:50.025750286Z"}
{"log":"\u0009at com.gjwlyy.covid.core.job.DailyReminderJob.lambda$dealPatientDailyJob$3(DailyReminderJob.java:109)\n","stream":"stdout","time":"2023-01-10T03:32:50.025753216Z"}
{"log":"\u0009at java.util.ArrayList.forEach(ArrayList.java:1257)\n","stream":"stdout","time":"2023-01-10T03:32:50.025756256Z"}
{"log":"\u0009at com.gjwlyy.covid.core.job.DailyReminderJob.dealPatientDailyJob(DailyReminderJob.java:106)\n","stream":"stdout","time":"2023-01-10T03:32:50.025759298Z"}
{"log":"\u0009at com.gjwlyy.covid.core.job.DailyReminderJob.dailyJob(DailyReminderJob.java:61)\n","stream":"stdout","time":"2023-01-10T03:32:50.025762317Z"}
{"log":"\u0009at com.gjwlyy.covid.core.job.DailyReminderJob$$FastClassBySpringCGLIB$$34fb91e0.invoke(\u003cgenerated\u003e)\n","stream":"stdout","time":"2023-01-10T03:32:50.025765223Z"}
{"log":"\u0009at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)\n","stream":"stdout","time":"2023-01-10T03:32:50.025768376Z"}
{"log":"\u0009at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)\n","stream":"stdout","time":"2023-01-10T03:32:50.025771336Z"}
{"log":"\u0009at com.gjwlyy.covid.core.job.DailyReminderJob$$EnhancerBySpringCGLIB$$7af1cd70.dailyJob(\u003cgenerated\u003e)\n","stream":"stdout","time":"2023-01-10T03:32:50.025774261Z"}
{"log":"\u0009at sun.reflect.GeneratedMethodAccessor167.invoke(Unknown Source)\n","stream":"stdout","time":"2023-01-10T03:32:50.025777303Z"}
{"log":"\u0009at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n","stream":"stdout","time":"2023-01-10T03:32:50.025780146Z"}
{"log":"\u0009at java.lang.reflect.Method.invoke(Method.java:498)\n","stream":"stdout","time":"2023-01-10T03:32:50.025783075Z"}
{"log":"\u0009at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)\n","stream":"stdout","time":"2023-01-10T03:32:50.025785872Z"}
{"log":"\u0009at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)\n","stream":"stdout","time":"2023-01-10T03:32:50.025788727Z"}
{"log":"\u0009at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)\n","stream":"stdout","time":"2023-01-10T03:32:50.025798209Z"}
{"log":"\u0009at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n","stream":"stdout","time":"2023-01-10T03:32:50.02580237Z"}
{"log":"\u0009at java.util.concurrent.FutureTask.run(FutureTask.java:266)\n","stream":"stdout","time":"2023-01-10T03:32:50.02580537Z"}
{"log":"\u0009at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)\n","stream":"stdout","time":"2023-01-10T03:32:50.025808239Z"}
{"log":"\u0009at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)\n","stream":"stdout","time":"2023-01-10T03:32:50.025811169Z"}
{"log":"\u0009at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n","stream":"stdout","time":"2023-01-10T03:32:50.025814181Z"}
{"log":"\u0009at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n","stream":"stdout","time":"2023-01-10T03:32:50.025817118Z"}
{"log":"\u0009at java.lang.Thread.run(Thread.java:748)\n","stream":"stdout","time":"2023-01-10T03:32:50.025820003Z"}
{"log":"\n","stream":"stdout","time":"2023-01-10T03:32:50.025822812Z"}
{"log":"2023-01-10 11:33:00.001 -  INFO --- [scheduling-1] traceId: com.gjwlyy.covid.core.job.DailyReminderJob : \u003c\u003c\u003c dailyJob 患者日程定时任务开始.请求参数 \n","stream":"stdout","time":"2023-01-10T03:33:00.001296014Z"}
{"log":"2023-01-10 11:33:00.007 -  INFO --- [scheduling-1] traceId: p6spy : 1|conn-0|statement|SELECT  fd_id AS id,fd_schedule_name AS scheduleName,fd_schedule_trigger_time AS scheduleTriggerTime,fd_status AS status,fd_sort AS sort,fd_delete_flag AS deleteFlag,fd_update_time AS updateTime,fd_create_time AS createTime,fd_version AS version,fd_org_id AS orgId  FROM t_management_schedule     WHERE (fd_delete_flag = false AND fd_status = true) \n","stream":"stdout","time":"2023-01-10T03:33:00.007959022Z"}
{"log":"2023-01-10 11:33:00.008 -  INFO --- [scheduling-1] traceId: com.gjwlyy.covid.core.job.DailyReminderJob : \u003c\u003c\u003c 定时任务涉及的管理日程记录id:[100099] \n","stream":"stdout","time":"2023-01-10T03:33:00.008512022Z"}

安装Fluent-Bit

kubectl create ns fluent-bit

helm repo add fluent https://fluent.github.io/helm-charts

helm upgrade --install fluent-bit fluent/fluent-bit -n fluent-bit

配置Fluent-Bit

编写文件custom_parsers.conf

[PARSER]
    Name java_multi_line    #起个名
    Key_name log   #默认的Key_name为log
    Format regex   #固定值
    Regex (?<log>^{"log":"\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}\.\d{3}\ .*})   #匹配log字段(时间点,例如:2023-01-09 03:59:24.617)
[PARSER]
    Name docker_no_time
    Format json
    Time_Keep Off
    Time_Key time
    Time_Format %Y-%m-%dT%H:%M:%S.%L

编写文件fluent-bit.conf

[SERVICE]
    Daemon Off
    Flush 1
    Log_Level info
    Parsers_File parsers.conf
    Parsers_File custom_parsers.conf
    HTTP_Server On
    HTTP_Listen 0.0.0.0
    HTTP_Port 2020
    Health_Check On

[INPUT]
    Name tail
    Path /var/log/containers/*.log    #收集日志的地址
    Exclude_Path /var/log/containers/*_kube*-system_*.log   #排除不想收集的日志
    Docker_Mode On   #如果启用,插件将重新组合分离的Docker日志行,然后将它们传递给上面配置的任何解析器。该模式不能与Multiline 模式同时使用。 (重要)
    Docker_Mode_Flush   5   #等待时间(以秒为单位),以处理排队的多行消息  (重要)
    Docker_Mode_Parser java_multi_line  #指定处理器的名称,custom_parsers.conf里面定义的 (重要)
    Parser docker
    # multiline.parser docker, cri
    Tag kube.*
    Mem_Buf_Limit 5MB
    Skip_Long_Lines On
[FILTER]
    Name kubernetes
    Match kube.*
    Annotations Off   #不收集注解
    Labels Off    #不收集标签
    Merge_Log Off   #当启用时,它检查日志字段内容是否是JSON字符串映射,如果是,它将映射字段作为日志结构的一部分追加。
    Keep_Log Off
    K8S-Logging.Parser On   #允许Kubernetes Pods建议预定义的解析
    K8S-Logging.Exclude On   #允许Kubernetes Pods从日志处理器中排除它们的日志

[FILTER]
    Name    nest   #操作嵌套数据
    Match    kube.*
    Operation    lift   #通过lift模式,从记录的将指定map中的key value都提取出来放到上一层
    Nested_under    kubernetes   #指定需要提取的map名
    Add_prefix    kubernetes_    #添加前缀

[Filter]
    Name    modify
    Match    kube.*
    Remove    stream     #移除字段stream
    Remove    kubernetes_docker_id
    Remove    kubernetes_pod_id
    Remove    kubernetes_host
    Remove    kubernetes_container_hash
    Rename    kubernetes_namespace_name namespace_name  #修改字段名称
    Rename    kubernetes_pod_name pod_name
    Rename    kubernetes_container_name container_name
    Rename    kubernetes_container_image container_image

[OUTPUT]
    Name es
    Host 192.168.31.253
    Port 9200
    HTTP_User elastic
    HTTP_Passwd 6ygXXXXXXXXXXXXX
    Logstash_Format On
    Replace_Dots On  #替换“.”变为“_”
    Logstash_Prefix kubesphere  #索引名称前缀
    Retry_Limit False

效果展示

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/152893.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java 泛型的介绍和使用

什么是泛型? 1.数据类型变得广泛,或者是数据类型变量化,这就是泛型.(广泛的类型). 2.有一个变量是用来存放一个数据类型,这就叫做泛型. 比如泛型T存放的是一个int 就表示为:Tint 当然T也可以是其他的数据类型,就取决我们给它数据类型. 3.泛型允许程序员在强类型程序设计语…

kafka zookeeper单机版安装部署全教程 含安装包

kafka zookeeper安装部署全教程 含安装包 大家好&#xff0c;我是酷酷的韩~ 一.基础软件安装 1.JDK安装部署 linux安装jdk1.8全教程(包含安装包) 二.安装包准备 1.kafka (kafka_2.12-2.8.0.tgz) https://kafka.apache.org/downloads 2.zookeeper (apache-zookeeper-3.7.…

最近爆火的电子血氧仪的基本原理

继口罩、抗原、药品之后,最近电子血氧仪的价格也开始水涨船高。从一个多月前的100多元,暴涨到了300多元。 那么,这类家用的电子血氧仪是如何工作的呢?测量数据到底准不准?今天就带大家来分析一下。 一、血氧仪工作原理 血氧仪是一种监测脉搏、血氧饱和度等指标的医疗器械…

人工智能-EM算法

目录1、EM算法2、EM算法介绍3、EM算法实例1、EM算法 EM算法&#xff1a;期望最大化算法。解决数据缺失情况下的参数估计问题 它是一个基础算法&#xff0c;是HMM等的基础 期望步:E步,最大步M步 步骤&#xff1a; 1&#xff0c;根据已经给出的观测数据&#xff0c;估计出模型参…

世界上第一款启用 QMK/VIA 的薄型无线机械键盘 Keychron K3 Pro 我刚刚入手

文章目录1. Keychron K3 Pro 是什么2. 键盘参数3. 打字音效测试4. 超薄5. 支持热插拔6. 薄型 Gateron 开关7. 薄型双射 PBT 键帽8. 多功能键9. 键盘部件可自定制10. 电池11. QMK 和 VIA 定制12. 产品清单13. 与 keychron k3 对比14. 与 keychron 其他系列对比14.1 为什么没有选…

Swin Transformer阅读笔记

Swin Transformer 使用了移动窗口的层级式的Vit&#xff08;Hierarchical Vision Transformer using Shifted Windows&#xff09; 总体来说&#xff1a;Swin Transformer想让Transformer像卷积神经网络一样&#xff0c;可以分为多个block&#xff0c;可以做层级式特征提取&a…

Flowable工作流——基础篇

1. 介绍 Flowable是BPMN的一个基于Java的软件实现&#xff0c;但是不仅仅限于BPMN&#xff0c;还有DMN决策表和CMMN Case管理引擎&#xff0c;并且有自己的用户管理&#xff0c;微服务API的功能&#xff0c;是一个服务平台。 是由开发了Acitivity6的开发人员&#xff0c;再次升…

nacos的使用

此篇博客是对nacos安装运行进行简单的介绍&#xff0c;后续博客会介绍下nacos的简单使用。nacos的安装安装可以去github上进行下载&#xff0c;下载地址&#xff08;不建议下载最新版本&#xff0c;可以找比较稳定的版本&#xff09;可以点解Tags查看所有历史版本我下载的是2.2…

基于 js 制作一个贪吃蛇小游戏

目录前言&#xff1a;项目效果展示&#xff1a;代码实现思路&#xff1a;使用方法&#xff1a;实现代码&#xff1a;总结&#xff1a;前言&#xff1a; 在工作学习之余玩一会游戏既能带来快乐&#xff0c;还能缓解生活压力&#xff0c;跟随此文一起制作一个小游戏吧。 描述&…

ESXI8.0一键安装黑群晖DSM7

&#x1f388; 作者&#xff1a;互联网-小啊宇 &#x1f388; 简介&#xff1a; CSDN 运维领域创作者、阿里云专家博主。目前从事 Kubernetes运维相关工作&#xff0c;擅长Linux系统运维、开源监控软件维护、Kubernetes容器技术、CI/CD持续集成、自动化运维、开源软件部署维护…

如何做好项目管理

项目管理概述 什么是项目 项目 是为创造独特的产品、服务或者成果而进行的临时性工作 项目三要素&#xff1a;临时性、独特性、渐进明确性 什么是项目管理 项目管理通过合理运营和整合项目相关活动&#xff0c;以满足项目目标达成的过程 项目与日常工作的区别 项目&…

设计测试用例

⭐️前言⭐️ 这篇文章主要介绍测试用例相关的知识&#xff0c;一个优秀的测试人员&#xff0c;需要具备设计优秀测试用例的能力。 &#x1f349;欢迎点赞 &#x1f44d; 收藏 ⭐留言评论 &#x1f4dd;私信必回哟&#x1f601; &#x1f349;博主将持续更新学习记录收获&…

基于启发式蝙蝠算法、粒子群算法、花轮询算法和布谷鸟搜索算法的换热器PI控制器优化(Matlab代码实现)

目录 &#x1f4a5;1 概述 &#x1f4da;2 运行结果 &#x1f389;3 参考文献 &#x1f468;‍&#x1f4bb;4 Matlab代码 &#x1f4a5;1 概述 本文采用蝙蝠算法、粒子群优化、花轮询算法和布谷鸟搜索算法&#xff0c;对管壳式换热器的控制系统进行了建模和计算机仿真。为…

trie树入门

trie树分为普通的trie树和01trie树两者可以实现成树&#xff0c;很大一部分原因是&#xff1a;只有26个字母和01两种状态&#xff0c;一个结点度数不会太大&#xff0c;而且字符串长度和位数不会很大&#xff0c;更容易存储普通trie树维护了一堆字符串集合的前缀&#xff0c;in…

Elastic-Job分布式任务调度(4):Elastic-Job高级

1 事件追踪 Elastic-Job-Lite在配置中提供了JobEventConfiguration&#xff0c;支持数据库方式配置&#xff0c;会在数据库中自动创建JOB_EXECUTION_LOG和JOB_STATUS_TRACE_LOG两张表以及若干索引&#xff0c;来记录作业的相关信息。 1.1 修改Elastic-Job配置类 在ElasticJo…

电商人必读:2022中国电商市场发展洞察报告(人群、品类、品牌、玩法).pdf(附下载链接)...

省时查报告-专业、及时、全面的行研报告库省时查方案-专业、及时、全面的营销策划方案库【免费下载】2022年12月份热门报告盘点罗振宇2023年跨年演讲PPT原稿吴晓波2022年年终秀演讲PPT原稿《底层逻辑》高清配图华为2021数字化转型&#xff1a;从战略到执行.pdf华为项目管理金种…

如何理解操作系统

路灯很多&#xff0c;希望你找到自己的月亮。 作者&#xff1a;阿润菜菜 目录 操作系统是什么 为什么设计操作系统 理解操作系统的作用 如何理解操作系统对软硬件管理&#xff1f; 操作系统为什么要对软硬件资源进行管理呢&#xff1f; 什么是系统调用和库函数 总结 操…

【docker13】Redis面试题

面试题 问题&#xff1a; 1~2亿条数据需要缓存&#xff0c;请问如何设计这个存储案例&#xff1f; 回答&#xff1a; 单机单台不可能的&#xff0c;肯定是分布式存储&#xff08;那如何用redis实现呢&#xff1f;) 解决1&#xff1a; 哈希取余分区 优点&#xff1a; 简单粗暴…

项目管理系统的类型

“系统”一词有两个不同的定义&#xff1a;一、定义某事如何完成的原则和程序&#xff0c;二、复杂整体的部分。因此&#xff0c;根据所使用的定义&#xff0c;项目管理系统也可以有两种不同的含义。 第一个是指定义如何执行项目的完整过程和原则系统。此定义包括所有项目管理以…

windows10上安装Python3.11.1

1&#xff09;下载Python3.11.1 Python官网下载地址&#xff1a;https://www.python.org/ package意思是下载压缩安装包&#xff0c;installer是.exe的安装程序。 根据自己电脑需求选择&#xff0c;这里我选择的是64位 2&#xff09;安装 双击安装包&#xff0c;进行安装。…