{{- if and .Values.prometheus.jmx.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "cp-kafka-connect.fullname" . }}-jmx-configmap
  labels:
    app: {{ template "cp-kafka-connect.name" . }}
    chart: {{ template "cp-kafka-connect.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
data:
  jmx-kafka-connect-prometheus.yml: |+
    jmxUrl: service:jmx:rmi:///jndi/rmi://localhost:{{ .Values.jmx.port }}/jmxrmi
    lowercaseOutputName: true
    lowercaseOutputLabelNames: true
    ssl: false
    rules:
    - pattern : "kafka.connect<type=connect-worker-metrics>([^:]+):"
      name: "cp_kafka_connect_connect_worker_metrics_$1"
    - pattern : "kafka.connect<type=connect-metrics, client-id=([^:]+)><>([^:]+)"
      name: "cp_kafka_connect_connect_metrics_$1_$2"
    - pattern : "kafka.connect<type=connector-task-metrics, connector=([^:]+), task=([^:]+)><>status: ([^:]+)"
      name: "cp_kafka_connect_connect_connector_metrics"
      value: 1
      labels:
        connector: $1
        task: $2
        status: $3
{{- end }}
