apiVersion: v1
kind: ConfigMap
metadata:
  name: logstash-order-cm-sql
data:
  logstash.conf: |-
    input {
           jdbc {
               type => "solumina_order"
               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(a.order_id, concat('$',b.oper_key)) as rid_obj, concat('', b.rowid) as temp_rid, a.order_no, a.order_id, b.oper_key, b.oper_no, a.part_no, c.work_center as asgnd_work_center, a.security_group from sfwid_order_desc a, sfwid_oper_desc b left outer join sffnd_work_center_def c on b.asgnd_location_id = c.location_id and b.asgnd_department_id = c.department_id and b.asgnd_center_id = c.center_id where a.order_id=b.order_id and b.step_key = -1 and (DATEADD(second, datediff(second, getdate(), getutcdate()), b.time_stamp) >= :sql_last_value OR DATEADD(second, datediff(second, getdate(), getutcdate()), a.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_order"
               connection_retry_attempts_wait_time => 30
           connection_retry_attempts => 99999999
             }
       }
       filter {
           if[type] == "solumina_order" {
             mutate {
               replace => { "type" => "order" }
               }
           }
       }
       output {
           elasticsearch {
               hosts => "https://--es--:443"
               index => "<solumina-ordersearch>"
               document_id => "%{rid_obj}"
           }
       }

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