一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

腳本之家,腳本語(yǔ)言編程技術(shù)及教程分享平臺(tái)!
分類導(dǎo)航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務(wù)器之家 - 腳本之家 - Python - 基于logstash實(shí)現(xiàn)日志文件同步elasticsearch

基于logstash實(shí)現(xiàn)日志文件同步elasticsearch

2020-08-06 10:57志不堅(jiān)者智不達(dá) Python

這篇文章主要介紹了基于logstash實(shí)現(xiàn)日志文件同步elasticsearch,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

引言:

之前博文介紹過了mysql/oracle與ES之間的同步機(jī)制。而logstash最初始的日志同步功能還沒有介紹。本文就logstash同步日志到ES做下詳細(xì)解讀。

1、目的:

將本地磁盤存儲(chǔ)的日志文件同步(全量同步、實(shí)時(shí)增量同步)到ES中。

基于logstash實(shí)現(xiàn)日志文件同步elasticsearch

2、源文件:

?
1
2
3
4
[root@5b9dbaaa148a test_log]# ll
-rwxrwxrwx 1 root root 170 Jul 5 08:02 logmachine.sh
-rw-r--r-- 1 root root 66 Jul 5 08:25 MProbe01.log
-rw-r--r-- 1 root root 74 Jul 5 08:28 MProbe02.log

3、增量實(shí)時(shí)同步腳本:

?
1
2
3
4
5
6
7
8
9
[root@5b9dbaaa148a test_log]# cat logmachine.sh
#!/bin/bash
icnt=0;
while (true)
do
 echo "[debug][20160703-15:00]"$icnt >> MProbe01.log
 echo "[ERROR][20160704-17:00]"$icnt >> MProbe02.log
 icnt=$((icnt+1));
done

4、logstash配置文件:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@5b9dbaaa148a logstash_jdbc_test]# cat log_test.conf
input {
 file {
 path=> [ "/usr/local/logstash/bin/test_log/MProbe01.log",
"/usr/local/logstash/bin/test_log/MProbe02.log" ]
 #codec=>multiline {
 # pattern => "^\s"
 # what=>"previous"
 #}
 type=>"probe_log" #類型名稱
 # tags=>["XX.XX.XX.XX"]
 }
}
 
###過濾
#filter{
# grok {
# match => ["message","mailmonitor"]
# add_tag => [mailmonitor]
# }
 
# grok {
# match => [ "message", "smsmonitor" ]
# add_tag => [smsmonitor]
# }
# ....
#}
 
###output to es
output {
 elasticsearch {
 hosts => "10.8.5.101:9200"
 index => "mprobe_index"   #索引名稱
 #template_name => "mprobelog"
 #document_id => "%{id}"
 }
 stdout { codec => json_lines }
}

5、同步測(cè)試:

[root@5b9dbaaa148a bin]# ./logstash -f ./logstash_jdbc_test/log_test.conf
Settings: Default pipeline workers: 24
Pipeline main started
{"message":"[DEbug][20160305-15:35]testing02","@version":"1","@timestamp":"2016-07-05T07:26:08.043Z","path":"/usr/local/logstash/bin/test_log/MProbe01.log","host":"5b9dbaaa148a"

6、結(jié)果驗(yàn)證

(1)日志記錄:

[root@5b9dbaaa148a test_log]# tail -f MProbe01.log
[DEbug][20160305-15:35]testing02
[DEbug][20160305-15:35]testing01
^C
[root@5b9dbaaa148a test_log]# tail -f MProbe02.log
[DEbug][20160305-15:35]testing02_001
[DEbug][20160305-15:35]testing02_003

(2)ES記錄

基于logstash實(shí)現(xiàn)日志文件同步elasticsearch

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://www.cnblogs.com/linwenbin/p/13432882.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产99热 | 热门小说同人h改编h | 四虎永久网址在线观看 | www.四虎.com | 亚洲激情在线 | 国产一区在线免费观看 | 午夜久久免影院欧洲 | 国产福利在线观看91精品 | 日本三级大学生17 | 国产精品国产高清国产专区 | 久久久久嫩草影院精品 | 好大好硬视频 | 久久中文字幕综合不卡一二区 | 亚洲婷婷在线视频 | uoco福利姬网站 | 91啦在线播放 | 亚洲免费在线视频 | 男女一级特黄a大片 | 国产欧美精品一区二区三区四区 | 久久免费黄色 | 亚洲视频高清 | 乳女教师欲乱动漫无修版动画3d | 免费看国产精品久久久久 | 国产精品视频久久久 | 国产精品毛片高清在线完整版 | 97影音| 白丝萝莉喷水 | 九九热只有精品 | 欧美精品一线二线大片 | 精新精新国产自在现 | 香蕉在线精品一区二区 | 国产午夜不卡 | 变态女王麻麻小说在线阅读 | 齐天大性之七仙女欲春迅雷链接 | 久久理论片迅播影院一级 | 国产日韩精品一区二区在线观看播放 | 久久精品热在线观看85 | 好大好爽好硬我要喷水了 | 天天射寡妇射 | 4hc44四虎永久地址链接 | 亚洲理论视频 |