Products
GG网络技术分享 2025-11-10 13:25 3
根据您给的文本内容,
FROM logstash:7.7.1。input有些配置Logstash从哪里获取数据。file输入插件,指定Docker日志文件的路径和模式,比方说:
conf
input {
file {
path => "/var/lib/docker/containers/*.log"
type => "docker_log"
start_position => "beginning"
}
}
path指定了Docker日志文件的存储路径。type为日志事件设置类型,方便后续处理。start_positionNeng设置为beginning或last_event,用于指定从文件开头还是从上次读取的位置开头读取。filter有些对收集到的日志数据进行处理。grok插件来解析日志数据, 比方说:
conf
filter {
if == "docker_log" {
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} %{DATA:container_id} %{GREEDYDATA:log_message}" }
}
}
}
output有些指定Logstash将处理后的数据发送到哪个位置。conf
output {
elasticsearch {
hosts =>
index => "docker-%{+YYYY.MM.dd}"
document_type => "docker_log"
}
}
hosts指定Elasticsearch集群的地址。index设置输出到Elasticsearch的索引名称,Neng用变量来动态生成索引名。通过上述步骤, LogstashNeng高大效地收集和处理Docker日志,并将其存储在Elasticsearch中,便于后续琢磨和监控。

Demand feedback