【发布时间】:2017-07-24 16:59:46
【问题描述】:
我正在关注一个在线教程,并获得了一个 cars.csv 文件和以下 Logstash 配置文件。我的 logstash 运行良好,并且在我们说话时正在为 CSV 编制索引。
问题是,我有另一个日志文件(完全不同的数据),我需要对其进行解析并索引到不同的索引中。
- 如何在不重新启动 logstash 的情况下添加此配置?
- 如果上述方法不可行,我编辑配置文件,然后重新启动 logstash - 它不会重新索引整个汽车文件吗?
- 如果我这样做 2. 如何为多种样式的日志文件格式化配置。
例如。我的新日志文件如下所示:
01-01-2017 ORDER FAILED: £12.11 Somewhere : Fraud
现有配置文件:
input {
file {
path => "/opt/cars.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
csv {
separator => ","
columns =>
[
"maker",
"model",
"mileage",
"manufacture_year",
"engine_displacement",
"engine_power",
"body_type",
"color_slug",
"stk_year",
"transmission",
"door_count",
"seat_count",
"fuel_type",
"date_last_seen",
"date_created",
"price_eur"
]
}
mutate {
convert => ["mileage", "integer"]
}
mutate {
convert => ["price_eur", "float"]
}
mutate {
convert => ["engine_power", "integer"]
}
mutate {
convert => ["door_count", "integer"]
}
mutate {
convert => ["seat_count", "integer"]
}
}
output {
elasticsearch {
hosts => "localhost"
index => "cars"
document_type => "sold_cars"
}
stdout {}
}
orders.log 的配置文件
input {
file {
path => "/opt/logs/orders.log"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
grok {
match => { "message" => "(?<date>[0-9-]+) (?<order_status>ORDER [a-zA-Z]+): (?<order_amount>£[0-9.]+) (?<order_location>[a-zA-Z]+)( : (?<order_failure_reason>[A-Za-z ]+))?"}
}
mutate {
convert => ["order_amount", "float"]
}
}
output {
elasticsearch {
hosts => "localhost"
index => "sales"
document_type => "order"
}
stdout {}
}
免责声明:我是一个完全的新手。使用 ELK 的第二天。
【问题讨论】:
标签: elasticsearch logstash logstash-configuration