简体   繁体   English

用于自动递增列的 Fluentd sql 输出插件配置

[英]Fluentd sql output plugin configuration for auto incremented column

I have a fluentd configuration that pulls data from the file and pushes to the SQL server however there is a primary key with the auto-incremented column, so, in my fluentd configuration if I don't mention that column it throws an error saying that the field is missing and if I include the column in the configuration it gives identity error, in below configuration "Id" is the primary and auto-incremented column, also let me know if adapter "sqlserver" is the right thing to use.我有一个 fluentd 配置,它从文件中提取数据并推送到 SQL 服务器,但是有一个带有自动递增列的主键,因此,在我的 fluentd 配置中,如果我不提及该列,它会抛出一个错误说该字段丢失,如果我在配置中包含该列,则会出现标识错误,在下面的配置中,“Id”是主要且自动递增的列,还请告诉我适配器“sqlserver”是否适合使用。

<filter record.**>
      @type record_transformer
      enable_ruby  true
      <record>
        Id ${id}
      </record>
      <record>
        timestamp ${time}
      </record>
    </filter>

    <filter record.**>
      @type stdout
    </filter>

    <match record.**> 
        
        @type sql
        host myhost
        username myuser
        password mypassword
        database mydb
        adapter sqlserver

        <table>
          table simple_table
          column_mapping 'Id:Id,timestamp:timestamp'
        </table>
        
        flush_interval 1s
        # disable_retry_limit
        # num_threads 8
        # slow_flush_log_threshold 40.0
    </match>

好吧,我发现了这一点,即使它的主键和自动递增,也必须在 column_mapping 中发送列名,如果您使用其他一些 SQL 凭据登录,它将给您一个错误,但是,如果您使用在创建表时使用的相同细节可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM