following is my config
input {
file {
path => "/*.log"
start_position => "beginning"
sincedb_path => "/sincedb.log"
exclude => ["*current.log", "*sincedb.log"]
}
}
filter {
json {
source => "message"
# add_field => { "new_field2" => "My name is %{controller}" }
remove_field => [ "message" ]
}
}
output {
elasticsearch {
hosts => "http://127.0.0.1:9200"
index => "log_${???}" # what i want to know
codec => "json"
}
}
-
input
i'm reading multiple json lines in multiple files. (read mode)
in these json strings including 'date' property (yyyy-MM-dd HH:mm:ss) -
filter
i added logstash'smessage
tosource
and deletemessage
-
output
i want to insert this log into 'log_2019.08.13' index in elasticsearch.
i has created indices name with server date.
but, sometime 'date' key's value in log and actual server time is not same.
for example, value about log's 'date' key is '2019-08-12 23:59:59'.
but when this logs going in index, and server time has changed to next day,
this log will be come to 'log_2019.08.13'. so, my aggregation result has lower correctness.
so, i decided to make index name's date 'yyyy.MM.dd' format via log's 'date' field.
how can i substring(for substring ' HH:mm:ss', 'yyyy-MM-dd')
and join(for join "yyyy + '.' + MM + '.' + dd")
and use in index name in logstash config?