
filebeat.prospectors:
- input_type: log
document_type: hello_world
paths:
- /data/log/*.log
output.logstash:
hosts:["localhost:5044"]
这里需要注意的一点是 document_type, 它的作用是在于 Indexer 的时候,通过这个 字段来匹配相应的 filter 和 output。
bin/logstash -f logstash_configuration/conf.d --config.reload.automatic
input {
beats {
port => 5044
codec => plain
}
}
filter {
if [type] == "halo_api" {
grok {
match => {
"message" => "\[(?<log_level>\w+)\s+(?<year>\d\d)%{MONTHNUM:month}%{MONTHDAY:day}\s%{TIME:time}\s+%{DATA:trace_id}\s+%{DATA:module}:%{NUMBER:line_no:int}\s+%{DATA:hostname}:%{NUMBER:process:int}\]\s+(?<log_message>[\s\w\W]+)" }
}
translate {
field => "log_level"
destination => "log_level"
override => "true"
dictionary => ["A", "ALERT", "T", "TRACE", "D", "DEBUG",
"N", "NOTICE", "W", "WARN", "I", "INFO", "E", "ERROR",
"C", "CRITICAL", "F", "FATAL"]
}
mutate {
add_field => {
"log_timestamp" => "20%{year}-%{month}-%{day} %{time}"
}
}
date {
match => ["log_timestamp", "yyyy-MM-dd HH:mm:ss"]
timezone => "Etc/GMT"
target => "log_timestamp"
}
}
}
output {
if [type] == "halo_api" {
elasticsearch {
hosts => ["halo-es01:9200"]
index => "%{type}-%{+yyyy.MM.dd}"
template => "/data/apps/logstash_configuration/templates/halo_api.json"
template_name => "halo_api.json"
template_overwrite => true
}
}
}
pipeline:
workers: 24
batch:
size: 125
delay: 5
"settings": {
"index.refresh_interval": "15s",
"analysis": {
"analyzer": {
"my_custom_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": "standard"
}
}
}
},
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31509949/viewspace-3132306/ ,如需转载,请注明出处,否则将追究法律责任。