Add your filters / logstash plugins configuration here
filter {
grok {
match => { "message" => [my filter (i deleted it because so long )] }
}
date {
match => [ "timestamp", "dd/MMM/YYYY:HH:mm:ss Z" ]
locale => en
}
geoip {
source => "clientip"
}
}
output {
if "_grokparsefailure" in [tags] {
# write events that didn't match to a file
file { "path" => "home/hakim/grok_failures.txt" }
}
else{
if [type] == 'cluster2' {
elasticsearch {
hosts => ["213.X.X.X:9200"] #manage_template => false
index => "cluster2"
user => XXXX
password => XXXX
}
}
else if [type] == 'clustermon' {
elasticsearch {
hosts => ["213.X.X.X:9200"] #manage_template => false
index => "clustermon"
user => XXXX
password => XXXX
}
}
}
}
when i put docker-compose up , all it's okay but when i added file logs there nothing happen , i didn't know why ?
Debug this systematically. Is Logstash getting any logs at all? Have you looked in the Logstash logs for clues about any connectivity problems with Elasticsearch?
Use a stdout { codec => rubydebug } output (not wrapped in a conditional) to dump the raw contents of the events to the Logstash log. That'll make it very clear if the type field indeed contains one of the two strings you support.
You can use whatever field you want. What fields you use to categorize your logs is up to you, but be careful about using filenames as they're more likely to change.
i tried with source it's worked , but i have to make the exact source ,now what i need is for example :
source = "/doc/file1.log" , but in /doc folder we have other logs files , i tried to use : if source == "/doc/*" for all logs files it's doen't work and i have to specify file per file , is there a way to specify all log files contained in folder ?
As I said, using filenames isn't a great idea. Instead, configure the inputs (Logstash's file input, Filebeat, or whatever you've got) to add a field (e.g. type but could be anything) that indicate the kind of log. Then your filters can focus on that field instead.
hi , i added 'type' tags , now it's appear in logstash logs , but when i use like with "source" , i mean
{ if [type] == "type"} , it doesn't work for me ?
hi , i have just a question , can i do my code now with 'translate' instead of 'if , else if ...' because i have more than 2 indexes to creat ? also as i know there is no "switch case" on logstash config
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.