当前位置:网站首页>Elk + filebeat log parsing, log warehousing optimization, logstash filter configuration attribute
Elk + filebeat log parsing, log warehousing optimization, logstash filter configuration attribute
2022-06-25 07:40:00 【Fast attack】
List of articles
Preface
Some time ago, I did not build a set of ELK Log analysis system , Then the log is through beats Read landing log , Push to logstash, And then again from logstash Pushed to the elasticsearch The index library , Last adopt kibana Visual tools are used to analyze and view logs , See... For the construction process Springboot/Springcloud Integrate ELK platform ,(Filebeat The way ) Log collection and management (Elasticsearch+Logstash+Filebeat+Kibana)
Here is the graph kibana The result of the presentation , Here we find a lot of useless and duplicate fields , And my log fields have to be expanded to see , This part can certainly be optimized . And then my Springboot/Springcloud Integrate ELK platform ,(Filebeat The way ) Log collection and management (Elasticsearch+Logstash+Filebeat+Kibana) There was also a friend in the comment area of this article who asked me beats It can be pushed directly to elasticsearch, Why go through logstash?
Before this little friend comments , I have optimized the log , This article records the process of parsing the optimization log !
Optimization results

Realization
First , We know logstash There are many filter plug-ins
| plug-in unit | explain |
|---|---|
| date | Date resolution |
| grok | Regular matching parsing |
| dissect | Separator resolution |
| mutate | Process fields , Such as renaming 、 Delete 、 Replace |
| json | according to json Parse the field contents into the specified field |
| geoip | Add geographic location data |
| ruby | utilize ruby Code to dynamically modify Logstash Event |
Here I refer to the examples of these two articles , Then to my logstash Modify the log
Logstash filter Use
logstash Configuration details
- This is my output log
2022-06-10 11:00:47.974 ERROR [main] com.alibaba.nacos.client.config.http.ServerHttpAgent : [NACOS SocketTimeoutException httpGet] currentServerAddr:http://127.0.0.1:8848, err : connect timed out
- This is me log4j Defined format , Here I am logstash The configuration file is parsed according to this format , See... For log integration What is a log facade ? SpringBoot Integrate log4j2 , Log landing
# log4j2
%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%-5level} [%thread] %style{%logger{36}}{cyan} : %msg%n
# logstash Resolution in configuration
%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:level} %{JAVALOGMESSAGE:thread} %{JAVALOGMESSAGE:style} : %{JAVALOGMESSAGE:msg}
logstash
input {
beats {
port => 5044
type => "logs"
}
tcp {
mode => "server"
host => "127.0.0.1"
port => 4560
codec => json_lines
}
}
filter {
// Parsing log
grok{
match => {
"message" => "%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:level} %{JAVALOGMESSAGE:thread} %{JAVALOGMESSAGE:style} : %{JAVALOGMESSAGE:msg}" }
}
// Replace the warehousing time with the time in our log
date {
match => [ "timestamp" , "yyyy-MM-dd HH:mm:ss,S", "ISO8601" ]
}
// Delete redundant fields
mutate {
remove_field => "agent"
remove_field => "ecs"
remove_field => "@version"
remove_field => "host"
remove_field => "path"
remove_field => "log"
remove_field => "message"
}
}
output {
elasticsearch {
hosts => ["http://127.0.0.1:9200"]
user => "elastic"
passwrod => "123456"
index => "%{[fields][servicename]}-%{+yyyy.MM.dd}"
}
}
filebeat
Add the configuration
multiline:
pattern: ‘^\s*(\d{4}|\d{2})-(\d{2}|[a-zA-Z]{3})-(\d{2}|\d{4})’ accord with java Log line breaking rules
filebeat.inputs:
- type: log
enabled: true
paths:
- E:\ideaProject\SpringCloudAlibaba2022\logs\order-service\info.log
#- c:\programdata\elasticsearch\logs\*
fields:
servicename: order-service
multiline:
pattern: '^\s*(\d{4}|\d{2})\-(\d{2}|[a-zA-Z]{3})\-(\d{2}|\d{4})'
negate: true
match: after
timeout: 5s
- type: log
enabled: true
paths:
- E:\ideaProject\SpringCloudAlibaba2022\logs\user-service\info.log
#- c:\programdata\elasticsearch\logs\*
fields:
servicename: user-service
multiline:
pattern: '^\s*(\d{4}|\d{2})\-(\d{2}|[a-zA-Z]{3})\-(\d{2}|\d{4})'
negate: true
match: after
timeout: 5s
After these configuration changes are completed , restart filebeat、logstash
If you have any questions, please feel free to contact us by private letter !
Originality is not easy. , If it helps you, please give me a compliment before you leave ! thank !
边栏推荐
- Shell tips (134) simple keyboard input recorder
- Cocos learning diary 3 - API acquisition nodes and components
- LTpowerCAD II和LTpowerPlanner III
- 國外LEAD域名郵箱獲取途徑
- JMeter introduction practice ----- use of global variables and local variables
- 基于激光雷达的林业调查常用术语及含义锦集
- Distributed quorum NWR of the alchemy furnace of the Supreme Master
- Access to foreign lead domain name mailbox
- Intel announced five new technological developments, including quantum computing, neural pseudo computing, machine programming, integrated optoelectronics, and secure computing
- Tupu software digital twin 3D wind farm, offshore wind power of smart wind power
猜你喜欢

【批处理DOS-CMD命令-汇总和小结】-cmd扩展命令、扩展功能(cmd /e:on、cmd /e:off)

Chuantuwei ca-is3720lw alternative material No. iso7820fdw

Intel announced five new technological developments, including quantum computing, neural pseudo computing, machine programming, integrated optoelectronics, and secure computing

Estimation of dense forest volume based on LIDAR point cloud with few ground points

Kube scheduler source code analysis (1) - initialization and startup analysis

CPDA|数据分析师成长之路如何起步?

Leetcode daily question - 515 Find the maximum value in each tree row

几款不错的天气插件

ELK + filebeat日志解析、日志入库优化 、logstash过滤器配置属性
![[batch dos-cmd command - summary and summary] - CMD window setting and operation commands (CD, title, mode, color, pause, CHCP, exit)](/img/8c/7345b4e8a55dcf11d18ac113df4fc2.png)
[batch dos-cmd command - summary and summary] - CMD window setting and operation commands (CD, title, mode, color, pause, CHCP, exit)
随机推荐
el-input实现尾部加字
Design a MySQL table for message queue to store message data
NSIS 静默安装vs2013运行时
【批处理DOS-CMD命令-汇总和小结】-cmd扩展命令、扩展功能(cmd /e:on、cmd /e:off)
13 `bs_ duixiang. Tag tag ` get a tag object
Common functions of OrCAD schematic
基于激光雷达的林业调查常用术语及含义锦集
基于地面点稀少的LiDAR点云的茂密森林蓄积量估算
诸葛亮 VS 庞统,拿下分布式 Paxos
Cocos learning diary 3 - API acquisition nodes and components
STL教程4-输入输出流和对象序列化
无“米”,也能煮“饭”利用“点云智绘”反演机载LiDAR林下缺失地面点攻略
Sichuan earth microelectronics ca-is1300 isolated operational amplifier for current detection is on the market
Access to foreign lead domain name mailbox
栅格地图(occupancy grid map)构建
13 `bs_duixiang.tag标签`得到一个tag对象
韩信大招:一致性哈希
OAuth 2.0一键登录那些事
不同路径II[针对DFS的动态规划改进]
The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse
