Mysterious288
Mysterious288

Reputation: 447

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.

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

Upvotes: 0

Views: 564

Answers (1)

Mysterious288
Mysterious288

Reputation: 447

Well, I figured this out, it's mandatory to send the column name in the column_mapping even though if its primary key and auto-incremented, if you login with some other SQL credential it will give you an error, however, if you login with the same details used at the time of table creation it works.

Upvotes: 0

Related Questions