使用logstash排序弹性搜索字段

时间:2020-02-18 06:29:41

标签: elasticsearch logstash logstash-configuration

嗨,下面是我的配置,我正在尝试使用Logstash将数据从MSSQL索引到Elasticsearch,但是字段排列不是预期的方式

input {
    jdbc {
    jdbc_driver_library => "D:\Users\mmurugesan\Desktop\driver\mssql-jdbc-7.4.1.jre12-shaded.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://EC2AMAZ-J90JR4A\SQLEXPRESS:1433;databaseName=xxxx;"
    jdbc_user => "xxx"
    jdbc_password => "xxxx"
    jdbc_paging_enabled => true
    tracking_column => modified_date
    use_column_value => true
    clean_run => true
    tracking_column_type => "timestamp"
    schedule => "*/1 * * * *"
    statement => "Select pl.Policyholdername,pl.Age,pl.Dob,pl.Client_Address,cl.claimnumber,cl.claimtype,cl.is_active,cl.Modified_date from claim cl
    inner join Policy pl on pl.Policynumber=cl.policynumber
    where cl.Modified_date >:sql_last_value"
    last_run_metadata_path => "D:\Users\mmurugesan\Desktop\logstash-7.5.2\jdbc_lastrun\jdbc_last_run.txt"
    jdbc_default_timezone => "UTC" 
    }
    }
    filter {
    if [is_active] {
            mutate {    
                add_field => {
                    "[@metadata][elasticsearch_action]" => "index"
                }
            }
            mutate {
                remove_field => [ "is_active","@version","@timestamp" ]
            }

        } else {
            mutate {    
                add_field => {
                    "[@metadata][elasticsearch_action]" => "delete"
                }
            }
            mutate {
                remove_field => [ "is_active","@version","@timestamp" ]
            }
        } 

    }
    output {
    elasticsearch {
    hosts => "xxx"
    user => "xxx"
    password => "xxx"
    index => "duckcreek"
    action => "%{[@metadata][elasticsearch_action]}"
    document_type => "_doc"
    document_id => "%{claimnumber}"

    }
    stdout { codec => rubydebug }
    }

将数据索引到弹性搜索中的弹性搜索字段中后,未按预期的方式附上屏幕截图以供参考。

enter image description here

是否可以使用logstash在弹性搜索中安排字段设置?

0 个答案:

没有答案