๐Ÿ“ฆ juspay / hyperswitch

๐Ÿ“„ vector.yaml ยท 297 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297acknowledgements:
  enabled: true


api:
  enabled: true
  address: 0.0.0.0:8686

sources:
  kafka_tx_events:
    type: kafka
    bootstrap_servers: kafka0:29092
    group_id: sessionizer
    topics:
      - hyperswitch-payment-attempt-events
      - hyperswitch-payment-intent-events
      - hyperswitch-refund-events
      - hyperswitch-dispute-events
      - hyperswitch-payout-events
    decoding:
      codec: json
  
  revenue_events:
    type: kafka
    bootstrap_servers: kafka0:29092
    group_id: hyperswitch_revenue_recovery
    topics:
      - hyperswitch-revenue-recovery-events
    decoding:
      codec: json

  sessionized_kafka_tx_events:
    type: kafka
    bootstrap_servers: kafka0:29092
    group_id: sessionizer
    topics:
      - ^sessionizer
    decoding:
      codec: json

  app_logs:
    type: docker_logs
    include_labels:
      - "logs=promtail"

  vector_metrics:
    type: internal_metrics

  node_metrics:
    type: host_metrics

  sdk_source:
    type: http_server
    address: 0.0.0.0:3103
    encoding: json

transforms:
  events_create_ts:
    inputs:
    - kafka_tx_events
    source: |-
      .timestamp = from_unix_timestamp(.created_at, unit: "seconds") ?? now()
      ."@timestamp" = from_unix_timestamp(.created_at, unit: "seconds") ?? now()
    type: remap

  plus_1_events:
    type: filter
    inputs:
      - events_create_ts
      - sessionized_events_create_ts
    condition: ".sign_flag == 1"

  hs_server_logs:
    type: filter
    inputs:
      - app_logs
    condition: '.labels."com.docker.compose.service" == "hyperswitch-server"'

  parsed_hs_server_logs:
    type: remap
    inputs:
      - app_logs
    source: |-
      .message = parse_json!(.message)

  sessionized_events_create_ts:
    type: remap
    inputs:
    - sessionized_kafka_tx_events
    source: |-
      .timestamp = from_unix_timestamp(.created_at, unit: "milliseconds") ?? now()
      ."@timestamp" = from_unix_timestamp(.created_at, unit: "milliseconds") ?? now()

  sdk_transformed:
    type: throttle
    inputs:
      - sdk_source
    key_field: "{{ .payment_id }}{{ .merchant_id }}"
    threshold: 1000
    window_secs: 60

  

sinks:
  opensearch_events_1:
    type: elasticsearch
    inputs:
      - plus_1_events
    endpoints:
      - "https://opensearch:9200"
    id_key: message_key
    api_version: v7
    tls:
      verify_certificate: false
      verify_hostname: false
    auth:
      strategy: basic
      user: admin
      password: 0penS3arc#
    encoding:
      except_fields:
        - message_key
        - offset
        - partition
        - topic
        - clickhouse_database
        - last_synced
        - sign_flag
    bulk:
      index: "vector-{{ .topic }}"

  opensearch_events_2:
    type: elasticsearch
    inputs:
      - plus_1_events
    endpoints:
      - "https://opensearch:9200"
    id_key: message_key
    api_version: v7
    tls:
      verify_certificate: false
      verify_hostname: false
    auth:
      strategy: basic
      user: admin
      password: 0penS3arc#
    encoding:
      except_fields:
        - message_key
        - offset
        - partition
        - topic
        - clickhouse_database
        - last_synced
        - sign_flag
    bulk:
      # Add a date suffixed index for better grouping
      index: "vector-{{ .topic }}-%Y-%m-%d"

  opensearch_events_3:
    type: elasticsearch
    inputs:
      - plus_1_events
    endpoints:
      - "https://opensearch:9200"
    id_key: message_key
    api_version: v7
    tls:
      verify_certificate: false
      verify_hostname: false
    auth:
      strategy: basic
      user: admin
      password: 0penS3arc#
    encoding:
      except_fields:
        - message_key
        - offset
        - partition
        - topic
        - clickhouse_database
        - last_synced
        - sign_flag
    bulk:
      index: "{{ .topic }}"

  opensearch_logs:
    type: elasticsearch
    inputs:
      - parsed_hs_server_logs
    endpoints:
      - "https://opensearch:9200"
    api_version: v7
    tls:
      verify_certificate: false
      verify_hostname: false
    auth:
      strategy: basic
      user: admin
      password: 0penS3arc#
    bulk:
      # Add a date suffixed index for better grouping
      # index: "vector-{{ .topic }}-%Y-%m-%d"
      index: "logs-{{ .container_name }}-%Y-%m-%d"

  log_events:
    type: loki
    inputs:
      - kafka_tx_events
      - sessionized_kafka_tx_events
    endpoint: http://loki:3100
    labels:
      source: vector
      topic: "{{ .topic }}"
      job: kafka
    encoding:
      codec: json

  log_app_loki:
    type: loki
    inputs:
      - parsed_hs_server_logs
    endpoint: http://loki:3100
    labels:
      source: vector
      job: app_logs
      container: "{{ .container_name }}"
      stream: "{{ .stream }}"
    encoding:
      codec: json

  metrics:
    type: prometheus_exporter
    inputs:
      - vector_metrics
      - node_metrics

  sdk_sink:
    type: kafka
    encoding:
      codec: json
      except_fields:
        - "path"
        - "source_type"
    inputs:
      - "sdk_transformed"
    bootstrap_servers: kafka0:29092
    topic: hyper-sdk-logs
    key_field: ".merchant_id"

  revenue_recovery_s3:
    type: aws_s3
    inputs:
      - revenue_events
    bucket: BUCKET_NAME
    region: us-east-1
    content_type: json
    batch:
      max_events: 1000
      timeout_secs: 86400
    encoding:
      codec: csv
      csv:
        fields:
          - merchant_id
          - invoice_id
          - invoice_amount
          - invoice_currency
          - invoice_due_date
          - invoice_date
          - billing_city
          - billing_country
          - billing_state
          - attempt_id
          - attempt_amount
          - attempt_currency
          - attempt_status
          - pg_error_code
          - network_advice_code
          - network_error_code
          - first_pg_error_code
          - first_network_advice_code
          - first_network_error_code
          - attempt_created_at
          - payment_method_type
          - payment_method_subtype
          - card_network
          - card_issuer
          - retry_count
          - payment_gateway
    key_prefix: "{{ .merchant_id }}/"
    timezone: "Europe/London"

    filename_append_uuid: false
    filename_time_format: "%Y/%m/%+"
    filename_extension: csv