国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

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

服務器之家 - 腳本之家 - Python - 基于logstash實現日志文件同步elasticsearch

基于logstash實現日志文件同步elasticsearch

2020-08-06 10:57志不堅者智不達 Python

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

引言:

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

1、目的:

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

基于logstash實現日志文件同步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、增量實時同步腳本:

?
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、同步測試:

[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、結果驗證

(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實現日志文件同步elasticsearch

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

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

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美黄色a视频 | 手机在线观看 | 在线免费成人 | 久久影音先锋 | 黄色国产 | 中文二区 | 精品超碰 | 国产视频网 | 在线观看免费黄视频 | 久色| 欧美freesex黑人又粗又大 | 美女久久久 | 精品在线一区 | 久久久av亚洲男天堂 | 日韩欧一区二区三区 | 欧美一级一区 | 国产高清一区二区 | 亚洲视频在线观看网址 | 国产一区二区精品在线观看 | 亚洲久久 | 国产欧美日韩在线 | 国产在线中文字幕 | 12306影视午夜入口 | 色综合99| 亚洲精品在线视频观看 | 久久中文字幕在线 | 国产精品二区一区二区aⅴ污介绍 | 欧美乱大交xxxxx春色视频 | 99亚洲伊人久久精品影院 | 久久毛片| 在线a人片免费观看视频 | 欧美另类专区 | 国产精品毛片久久久久久久 | 亚洲午夜精品视频 | 五月激情综合网 | 91传媒在线播放 | 荷兰欧美一级毛片 | 美日韩视频 | 91精品国产综合久久久久久漫画 | 久久精品成人 | av一区在线观看 |