[英]How to push data to an existing index(Elastic Search) from Logstash?
elasticsearch {
hosts => "elasticsearch:9200"
index => "logmessages"
document_type => "message"
}
I want to create an Index with certain mappings in Elasticsearch and then point Logstash to that Index to store data.我想在 Elasticsearch 中创建具有某些映射的索引,然后将 Logstash 指向该索引以存储数据。 How do I do it?我该怎么做? It seems to work fine when Logstash pushes data to a non-existing Index.当 Logstash 将数据推送到不存在的索引时,它似乎工作正常。
You just need to create an index with required mappings then pass index name as follows:您只需要使用所需的映射创建一个索引,然后按如下方式传递索引名称:
output {
elasticsearch {
hosts => ["elastic_search_server_ip:port"] #localhost:9200
action => "index"
index => "your_existing_index_name"}
# How to create index with mappings
index_mapping = {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
'mappings': {'properties': {
'id': {'type': 'long'},
"location": {
"type": "geo_point"
}
}}}
resp = es.indices.create(index = "test", body = index_mapping, ignore = 400)
Note: Your index should contain all the columns/fields.注意:您的索引应包含所有列/字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.