-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathamq-streams-template.yml.j2
556 lines (547 loc) · 21.7 KB
/
amq-streams-template.yml.j2
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
kind: Template
apiVersion: v1
metadata:
name: spring-music-cdc
annotations:
description: Template including AMQ Streams and Kafka Connect
parameters:
- name: KAFKA_REPLICA_COUNT
description: The number of replicas for Kafka/Kafka Connect/Zookeeper
value: "3"
- name: RH_SSO_REALM
description: The realm within RH-SSO for authentication
value: spring-music-cdc
required: true
- name: RH_SSO_SERVER_ADDRESS
description: The address of the RH-SSO instance
value: "https://secure-sso.{{ proj_nm_demo }}.svc.cluster.local:8443"
required: true
objects:
- kind: Secret
apiVersion: v1
type: Opaque
metadata:
name: broker-oauth-secret
namespace: "{{ proj_nm_demo }}"
labels:
app: spring-music-cdc
template: spring-music-cdc
data:
secret: "{{ rh_sso.kafka_broker_secret | b64encode }}"
- kind: Secret
apiVersion: v1
type: Opaque
metadata:
name: connect-oauth-secret
namespace: "{{ proj_nm_demo }}"
labels:
app: spring-music-cdc
template: spring-music-cdc
data:
secret: "{{ rh_sso.kafka_connect_secret | b64encode }}"
- kind: Secret
apiVersion: v1
type: Opaque
metadata:
name: bridge-oauth-secret
namespace: "{{ proj_nm_demo }}"
labels:
app: spring-music-cdc
template: spring-music-cdc
data:
secret: "{{ rh_sso.kafka_bridge_secret | b64encode }}"
- kind: Kafka
apiVersion: kafka.strimzi.io/v1beta1
metadata:
name: db-events
namespace: "{{ proj_nm_demo }}"
labels:
app: spring-music-cdc
template: spring-music-cdc
spec:
kafka:
replicas: {{ '${{' }}KAFKA_REPLICA_COUNT}}
listeners:
- name: plain
port: 9092
type: internal
tls: false
- name: tls
port: 9093
type: internal
tls: true
authentication:
type: oauth
clientId: kafka-broker
clientSecret:
secretName: broker-oauth-secret
key: secret
validIssuerUri: ${RH_SSO_SERVER_ADDRESS}/auth/realms/${RH_SSO_REALM}
introspectionEndpointUri: ${RH_SSO_SERVER_ADDRESS}/auth/realms/${RH_SSO_REALM}/protocol/openid-connect/token/introspect
# jwksEndpointUri: ${RH_SSO_SERVER_ADDRESS}/auth/realms/${RH_SSO_REALM}/protocol/openid-connect/certs
userNameClaim: preferred_username
tlsTrustedCertificates:
- secretName: {{ ca_truststore_secret_name }}
certificate: xpaas.crt
jvmOptions:
gcLoggingEnabled: false
config:
auto.create.topics.enable: "true"
num.partitions: 1
offsets.topic.replication.factor: {{ '${{' }}KAFKA_REPLICA_COUNT}}
default.replication.factor: {{ '${{' }}KAFKA_REPLICA_COUNT}}
transaction.state.log.replication.factor: {{ '${{' }}KAFKA_REPLICA_COUNT}}
transaction.state.log.min.isr: 2
storage:
type: persistent-claim
size: 100Gi
deleteClaim: true
template:
statefulset:
metadata:
labels:
app.kubernetes.io/part-of: spring-music-cdc
app: spring-music-cdc
template: spring-music-cdc
annotations:
app.openshift.io/connects-to: db-events-zookeeper,sso
metrics:
# Inspired by config from Kafka 2.0.0 example rules:
# https://github.com/prometheus/jmx_exporter/blob/master/example_configs/kafka-2_0_0.yml
lowercaseOutputName: true
rules:
# Special cases and very specific rules
- pattern: kafka.server<type=(.+), name=(.+), clientId=(.+), topic=(.+), partition=(.*)><>Value
name: kafka_server_$1_$2
type: GAUGE
labels:
clientId: "$3"
topic: "$4"
partition: "$5"
- pattern: kafka.server<type=(.+), name=(.+), clientId=(.+), brokerHost=(.+), brokerPort=(.+)><>Value
name: kafka_server_$1_$2
type: GAUGE
labels:
clientId: "$3"
broker: "$4:$5"
- pattern: kafka.server<type=(.+), cipher=(.+), protocol=(.+), listener=(.+), networkProcessor=(.+)><>connections
name: kafka_server_$1_connections_tls_info
type: GAUGE
labels:
listener: "$2"
networkProcessor: "$3"
protocol: "$4"
cipher: "$5"
- pattern: kafka.server<type=(.+), clientSoftwareName=(.+), clientSoftwareVersion=(.+), listener=(.+), networkProcessor=(.+)><>connections
name: kafka_server_$1_connections_software
type: GAUGE
labels:
clientSoftwareName: "$2"
clientSoftwareVersion: "$3"
listener: "$4"
networkProcessor: "$5"
- pattern: "kafka.server<type=(.+), listener=(.+), networkProcessor=(.+)><>(.+):"
name: kafka_server_$1_$4
type: GAUGE
labels:
listener: "$2"
networkProcessor: "$3"
- pattern: kafka.server<type=(.+), listener=(.+), networkProcessor=(.+)><>(.+)
name: kafka_server_$1_$4
type: GAUGE
labels:
listener: "$2"
networkProcessor: "$3"
# Some percent metrics use MeanRate attribute
# Ex) kafka.server<type=(KafkaRequestHandlerPool), name=(RequestHandlerAvgIdlePercent)><>MeanRate
- pattern: kafka.(\w+)<type=(.+), name=(.+)Percent\w*><>MeanRate
name: kafka_$1_$2_$3_percent
type: GAUGE
# Generic gauges for percents
- pattern: kafka.(\w+)<type=(.+), name=(.+)Percent\w*><>Value
name: kafka_$1_$2_$3_percent
type: GAUGE
- pattern: kafka.(\w+)<type=(.+), name=(.+)Percent\w*, (.+)=(.+)><>Value
name: kafka_$1_$2_$3_percent
type: GAUGE
labels:
"$4": "$5"
# Generic per-second counters with 0-2 key/value pairs
- pattern: kafka.(\w+)<type=(.+), name=(.+)PerSec\w*, (.+)=(.+), (.+)=(.+)><>Count
name: kafka_$1_$2_$3_total
type: COUNTER
labels:
"$4": "$5"
"$6": "$7"
- pattern: kafka.(\w+)<type=(.+), name=(.+)PerSec\w*, (.+)=(.+)><>Count
name: kafka_$1_$2_$3_total
type: COUNTER
labels:
"$4": "$5"
- pattern: kafka.(\w+)<type=(.+), name=(.+)PerSec\w*><>Count
name: kafka_$1_$2_$3_total
type: COUNTER
# Generic gauges with 0-2 key/value pairs
- pattern: kafka.(\w+)<type=(.+), name=(.+), (.+)=(.+), (.+)=(.+)><>Value
name: kafka_$1_$2_$3
type: GAUGE
labels:
"$4": "$5"
"$6": "$7"
- pattern: kafka.(\w+)<type=(.+), name=(.+), (.+)=(.+)><>Value
name: kafka_$1_$2_$3
type: GAUGE
labels:
"$4": "$5"
- pattern: kafka.(\w+)<type=(.+), name=(.+)><>Value
name: kafka_$1_$2_$3
type: GAUGE
# Emulate Prometheus 'Summary' metrics for the exported 'Histogram's.
# Note that these are missing the '_sum' metric!
- pattern: kafka.(\w+)<type=(.+), name=(.+), (.+)=(.+), (.+)=(.+)><>Count
name: kafka_$1_$2_$3_count
type: COUNTER
labels:
"$4": "$5"
"$6": "$7"
- pattern: kafka.(\w+)<type=(.+), name=(.+), (.+)=(.*), (.+)=(.+)><>(\d+)thPercentile
name: kafka_$1_$2_$3
type: GAUGE
labels:
"$4": "$5"
"$6": "$7"
quantile: "0.$8"
- pattern: kafka.(\w+)<type=(.+), name=(.+), (.+)=(.+)><>Count
name: kafka_$1_$2_$3_count
type: COUNTER
labels:
"$4": "$5"
- pattern: kafka.(\w+)<type=(.+), name=(.+), (.+)=(.*)><>(\d+)thPercentile
name: kafka_$1_$2_$3
type: GAUGE
labels:
"$4": "$5"
quantile: "0.$6"
- pattern: kafka.(\w+)<type=(.+), name=(.+)><>Count
name: kafka_$1_$2_$3_count
type: COUNTER
- pattern: kafka.(\w+)<type=(.+), name=(.+)><>(\d+)thPercentile
name: kafka_$1_$2_$3
type: GAUGE
labels:
quantile: "0.$4"
zookeeper:
replicas: {{ '${{' }}KAFKA_REPLICA_COUNT}}
storage:
type: persistent-claim
size: 100Gi
deleteClaim: true
template:
statefulset:
metadata:
labels:
app.kubernetes.io/part-of: spring-music-cdc
app: spring-music-cdc
template: spring-music-cdc
annotations:
app.openshift.io/connects-to: sso
metrics:
# Inspired by Zookeeper rules
# https://github.com/prometheus/jmx_exporter/blob/master/example_configs/zookeeper.yaml
lowercaseOutputName: true
rules:
# replicated Zookeeper
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+)><>(\\w+)"
name: "zookeeper_$2"
type: GAUGE
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+)><>(\\w+)"
name: "zookeeper_$3"
type: GAUGE
labels:
replicaId: "$2"
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+), name2=(\\w+)><>(Packets\\w+)"
name: "zookeeper_$4"
type: COUNTER
labels:
replicaId: "$2"
memberType: "$3"
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+), name2=(\\w+)><>(\\w+)"
name: "zookeeper_$4"
type: GAUGE
labels:
replicaId: "$2"
memberType: "$3"
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+), name2=(\\w+), name3=(\\w+)><>(\\w+)"
name: "zookeeper_$4_$5"
type: GAUGE
labels:
replicaId: "$2"
memberType: "$3"
entityOperator:
topicOperator: {}
userOperator: {}
kafkaExporter:
topicRegex: ".*"
groupRegex: ".*"
- kind: KafkaConnect
apiVersion: kafka.strimzi.io/v1beta1
metadata:
name: db-events
namespace: "{{ proj_nm_demo }}"
labels:
app: spring-music-cdc
template: spring-music-cdc
annotations:
strimzi.io/use-connector-resources: "true"
spec:
replicas: {{ '${{' }}KAFKA_REPLICA_COUNT}}
image: "quay.io/edeandrea/kafka-connect-debezium-mysql:latest"
bootstrapServers: "db-events-kafka-bootstrap:9093"
jvmOptions:
gcLoggingEnabled: false
config:
group.id: spring-music-db
offset.storage.topic: spring-music-db-offsets
config.storage.topic: spring-music-db-configs
status.storage.topic: spring-music-db-status
config.storage.replication.factor: {{ '${{' }}KAFKA_REPLICA_COUNT}}
offset.storage.replication.factor: {{ '${{' }}KAFKA_REPLICA_COUNT}}
status.storage.replication.factor: {{ '${{' }}KAFKA_REPLICA_COUNT}}
config.providers: file
config.providers.file.class: org.apache.kafka.common.config.provider.FileConfigProvider
authentication:
type: oauth
tokenEndpointUri: ${RH_SSO_SERVER_ADDRESS}/auth/realms/${RH_SSO_REALM}/protocol/openid-connect/token
clientId: kafka-connect
clientSecret:
secretName: connect-oauth-secret
key: secret
tlsTrustedCertificates:
- secretName: {{ ca_truststore_secret_name }}
certificate: xpaas.crt
tls:
trustedCertificates:
- certificate: ca.crt
secretName: db-events-cluster-ca-cert
externalConfiguration:
volumes:
- name: connector-config
secret:
secretName: summit-lab-spring-music-db-connector-creds
template:
deployment:
metadata:
labels:
app: spring-music-cdc
app.kubernetes.io/part-of: spring-music-cdc
template: spring-music-cdc
annotations:
app.openshift.io/connects-to: "db-events-kafka,summit-lab-spring-music-db,sso"
metrics:
# Inspired by kafka-connect rules
# https://github.com/prometheus/jmx_exporter/blob/master/example_configs/kafka-connect.yml
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
#kafka.connect:type=app-info,client-id="{clientid}"
#kafka.consumer:type=app-info,client-id="{clientid}"
#kafka.producer:type=app-info,client-id="{clientid}"
- pattern: 'kafka.(.+)<type=app-info, client-id=(.+)><>start-time-ms'
name: kafka_$1_start_time_seconds
labels:
clientId: "$2"
help: "Kafka $1 JMX metric start time seconds"
type: GAUGE
valueFactor: 0.001
- pattern: 'kafka.(.+)<type=app-info, client-id=(.+)><>(commit-id|version): (.+)'
name: kafka_$1_$3_info
value: 1
labels:
clientId: "$2"
$3: "$4"
help: "Kafka $1 JMX metric info version and commit-id"
type: GAUGE
#kafka.producer:type=producer-topic-metrics,client-id="{clientid}",topic="{topic}"", partition="{partition}"
#kafka.consumer:type=consumer-fetch-manager-metrics,client-id="{clientid}",topic="{topic}"", partition="{partition}"
- pattern: kafka.(.+)<type=(.+)-metrics, client-id=(.+), topic=(.+), partition=(.+)><>(.+-total|compression-rate|.+-avg|.+-replica|.+-lag|.+-lead)
name: kafka_$2_$6
labels:
clientId: "$3"
topic: "$4"
partition: "$5"
help: "Kafka $1 JMX metric type $2"
type: GAUGE
#kafka.producer:type=producer-topic-metrics,client-id="{clientid}",topic="{topic}"
#kafka.consumer:type=consumer-fetch-manager-metrics,client-id="{clientid}",topic="{topic}"", partition="{partition}"
- pattern: kafka.(.+)<type=(.+)-metrics, client-id=(.+), topic=(.+)><>(.+-total|compression-rate|.+-avg)
name: kafka_$2_$5
labels:
clientId: "$3"
topic: "$4"
help: "Kafka $1 JMX metric type $2"
type: GAUGE
#kafka.connect:type=connect-node-metrics,client-id="{clientid}",node-id="{nodeid}"
#kafka.consumer:type=consumer-node-metrics,client-id=consumer-1,node-id="{nodeid}"
- pattern: kafka.(.+)<type=(.+)-metrics, client-id=(.+), node-id=(.+)><>(.+-total|.+-avg)
name: kafka_$2_$5
labels:
clientId: "$3"
nodeId: "$4"
help: "Kafka $1 JMX metric type $2"
type: UNTYPED
#kafka.connect:type=kafka-metrics-count,client-id="{clientid}"
#kafka.consumer:type=consumer-fetch-manager-metrics,client-id="{clientid}"
#kafka.consumer:type=consumer-coordinator-metrics,client-id="{clientid}"
#kafka.consumer:type=consumer-metrics,client-id="{clientid}"
- pattern: kafka.(.+)<type=(.+)-metrics, client-id=(.*)><>(.+-total|.+-avg|.+-bytes|.+-count|.+-ratio|.+-age|.+-flight|.+-threads|.+-connectors|.+-tasks|.+-ago)
name: kafka_$2_$4
labels:
clientId: "$3"
help: "Kafka $1 JMX metric type $2"
type: GAUGE
#kafka.connect:type=connector-task-metrics,connector="{connector}",task="{task}<> status"
- pattern: 'kafka.connect<type=connector-task-metrics, connector=(.+), task=(.+)><>status: ([a-z-]+)'
name: kafka_connect_connector_status
value: 1
labels:
connector: "$1"
task: "$2"
status: "$3"
help: "Kafka Connect JMX Connector status"
type: GAUGE
#kafka.connect:type=task-error-metrics,connector="{connector}",task="{task}"
#kafka.connect:type=source-task-metrics,connector="{connector}",task="{task}"
#kafka.connect:type=sink-task-metrics,connector="{connector}",task="{task}"
#kafka.connect:type=connector-task-metrics,connector="{connector}",task="{task}"
- pattern: kafka.connect<type=(.+)-metrics, connector=(.+), task=(.+)><>(.+-total|.+-count|.+-ms|.+-ratio|.+-avg|.+-failures|.+-requests|.+-timestamp|.+-logged|.+-errors|.+-retries|.+-skipped)
name: kafka_connect_$1_$4
labels:
connector: "$2"
task: "$3"
help: "Kafka Connect JMX metric type $1"
type: GAUGE
#kafka.connect:type=connector-metrics,connector="{connector}"
#kafka.connect:type=connect-worker-metrics,connector="{connector}"
- pattern: kafka.connect<type=connect-worker-metrics, connector=(.+)><>([a-z-]+)
name: kafka_connect_worker_$2
labels:
connector: "$1"
help: "Kafka Connect JMX metric $1"
type: GAUGE
#kafka.connect:type=connect-worker-metrics
- pattern: kafka.connect<type=connect-worker-metrics><>([a-z-]+)
name: kafka_connect_worker_$1
help: "Kafka Connect JMX metric worker"
type: GAUGE
#kafka.connect:type=connect-worker-rebalance-metrics
- pattern: kafka.connect<type=connect-worker-rebalance-metrics><>([a-z-]+)
name: kafka_connect_worker_rebalance_$1
help: "Kafka Connect JMX metric rebalance information"
type: GAUGE
- kind: KafkaBridge
apiVersion: kafka.strimzi.io/v1alpha1
metadata:
name: db-events
namespace: "{{ proj_nm_demo }}"
labels:
app: spring-music-cdc
template: spring-music-cdc
spec:
replicas: 1
bootstrapServers: db-events-kafka-bootstrap:9093
http:
port: 8080
jvmOptions:
gcLoggingEnabled: false
enableMetrics: true
authentication:
type: oauth
tokenEndpointUri: ${RH_SSO_SERVER_ADDRESS}/auth/realms/${RH_SSO_REALM}/protocol/openid-connect/token
clientId: kafka-bridge
clientSecret:
secretName: bridge-oauth-secret
key: secret
tlsTrustedCertificates:
- secretName: {{ ca_truststore_secret_name }}
certificate: xpaas.crt
tls:
trustedCertificates:
- certificate: ca.crt
secretName: db-events-cluster-ca-cert
template:
deployment:
metadata:
labels:
discovery.3scale.net: true
app: spring-music-cdc
app.kubernetes.io/part-of: spring-music-cdc
template: spring-music-cdc
annotations:
app.openshift.io/connects-to: db-events-kafka,sso
discovery.3scale.net/scheme: http
discovery.3scale.net/port: 8080
discovery.3scale.net/path: /
discovery.3scale.net/description-path: /openapi
- kind: KafkaConnector
apiVersion: kafka.strimzi.io/v1alpha1
metadata:
name: db-events
namespace: "{{ proj_nm_demo }}"
labels:
app: spring-music-cdc
strimzi.io/cluster: db-events
spec:
class: io.debezium.connector.mysql.MySqlConnector
tasksMax: 1
config:
database.hostname: summit-lab-spring-music-db
database.port: 3306
database.user: "${file:/opt/kafka/external-configuration/connector-config/connector.properties:dbUsername}"
database.password: "${file:/opt/kafka/external-configuration/connector-config/connector.properties:dbPassword}"
database.dbname: music
database.server.name: spring-music
database.server.id: 223344
database.whitelist: music
database.allowPublicKeyRetrieval: true
database.history.kafka.bootstrap.servers: db-events-kafka-bootstrap:9092
database.history.kafka.topic: dbhistory.music
table.whitelist: music.outbox_events
tombstones.on.delete : false
transforms: outbox
transforms.outbox.type: io.debezium.transforms.outbox.EventRouter
transforms.outbox.route.topic.replacement: "outbox.${routedByValue}.events"
transforms.outbox.table.field.event.id: event_id
transforms.outbox.table.field.event.key: aggregate_id
transforms.outbox.table.field.event.timestamp: event_timestamp
transforms.outbox.table.field.event.payload.id: aggregate_id
transforms.outbox.route.by.field: aggregate_type
transforms.outbox.table.fields.additional.placement: "event_id:envelope:eventId,event_timestamp:envelope:eventTimestamp,aggregate_id:envelope:aggregateId,aggregate_type:envelope:aggregateType,event_type:envelope:eventType"
# - kind: Route
# apiVersion: route.openshift.io/v1
# metadata:
# labels:
# app: spring-music-cdc
# template: spring-music-cdc
# name: db-events-connect-api
# spec:
# port:
# targetPort: rest-api
# to:
# kind: Service
# name: db-events-connect-api
# weight: 100
- kind: Route
apiVersion: route.openshift.io/v1
metadata:
labels:
app: spring-music-cdc
template: spring-music-cdc
name: db-events-bridge-api
namespace: "{{ proj_nm_demo }}"
spec:
port:
targetPort: rest-api
to:
kind: Service
name: db-events-bridge-service
weight: 100