apiVersion: v1
kind: ConfigMap
metadata:
  name: logstash-discrepancy-cm-sql
data:
  logstash.conf: |-
    input {
        jdbc {
        type => "solumina_discrepancy"
        jdbc_driver_library => "/opt/logstash/driver/mssql-jdbc-7.4.1.jre8.jar"
        jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
        jdbc_connection_string => "CONN_STRING"
        jdbc_user => "MT_CONPOOL_USER"
        jdbc_password => "MT_CONPOOL_USER"
        jdbc_fetch_size => 1000
        schedule => "*/5 * * * *"
        statement => "select distinct concat(d.disc_id, concat('$', d.disc_line_no)) as rid_obj, concat('', d.rowid) as temp_rid, d.disc_id, d.disc_line_no, d.part_no, d.PART_CHG, c1.work_center as reject_work_center,o1.order_no as reject_order_no, d.security_group from sfqa_disc_item d left outer join sffnd_work_center_def c1 on c1.center_id=d.reject_center_id left outer join sfwid_order_desc o1 on o1.order_id=d.order_id where (DATEADD(second, datediff(second, getdate(), getutcdate()), d.time_stamp) >= :sql_last_value)"
        clean_run => false
        record_last_run => true
        sql_log_level => debug
        last_run_metadata_path => "/opt/logstash/lastrun/.logstash_jdbc_last_run_discrepancy"
        connection_retry_attempts_wait_time => 30
        connection_retry_attempts => 99999999
        }
    }
    filter {
      if[type] == "solumina_discrepancy" {
        mutate {
          replace => { "type" => "discrepancy" }
          }
      }
    }
    output {
      elasticsearch {
        hosts => "https://--es--:443"
        index => "<discrepancysearch>" 
        document_id => "%{rid_obj}"
      }
    }

  logstash.yml: |-
    http.host: "0.0.0.0"
    path.config: /usr/share/logstash/pipeline
    xpack.monitoring.enabled: false
