使用自定义设置的 logstash 创建索引

使用自定义设置的 logstash 创建索引

我正在尝试从 Logstash (7.3.1) 创建一个新的 Elasticsearch (7.0.1) 索引,但是当我将模板文件与我的设置一起放入时它不起作用(即使没有我的模板设置它也能很好地工作)。

我的配置文件:

input {    
    file {
        path => "/home/temp/*.*"
        start_position => "beginning"
        type => "product"
    }

    jdbc {
        type => "product"
        jdbc_connection_string => "jdbc:postgresql://postgres_b2b:5432/b2b"
        jdbc_user => "***"
        jdbc_password => "***"
        jdbc_driver_class => "org.postgresql.Driver"
        schedule => "* * * * *"
        statement => "my query"
        tracking_column_type => "timestamp"
    }

}

filter {
    if [type] == "product" { 
        aggregate {
            task_id => "%{product_id}"
            code => "mappings"
            push_previous_map_as_event => true
            timeout => 3
        }
    }    
}

output {
    if [type] == "product" { 
        elasticsearch {
             index => "product"
             document_type => "_doc"
             document_id => "%{product_id}"
             manage_template => true                             
             template => "/home/temp/template.json"
             template_name => "template"
             template_overwrite => true
        }
    }
}

模板文件:

{
    "settings": {
        "analysis": {
            "analyzer": {
                "folding": {
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ]
                }
            }
        }
    },
    "mappings": {
        "test": {
            "properties": {
                "text": {
                    "type": "string",
                    "fields": {
                        "folded": {
                            "type": "string",
                            "analyzer": "folding"
                        }
                    }
                }
            }
        }
    }
}

但是我在启动应用程序时收到错误:

 logstashb2b         |   output {
    logstashb2b      |     elasticsearch {
    logstashb2b      |       # This setting must be a path
    logstashb2b      |       # File does not exist or cannot be opened /home/temp/template.json
    logstashb2b      |       template => "/home/temp/template.json"
    logstashb2b      |       ...
    logstashb2b      |     }
    logstashb2b      |   }
    logstashb2b      | [2019-10-01T09:37:05,324][ERROR][logstash.agent           

错误是:

] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Something is wrong with your configuration.", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/config/mixin.rb:87:in `config_init'", "/usr/share/logstash/logstash-core/lib/logstash/outputs/base.rb:60:in `initialize'", "org/logstash/config/ir/compiler/OutputStrategyExt.java:232:in `initialize'", "org/logstash/config/ir/compiler/OutputDelegatorExt.java:48:in `initialize'", "org/logstash/config/ir/compiler/OutputDelegatorExt.java:30:in `initialize'", "org/logstash/plugins/PluginFactoryExt.java:242:in `plugin'", "org/logstash/plugins/PluginFactoryExt.java:140:in `buildOutput'", "org/logstash/execution/JavaBasePipelineExt.java:50:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:24:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:36:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:325:in `block in converge_state'"]}

重要的是要说我的模板文件/目录具有权限777,所以我相信该文件可以被打开。

有什么提示,或者我的配置文件有问题吗?

相关内容