当前位置:网站首页>Common types and basic usage of input plug-in of logstash data processing service
Common types and basic usage of input plug-in of logstash data processing service
2022-04-23 13:32:00 【Jiangxl~】
Logstash Input plug-ins for data processing services Input Common types and basic usage
List of articles
1.Input Common types of plug-ins
logstash The plug-ins usually have stdin( For debugging )、file、redis、kafka、beats(filebeat) type .
2.Logstash Input Common configuration parameters
Input Some of the common configurations in are automatically , These fields can be in Redis、kakfa、filebeat、file And so on, used in various types of input plug-ins .
add_field
: Add a field to an event , Put it at the top of the event , It is generally used to mark the log source . For example, which project does it belong to , Which application
tags
: Add any number of tags , Other attributes used to mark logs , For example, it indicates whether the access log or the error log
type
: Add a field for all inputs , For example, indicate the log type
These three configuration fields are added to the collected log data , You only need to select one of these three fields for configuration , stay outpost The output plug-in can match according to fields and values , Store the log data of different fields in different locations ES In the index library .
1. To configure logstash
[root@elkstack-1 ~]# vim /data/elk/logstash/conf.d/test.conf
input {
file {
path => "/var/log/test/*.log"
exclude => "error.log"
start_position => "beginning"
tags => "web" # Add a label
type => "nginx" # Add a field type, The value is nginx
add_field => { # Add field information at the front of the log data ,project by web,app by nginx
"project" => "web"
"app" => "nginx"
}
}
}
filter {
}
output {
file {
path => "/tmp/log.txt"
}
}
2. Overload configuration
[root@elkstack-1 ~]# ps aux | grep logstash | grep -v grep | awk '{print $2}' |xargs kill -HUPUP
Observe the collected log data information , Added some field properties we configured
{"message":"web field","app":"nginx","path":"/var/log/test/access.log","tags":["web"],"host":"elkstack-1","project":"web","@version":"1","@timestamp":"2021-12-09T09:18:58.735Z","type":"nginx"}
The collected log data is json Format , Can be placed json Displayed in parser
3.Input To configure File Type of input plug-in
With /var/log/messages For example , adopt logstash take message Log output from to /tmp/log.txt In file .
3.1. Classic case
1. Writing configuration files
[root@elkstack-1 logstash]# cat conf.d/test.conf
input { # Define the source of the log
file { # The type is file, Read log data from file
path => "/var/log/message" # Log path
}
}
filter { # filter
}
output { # Define the storage path of log output
file {
path => "/tmp/log.txt" # Log path
}
}
2. heavy load logstash
[root@elkstack-1 logstash]# ps aux | grep logstash | grep -v grep | awk '{print $2}' |xargs kill -HUP
perhaps
[root@elkstack-1 logstash]# systemctl restart logstash
Observe /tmp/log.txt Is there any in the file logstash Data content written .
1. towards /var/log/messages Insert log data into
[root@elkstack-1 ~]# echo "123456" >> /var/log/messages
3. track /tmp/log.txt Observation logs are output
[root@elkstack-1 ~]# tail -f /tmp/log.txt
{"path":"/var/log/messages","host":"elkstack-1","@version":"1","@timestamp":"2021-12-09T08:12:43.656Z","message":"123456"}
3.2.File Common fields of type
path
: Log storage path , Support wildcard matching .
exclude
: Exclude log files that do not need to be collected .
start_position
: Specify where to start reading log files , The default is to read from the end , Specifies that the parameter value is beginning Indicates reading from the beginning of the file .
Example : Read /var/log/test All log files in the directory , But exclude error.log This file .
1.logstash Profile contents
[root@elkstack-1 ~]# vim /data/elk/logstash/conf.d/test.conf
input {
file {
path => "/var/log/test/*.log" # Read test All log files in the directory
exclude => "error.log" # Don't collect error Log files
start_position => "beginning" # Read from the beginning of the file
}
}
filter {
}
output {
file {
path => "/tmp/log.txt"
}
}
2. heavy load logstash
[root@elkstack-1 ~]# ps aux | grep logstash | grep -v grep | awk '{print $2}' |xargs kill -HUP
Observe the effect of log collection
1. towards access Write data to the log
[root@elkstack-1 ~]# echo access12332 > /var/log/test/access.log
[root@elkstack-1 ~]# echo access1 >> /var/log/test/access.log
2. Logs are logstash Normal collection of
[root@elkstack-1 ~]# tail -f /tmp/log.txt
{"path":"/var/log/test/access.log","message":"2","@version":"1","host":"elkstack-1","@timestamp":"2021-12-09T08:53:54.953Z"}
{"path":"/var/log/test/access.log","message":"access1","@version":"1","host":"elkstack-1","@timestamp":"2021-12-09T08:53:59.969Z"}
3. write in error Logs will not be collected
[root@elkstack-1 ~]# echo abc >> /var/log/test/access.log
4.logstash beats Type of plug-in
Beats The plug-in is used to receive data from Beats The data sent by the data collector , Common data collectors are Filebeat、Metricbeat、Packetbeat、Winlogbeat、Auditbeat、Heartbeat、Functionbeat wait .
Examples are as follows :
1. To configure logstash
[root@elkstack-1 ~]# vim /data/elk/logstash/conf.d/test.conf
input {
beats {
host => "0.0.0.0"
port => 5044
}
}
filter {
}
output {
file {
path => "/tmp/log.txt"
}
}
版权声明
本文为[Jiangxl~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231325215266.html
边栏推荐
- 基于uniapp异步封装接口请求简介
- TCP 复位gongji原理和实战复现
- Bottomsheetdialogfragment + viewpager + fragment + recyclerview sliding problem
- Isparta is a tool that generates webp, GIF and apng from PNG and supports the transformation of webp, GIF and apng
- Uniapp image import local image not displayed
- web三大组件之Servlet
- Solve the problem of Oracle Chinese garbled code
- [point cloud series] multi view neural human rendering (NHR)
- [point cloud series] foldingnet: point cloud auto encoder via deep grid deformation
- Migrating your native/mobile application to Unified Plan/WebRTC 1.0 API
猜你喜欢
SAP UI5 应用开发教程之七十二 - SAP UI5 页面路由的动画效果设置试读版
SHA512 / 384 principle and C language implementation (with source code)
面试官给我挖坑:URI中的 “//” 有什么用?
Plato farm, a top-level metauniverse game, has made frequent positive moves recently
LeetCode_DFS_中等_695.岛屿的最大面积
Learning notes of AMBA protocol
mui + hbuilder + h5api模拟弹出支付样式
为什么从事云原生开发需要学习容器技术
[dynamic programming] 221 Largest Square
CMSIS cm3 source code annotation
随机推荐
Mui wechat payment pit
Common analog keys of ADB shell: keycode
为什么从事云原生开发需要学习容器技术
Super 40W bonus pool waiting for you to fight! The second "Changsha bank Cup" Tencent yunqi innovation competition is hot!
According to the salary statistics of programmers in June 2021, the average salary is 15052 yuan. Are you holding back?
数据仓库—什么是OLAP
kettle庖丁解牛第16篇之输入组件周边讲解
2021年6月程序员工资统计,平均15052元,你拖后腿了吗?
[notes de marche]
Introduction to metalama 4 Use fabric to manipulate items or namespaces
Processbuilder tool class
mui 关闭其他页面,只保留首页面
ESP32 VHCI架构传统蓝牙设置scan mode,让设备能被搜索到
这几种 VSCode 扩展是我最喜欢的
The first lesson is canvas, showing a small case
面试官给我挖坑:单台服务器并发TCP连接数到底可以有多少 ?
[multi screen interaction] realize dual multi screen display II: startactivity mode
MySQL5. 5 installation tutorial
Servlet of three web components
基于uniapp异步封装接口请求简介