当前位置:网站首页>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 !
边栏推荐
- 数据可视化没有重点怎么办?
- The principle of Zener diode, what is its function?
- College entrance examination voluntary filling, why is the major the last consideration?
- [Introduction aux uvm== > Episode 9] ~ modèle de registre, intégration du modèle de registre, méthode conventionnelle du modèle de registre, scénario d'application du modèle de registre
- Sichuan earth microelectronics high performance, high integration and low cost isolated 485 transceiver
- Sichuan earth microelectronics ca-is1200 isolated operational amplifier for current detection
- Weimeisi new energy rushes to the scientific innovation board: the annual revenue is 1.7 billion, and the book value of accounts receivable is nearly 400million
- STL教程4-输入输出流和对象序列化
- Runtime——methods成员变量,cache成员变量
- 13 `bs_ duixiang. Tag tag ` get a tag object
猜你喜欢

Sichuan earth microelectronics 8-channel isolated digital input receiver

JMeter introduction practice ----- use of global variables and local variables

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

基于地面点稀少的LiDAR点云的茂密森林蓄积量估算

【批处理DOS-CMD命令-汇总和小结】-外部命令-cmd下载命令、抓包命令(wget)

The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse

为什么要“除夕”,原来是内存爆了!

Common functions of OrCAD schematic

OAuth 2.0一键登录那些事

14 bs对象.节点名称.name attrs string 获取节点名称 属性 内容
随机推荐
[batch dos-cmd command - summary and summary] - application startup and call, service and process operation commands (start, call, and)
Chuantuwei ca-is3720lw alternative material No. iso7820fdw
Home environment monitoring system design (PC version) (mobile app version to be determined)
VectorDraw Developer Framework 10.10
The principle of Zener diode, what is its function?
Mysql database import SQL file display garbled code
[Batch dos - cmd Command - Summary and Summary] - External Command - cmd Download Command, wget Command
不同路径II[针对DFS的动态规划改进]
Redis learning notes
RTKLIB-b33版本中GALILEO广播星历存储问题
Ns32f103c8t6 can perfectly replace stm32f103c8t6
数据可视化没有重点怎么办?
Advanced mathematics foundation_ Parity of functions
Unity3D邪门实现之GUI下拉菜单Dropdown设计无重复项
Keepalived monitors the process and automatically restarts the service process
Leetcode daily question - 515 Find the maximum value in each tree row
JMeter introduction practice ----- use of global variables and local variables
OpenMP入门
Debian introduction
韩信大招:一致性哈希

