# docker/fluentd/conf/fluent.conf

<source>
  @type kafka_group

  brokers kafka0:29092
  consumer_group fluentd
  topics hyperswitch-payment-intent-events,hyperswitch-payment-attempt-events,hyperswitch-refund-events,hyperswitch-dispute-events
  add_headers false
  add_prefix topic
  retry_emit_limit 2
</source>

<filter topic.hyperswitch-payment-intent-events*>
  @type record_transformer
  renew_time_key created_at
</filter>

<filter topic.hyperswitch-payment-attempt-events*>
  @type record_transformer
  renew_time_key created_at
</filter>

<filter topic.hyperswitch-refund-events*>
  @type record_transformer
  renew_time_key created_at
</filter>


<filter topic.hyperswitch-dispute-events*>
  @type record_transformer
  renew_time_key created_at
</filter>

<match topic.hyperswitch-payment-intent-events*>
  @type copy

  <store>
    @type stdout
  </store>

  <store>
    @type opensearch
    host opensearch
    port 9200
    scheme https
    index_name hyperswitch-payment-intent-events
    id_key payment_id
    user admin
    password '0penS3arc#'
    ssl_verify false
    prefer_oj_serializer true
    reload_on_failure true
    reload_connections false
    request_timeout 120s
    bulk_message_request_threshold 10MB
    include_timestamp true
  </store>

  <store>
    @type opensearch
    host opensearch
    port 9200
    scheme https
    index_name fluentd-hyperswitch-payment-intent-events-%Y-%m-%d
    id_key payment_id
    user admin
    password '0penS3arc#'
    ssl_verify false
    prefer_oj_serializer true
    reload_on_failure true
    reload_connections false
    request_timeout 120s
    bulk_message_request_threshold 10MB
    include_timestamp true
    <buffer tag, time>
      timekey 10s
      timekey_wait 10s
    </buffer>
  </store>
</match>

<match topic.hyperswitch-payment-attempt-events*>
  @type copy

  <store>
    @type stdout
  </store>

  <store>
    @type opensearch
    host opensearch
    port 9200
    scheme https
    index_name hyperswitch-payment-attempt-events
    id_key attempt_id
    user admin
    password '0penS3arc#'
    ssl_verify false
    prefer_oj_serializer true
    reload_on_failure true
    reload_connections false
    request_timeout 120s
    bulk_message_request_threshold 10MB
    include_timestamp true
  </store>

  <store>
    @type opensearch
    host opensearch
    port 9200
    scheme https
    index_name fluentd-hyperswitch-payment-attempt-events-%Y-%m-%d
    id_key attempt_id
    user admin
    password '0penS3arc#'
    ssl_verify false
    prefer_oj_serializer true
    reload_on_failure true
    reload_connections false
    request_timeout 120s
    bulk_message_request_threshold 10MB
    include_timestamp true
    <buffer tag, time>
      timekey 10s
      timekey_wait 10s
    </buffer>
  </store>
</match>

<match topic.hyperswitch-refund-events*>
  @type copy

  <store>
    @type stdout
  </store>

  <store>
    @type opensearch
    host opensearch
    port 9200
    scheme https
    index_name hyperswitch-refund-events
    id_key refund_id
    user admin
    password '0penS3arc#'
    ssl_verify false
    prefer_oj_serializer true
    reload_on_failure true
    reload_connections false
    request_timeout 120s
    bulk_message_request_threshold 10MB
    include_timestamp true
  </store>

  <store>
    @type opensearch
    host opensearch
    port 9200
    scheme https
    index_name fluentd-hyperswitch-refund-events-%Y-%m-%d
    id_key refund_id
    user admin
    password '0penS3arc#'
    ssl_verify false
    prefer_oj_serializer true
    reload_on_failure true
    reload_connections false
    request_timeout 120s
    bulk_message_request_threshold 10MB
    include_timestamp true
    <buffer tag, time>
      timekey 10s
      timekey_wait 10s
    </buffer>
  </store>
</match>

<match topic.hyperswitch-dispute-events*>
  @type copy

  <store>
    @type stdout
  </store>

  <store>
    @type opensearch
    host opensearch
    port 9200
    scheme https
    index_name hyperswitch-dispute-events
    id_key dispute_id
    user admin
    password '0penS3arc#'
    ssl_verify false
    prefer_oj_serializer true
    reload_on_failure true
    reload_connections false
    request_timeout 120s
    bulk_message_request_threshold 10MB
    include_timestamp true
  </store>

  <store>
    @type opensearch
    host opensearch
    port 9200
    scheme https
    index_name fluentd-hyperswitch-dispute-events-%Y-%m-%d
    id_key dispute_id
    user admin
    password '0penS3arc#'
    ssl_verify false
    prefer_oj_serializer true
    reload_on_failure true
    reload_connections false
    request_timeout 120s
    bulk_message_request_threshold 10MB
    include_timestamp true
    <buffer tag, time>
      timekey 10s
      timekey_wait 10s
    </buffer>
  </store>
</match>