0

背景: 我们正在做一个将 SQL Server 错误日志数据同步到 elasticsearch(ES) 的 POC,以便在 kibana 中引入仪表板。我使用带有jdbc输入插件的Logstash将sql server表数据移动到(ES),它成功了。在日志表中大约有 5000 条记录,每条记录都移至 ES。

问题陈述: 为了测试,我从 ES 中删除了之前由 Logstash 同步的索引,然后我使用相同的输入配置文件再次运行了 Logstash。但是没有记录被移动如果我向 SQL Server 表中添加一条新记录,这就是反映,但旧记录 (5000) 没有更新。

配置 下面是我用来同步的配置文件

input {
  jdbc {
    #https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#plugins-inputs-jdbc-record_last_run
    jdbc_connection_string => "jdbc:sqlserver://localhost:40020;database=application;user=development;password=XXX$"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"    

    jdbc_user => nil
        # The path to our downloaded jdbc driver
    jdbc_driver_library => "C:\Program Files (x86)\sqljdbc6.2\enu\sqljdbc4-3.0.jar"
        # The name of the driver class for SqlServer
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
        # Query for testing purpose     
    schedule => "* * * * *"
    last_run_metadata_path => "C:\Software\ElasticSearch\logstash-6.4.0\.logstash_jdbc_last_run"
    record_last_run => true
    clean_run => true
    statement => "  select * from Log"  

  }
}

output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "application_log"
    #document_id is a unique id, this has to be provided during syn, else we may get duplicate entry in ElasticSearch index.
    document_id => "%{Id}"
  }
}

请帮我解释一下出了什么问题。

Logstash 版本:6.4.0 Elasticsearch 版本:6.3.1

提前致谢

4

1 回答 1

0

我发现并解决了这个问题。

我发现的问题是每个字段都区分大小写,它只接受小写字母。

以下是我所做的更改,对我来说效果很好。

output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "application_log"
    #document_id is a unique id, this has to be provided during syn, else we may get duplicate entry in ElasticSearch index.
    document_id => "%{Id}"
  }
}

并且输入部分没有变化。

谢谢你的支持。

于 2018-09-28T08:12:38.777 回答