Hello,
I've been reading for a long time in different sources if it's possible to send all data processed by logstash to one index and at the same time send just some specific fields of this data to another different index.
I tried to use the clone filter plugin to achieve it but it doesn't work for me.
e.g, I have this logstash configuration:
input { stdin { } }
filter {
clone {
clones => ["cloned"]
}
grok {
match => { "message" => "%{NUMBER:timestamp}\s+%{NUMBER:duration}\s%{IP:client_address}\s%{WORD:cache_result}/%{POSINT:status_code}\s%{NUMBER:bytes}\s%{WORD:request_method}\s%{NOTSPACE:url}\s(%{NOTSPACE:user}|-)\s%{WORD:hierarchy_code}/%{IPORHOST:server}\s%{NOTSPACE:content_type}"}
}
if [type] == "cloned" {
prune {
whitelist_names => ["url"]
}
}
}
output {
if [type] == "cloned" {
elasticsearch {
hosts => ["localhost:9200"]
index => "cloned_index"
}
}
elasticsearch {
hosts => ["localhost:9200"]
index => "http_examples"
}
stdout { codec => rubydebug }
}
Sending the following data:
1598405553.742 289 127.0.0.1 TCP_MISS/301 440 GET http://this-is-a-test/ - HIER_DIRECT/13.107.42.14 -
I have the following output:
{
"url" => "http://this-is-a-test/"
}
{
"content_type" => "-",
"status_code" => "301",
"bytes" => "440",
"message" => "1598405553.742 289 127.0.0.1 TCP_MISS/301 440 GET http://this-is-a-test/ - HIER_DIRECT/13.107.42.12 -",
"cache_result" => "TCP_MISS",
"client_address" => "127.0.0.1",
"duration" => "289",
"@timestamp" => 2022-04-14T01:16:18.624Z,
"hierarchy_code" => "HIER_DIRECT",
"timestamp" => "1598405553.742",
"server" => "13.107.42.12",
"request_method" => "GET",
"url" => "http://this-is-a-test/",
"@version" => "1",
"host" => "elastic",
"user" => "-"
}
I see it prints the two different outputs but I don't find the way to create the index in the index pattern area of the Stack management in Kibana.
Any idea of what can be happening?
Thanks a lot for your help.