kubesphere k8s 安装Fluentd,带elasticsearch插件
目录
前言
一、制作Fluentd镜像
二、编写配置文件
1.编辑配置
2.配置说明(可忽略不看)
3.logback-spring.xml的配置
三、部署fluentd
前言
Fluentd是一款开源的日志收集功能,和Elasticsearch、Kibana一起使用可以搭建EFK日志收集系统。好处就是Fluentd比Logstash轻量化的多。内存占用连Logstash的十分之一都不到。本文将演示如何在kubesphere k8s上部署Fluentd
一、制作Fluentd镜像
dockerhub上有官方的镜像,但是里面不内置elasticsearch插件。这样的话在k8s上会有些问题,没法安装啊!!
制作方法也很简单官方教程:
fluent/fluentd-docker-image: Docker image for Fluentd (github.com)
如果实在是懒得麻烦,用我做好的也行。
aliyun: docker pull registry.cn-shanghai.aliyuncs.com/samaritan/fluentd:1.14-1
二、编写配置文件
1.编辑配置
在kubesphere上新建一个配置文件
key:fluent.conf
value:
<source>
@type tcp
@id debug-input
port 4560
tag debug
<parse>
@type json
</parse>
</source><source>
@type tcp
@id error-input
port 4561
tag error
<parse>
@type json
</parse>
</source><source>
@type tcp
@id business-input
port 4562
tag business
<parse>
@type json
</parse>
</source><source>
@type tcp
@id record-input
port 4563
tag record
<parse>
@type json
</parse>
</source><filter record>
@type parser
key_name message
reserve_data true
remove_key_name_field true
<parse>
@type json
</parse>
</filter><match fluent.**>
@type stdout
output_type json
</match><match **>
@type elasticsearch
host elastic-9g8m25-elasticsearch-master.mall-swarm
port 9200
type_name docker
logstash_format true
logstash_prefix docker-${tag}-logs
logstash_dateformat %Y-%m-%d
flush_interval 5s
include_tag_key true
</match>
2.配置说明(可忽略不看)
<source>
定义了日志收集的来源,可以有tcp、udp、tail(文件)、forward(tcp+udp)、http等方式。
这里我们从tcp请求收集日志,端口为4560
,并且设置了tag为debug
。
<source>@type tcp@id debug-inputport 24221tag debug<parse>@type json</parse>
</source>
<parse>
定义对原始数据的解析方式,可以将日志转化为JSON。
将debug日志转化为JSON可以进行如下配置。
<source>@type tcp@id debug-inputport 4560tag debug<parse>@type json</parse>
</source>
<filter xxx>
可以对收集的日志进行一系列的处理,比如说将日志打印到控制台或者对日志进行解析。
对于tag为record
来源的日志,我们将其中的message
属性转化为JSON格式,如果不进行转化的话,message
属性将会是一个字符串。
<filter record>@type parserkey_name messagereserve_data trueremove_key_name_field true<parse>@type json</parse>
</filter>
<match>
定义了收集到的日志最后输出到哪里,可以输出到stdout(控制台)、file、elasticsearch、mongo等里面。
这里我们使用elasticsearch
来存储日志信息,logstash_format
、logstash_prefix
、logstash_dateformat
主要用来控制日志索引名称的生成,当前配置生成debug日志的索引格式为docker-debug-logs-2021-10-23
,flush_interval
用来控制日志输出到elasticsearch的时间间隔。
<match **>@type elasticsearchhost elastic-9g8m25-elasticsearch-master.samaritanport 9200type_name dockerlogstash_format truelogstash_prefix docker-${tag}-logslogstash_dateformat %Y-%m-%dflush_interval 5sinclude_tag_key true
</match>
3.logback-spring.xml的配置
这里面没啥说的,就是将上面的端口配置到里面,好让日志能够输出到fluentd
<appender name="LOG_STASH_DEBUG" class="net.logstash.logback.appender.LogstashTcpSocketAppender"><destination>${LOG_STASH_HOST}:4560</destination>
</appender>
三、部署fluentd
kubesphere部署无状态服务。
使用自定义经常仓库地址 这里用我自己制作上传的带es插件的镜像:
registry.cn-shanghai.aliyuncs.com/samaritan/fluentd:1.14-1。
选择使用默认端口
设置日志搜集端口。
挂载配置文件,选择之前编写的配置文件,挂载到/fluentd/etc 目录
点击下一步,创建。
查看启动日志,确定载入的是我们自定义的配置文件,且无报错。
kubesphere k8s 安装Fluentd,带elasticsearch插件相关推荐
- Google Chrome谷歌浏览器安装最新版Elasticsearch插件 图文教程 【一看就懂】
我们在虚拟机安装了Elasticsearch后,往往还需要再安装一个可视化界面以便于使用.本文就教您如何在Google Chrome谷歌浏览器安装最新版Elasticsearch(es)插件. | 1 ...
- 使用 Fluentd 和 ElasticSearch Stack 实现 Kubernetes 的集群 Logging
经过一段时间的探索,我们先后完成了Kubernetes集群搭建,DNS.Dashboard.Heapster等插件安装,集群安全配置,搭建作为Persistent Volume的CephRBD,以及服 ...
- Linux / Windows系统中安装最新版 ElasticSearch (es)搜索引擎 超详细图文教程【一看就懂】
"You Know, for Search" 相信来到这里的朋友们已经对ElasticSearch(es)有了一个大致的了解.关于Elasticsearch的介绍就不在此做过多赘 ...
- 2021年大数据ELK(八):Elasticsearch安装IK分词器插件
全网最详细的大数据ELK文章系列,强烈建议收藏加关注! 新文章都已经列出历史文章目录,帮助大家回顾前面的知识重点. 目录 系列历史文章 安装IK分词器 一.下载Elasticsearch IK分词器 ...
- 安装kibana,X-pack和elasticsearch插件的全过程
Are U ready? 搞Elasticsearch的话死后需要安装一些辅助工具,在安装这些工具之前,最好先检查rpm和node版本,如下: [root@chen-elk-001 elasticse ...
- Elasticsearch学习笔记(三)安装hanlp中文分词插件及同义词配置
目录 hanlp分词插件 插件安装 在线安装 离线安装 安装数据包 同义词配置 hanlp分词插件 HanLP是一款免费开源(Apache License 2.0协议)中文语义分词工具,它提供中文分词 ...
- ELK(3)——elasticsearch插件安装
文章目录 1.下载elasticsearch-head插件 2.更换npm源安装 1.下载elasticsearch-head插件 wget https://github.com/mobz/elast ...
- k8s安装elasticSearch(简易版)
k8s安装elasticSearch apiVersion: v1 kind: ReplicationController metadata:name: elasticsearchnamespace: ...
- windows下STS(Spring Tools Suite,自带spring插件的eclipse)的下载与安装
STS和eclipse使用方式完全一模一样,包括设置和快捷键.直接使用STS,省去了eclipse安装spring插件的过程. 一.下载与安装 (1)在官网上下载STS http://spring.i ...
最新文章
- 11kw星三角启动延时几秒_电机星三角降压启动接线方法图解
- exportfs命令、NFS客户端问题、FTP介绍、使用vsftpd搭建ftp
- Linux初到者五个最易犯的错误
- Android单元测试研究与实践
- Dragonfly成为CNCF孵化项目,我们与基金会首位华人TOC聊了聊
- java中如果需要返回多个值怎么办
- Spring:延迟初始化
- JAVA 调用HTTP接口POST或GET实现方式
- 数据结构严蔚敏(c语言版)课后算法题答案-树和二叉树
- MDR的进阶版本-GMDR
- linux ftp上传命令实例,ftp上传文件命令,Linux中使用ftp命令上传文件
- licode erizo pipleline 1 : handlercontext
- 数月沉淀终圆梦,西安校区刘同学转行测试收获12K,嫽扎咧
- Racket编程指南——23 Racket和Scheme的方言
- datagrip连接mysql数据库失败
- mysql自增主键达到最大后如何处理
- 自动化脚本之SCRT
- 用条码标签打印软件批量打印照片
- 自主小型Web服务器实现——TinyHttp
- Charles — mac下网络封包分析工具