"Results" directory contains Project1 & Project2 sub directories. Also there might be more "Project....n" sub dir gets created depending upon test run for several projects.
Each Project DIR contains more that one RUN directories....
I want to process each "Projects" directories as and when they are created and out put them to different indices at elasticsearch.
e.g. For Project1 index to be set as "Logstash-Project1-%{+YYYY.MM.dd}", similarly for Project2 as "Logstash-Project2-%{+YYYY.MM.dd}" and so on.
Use the grok filter to extract the project name from the input file path (stored in the path field), then reference that field when setting the index pattern of the elasticsearch output.
elasticsearch {
...
index => "logstash-%{project}-%{+YYYY.MM.dd}"
}
I dont know how to use grok filter to extract the project name from the input file path. What pattern i need to match for extracting Project from path. Any help?
The input file path has nothing to do with the path field. Its value is taken from the name of the actual file from which a particular log message actually came.
In case of linux it worked so I just thought of to run on windows using
grok {
match => ["path", "C:\Test\Result(?[^/]+)"]
}
This didn't work. any idea why?
I find the grok match can not enable the "path" and "message" work well together.
like this :
match => {
"message" => "%{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}"
"path" => "/logfile/(?\w+?)/"
}
First of all, thanks for your previous posts about index. I've tried your suggestion but I don't kown what i did wrong as it does' work for me... (Please inform me if you prefer opening a new topic)
I've 2 log files who stored in the directories /tmp/toto/first/ and /tmp/toto/second/ . I want to have the different index name distinguished by the project name (first and second in this case). Here are my configurations :
Filebeat :
...
paths:
- /tmp/toto/*/*.log
...
Logstash
input {
beats {
port => "5043"
}
}
filter {
grok {
match => { "path" => "/tmp/toto/(?<project>[^/]+)/" }
match => { "message" => "%{COMBINEDAPACHELOG}"}
}
date {
match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}
}
output {
elasticsearch {
hosts => [ "127.0.0.1:9200" ]
index => [ "log-%{project}-%{+YYYY.MM.dd}" ]
}
}
After starting all services, it seems elasticsearch doesn't understand project variable :
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open log-%{project}-2016.06.20 QNPYvvFqRzGFEC9_32da7g 5 1 450 0 807.6kb 807.6kb
yellow open log-%{project}-2017.02.22 RzDgOdWKQXqmItnm0zNdGw 5 1 232 0 138.5kb 138.5kb
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.