{{- if and .Values.prometheus.jmx.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "cp-ksql-server.fullname" . }}-jmx-configmap
  labels:
    app: {{ template "cp-ksql-server.name" . }}
    chart: {{ template "cp-ksql-server.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
data:
  jmx-ksql-server-prometheus.yml: |+
    jmxUrl: service:jmx:rmi:///jndi/rmi://localhost:{{ .Values.jmx.port }}/jmxrmi
    lowercaseOutputName: true
    lowercaseOutputLabelNames: true
    ssl: false
    rules:
    - pattern : 'io.confluent.ksql.metrics<type=ksql-engine-query-stats>([^:]+):'
      name: "cp_ksql_server_metrics_$1"
{{- end }}
