Hi, I am new to ELK stack. This is my set so far for sending application logs : filebeat -> redis(dockers) -> logstash(dockers) -> ES.
My Question is what is the the correct way to setup custom index in logstash output?
According to my understanding I need to create a index template directly in ES and use the same name in the output of the logstash. Is this not the right approach? Because I don't see the fields are index in the way I defined in the template. Below are steps I followed
Step:
- Create a index template in ES using this - _index_template/index2_template and passed JSON with fields types.
- Used the same name in the output of the logstash.
JSON for creating index template:
{
"index_patterns": ["index2-*"],
"template": {
"settings": {
"number_of_shards": 1
},
"mappings": {
"properties": {
"timestamp": {
"type": "date"
},
"level": {
"type": "keyword"
},
"mdc.audit_id": {
"type": "text",
"index": false
},
"mdc.status": {
"type": "keyword"
},
"mdc.instance_id": {
"type": "text",
"index": false
},
"mdc.url": {
"type": "text"
},
"mdc.executionTime": {
"type": "integer"
},
"thread": {
"type": "keyword",
"index": false
},
"logger": {
"type": "text",
"index": false
},
"message": {
"type": "keyword"
},
"exception": {
"type": "text"
}
}
}
},
"priority": 51,
"version": 1,
"_meta": {
"description": "my custom"
}
}
In the logstash I have the following:
input {
redis {
host => "XXX.1X.X.X"
key => "app_logs"
data_type => "list"
}
}
output {
elasticsearch {
hosts => ["eslocalhost:9200"]
index => "index2_template"
#manage_template => true
template_name => "index2_template"
template => "index2_template"
}
}