自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Filebeat收集日志數(shù)據(jù)傳輸?shù)絉edis,通過Logstash來根據(jù)日志字段創(chuàng)建不同的ES索引

數(shù)據(jù)庫 Redis
在redis中顯示的效果是都會輸出到key值nginx_log對應的列表中,根據(jù)key值是沒法進行區(qū)分的,只能根據(jù)key值列表中每一行數(shù)據(jù)中的log_source或者自己定義的屬性來判斷該行是哪一個應用的日志。

1.Filebeat.yml配置

filebeat.inputs:
- type: log
enabled: true
paths:
- /usr/local/nginx/logs/access.log
exclude_files: ['.gz$','INFO']
multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'
multiline.negate: true
multiline.match: after
tags: ["nginx-log-messages"]
fields:
log_source: messages
fields_under_root: true


output.redis:
hosts: ["192.168.0.111:6379"]
key: nginx_log
password: nginxredis
db: 0

參數(shù)說明:

  fields:
log_source: messages
fields_under_root: true

使用fields表示在filebeat收集的日志中多增加一個字段log_source,其值是messages,用來在logstash的output輸出到elasticsearch中判斷日志的來源,從而建立相應的索引 若fields_under_root設置為true,表示上面新增的字段是頂級參數(shù)。

頂級字段在output輸出到elasticsearch中的使用如下:

[root@es-master21 logstash]# vim config/logstash.conf
input {
redis {
data_type => "list"
host => "192.168.0.111"
db => "0"
port => "6379"
key => "nginx_log"
password => "nginxredis"
}
}

output {
# 根據(jù)redis鍵 messages_secure 對應的列表值中,每一行數(shù)據(jù)的其中一個參數(shù)來判斷日志來源
if [log_source] == 'messages' { # 注意判斷條件的寫法
elasticsearch {
hosts => ["192.168.0.111:9200"]
index => "nginx-message-%{+YYYY.MM.dd}"
#user => "elastic"
#password => "elastic123"
}
}

#或者也可以根據(jù)tags判斷
if "nginx-log-messages" in [tags] {
elasticsearch {
hosts => [""192.168.0.111:9200"]
index => "nginx-message-%{+YYYY.MM.dd}"
}
}

}

2.多個應用的日志都輸出到redis

filebeat.inputs:
- type: log
enabled: true
paths:
- /usr/local/nginx/logs/access.log
tags: ["nginx-log-access"]
fields:
log_source: access
fields_under_root: true

- type: log
enabled: true
paths:
- /usr/local/nginx/logs/error.log
tags: ["nginx-log-error"]
fields:
log_source: error
fields_under_root: true

output.redis:
hosts: ["192.168.0.111:6379"]
key: nginx_log
password: nginxredis
db: 0

?在redis中顯示的效果是都會輸出到key值nginx_log對應的列表中,根據(jù)key值是沒法進行區(qū)分的,只能根據(jù)key值列表中每一行數(shù)據(jù)中的log_source或者自己定義的屬性來判斷該行是哪一個應用的日志。

3.不同的應用日志使用不同的rediskey值

使用output.redis中的keys值,官方例子:

output.redis:
hosts: ["localhost"]
key: "default_list"
keys:
- key: "error_list" # send to info_list if `message` field contains INFO
when.contains:
message: "error"
- key: "debug_list" # send to debug_list if `message` field contains DEBUG
when.contains:
message: "DEBUG"
- key: "%{[fields.list]}"

說明:默認的key值是default_list,keys的值是動態(tài)分配創(chuàng)建的,當redis接收到的日志中message字段的值包含有error字段,則創(chuàng)建key為error_list,當包含有DEBUG字段,則創(chuàng)建key為debug_list。

問題的解決方法是在每個應用的輸出日志中新增一個能夠區(qū)分這個日志的值,然后再在keys中設置,這樣一來就能夠把不同應用的日志輸出到不同的redis的key中。

責任編輯:武曉燕 來源: 非著名運維
相關推薦

2017-09-21 13:18:11

存儲云端數(shù)據(jù)

2020-05-20 14:38:35

傳輸距離網絡布線

2021-09-07 09:34:04

CentOSfilebeatkafka

2021-04-27 09:45:33

Nginx日志運維

2020-06-11 16:35:02

filebeatlogstash前端

2020-06-12 07:50:15

大數(shù)據(jù)

2019-04-25 08:28:58

工具LogstashFilebeat

2013-11-26 15:51:45

Android編程藍牙數(shù)據(jù)傳輸

2010-04-07 14:54:38

2023-01-14 15:38:07

日志管理工具

2021-12-14 11:01:44

TCPUDP網絡協(xié)議

2024-11-13 06:18:50

2021-10-08 08:37:38

數(shù)據(jù)傳輸數(shù)據(jù)調用網絡協(xié)議

2010-07-13 15:55:12

FTP數(shù)據(jù)傳輸模式

2023-04-12 16:20:00

同步數(shù)據(jù)異步數(shù)據(jù)傳輸

2015-10-14 09:44:55

TCP網絡協(xié)議數(shù)據(jù)傳輸

2022-08-12 11:46:50

Kubernetes云原生開源

2011-03-04 13:22:10

FileZilla

2020-08-13 08:34:10

MySQL數(shù)據(jù)DTS

2010-06-30 15:06:27

FTP數(shù)據(jù)傳輸模式
點贊
收藏

51CTO技術棧公眾號