【问题标题】:SQL Server Sync with Elasticsearch through Logstash - retransfer does not happensSQL Server 通过 Logstash 与 Elasticsearch 同步 - 不会发生重新传输
【发布时间】:2018-09-18 15:51:32
【问题描述】:

背景: 我们正在做一个将 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 弹性搜索版本:6.3.1

提前致谢

【问题讨论】:

    标签: elasticsearch logstash logstash-jdbc


    【解决方案1】:

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

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

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

    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}"
      }
    }
    

    输入部分没有变化。

    感谢您的支持。

    【讨论】:

    • 我发现您的初始配置文件和答案之间没有任何变化。您是否将索引更改为小写,或者 document_id 是“%{id}”?
    猜你喜欢
    • 1970-01-01
    • 2021-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多