# helm_charts_configmap-jmx.yaml
{{- if and .Values.prometheus.jmx.enabled .Values.jmx.configMap.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "kafka.fullname" . }}-metrics
  labels:
  {{- include "kafka.monitor.labels" . | nindent 4 }}
data:
  jmx-kafka-prometheus.yml: |+
{{- if .Values.jmx.configMap.overrideConfig }}
{{ toYaml .Values.jmx.configMap.overrideConfig | indent 4 }}
{{- else }}
    jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:{{ .Values.jmx.port }}/jmxrmi
    lowercaseOutputName: true
    lowercaseOutputLabelNames: true
    ssl: false
    {{ if .Values.jmx.whitelistObjectNames }}
    whitelistObjectNames: ["{{ join "\",\"" .Values.jmx.whitelistObjectNames }}"]
    {{ end }}
    rules:
    - pattern: kafka.controller<type=(ControllerChannelManager), name=(QueueSize), broker-id=(\d+)><>(Value)
      name: kafka_controller_$1_$2_$4
      labels:
        broker_id: "$3"
    - pattern: kafka.controller<type=(ControllerChannelManager), name=(TotalQueueSize)><>(Value)
      name: kafka_controller_$1_$2_$3
    - pattern: kafka.controller<type=(KafkaController), name=(.+)><>(Value)
      name: kafka_controller_$1_$2_$3
    - pattern: kafka.controller<type=(ControllerStats), name=(.+)><>(Count)
      name: kafka_controller_$1_$2_$3
    - pattern: kafka.server<type=(ReplicaFetcherManager), name=(.+), clientId=(.+)><>(Value)
      name: kafka_server_$1_$2_$4
      labels:
        client_id: "$3"
    - pattern : kafka.network<type=(Processor), name=(IdlePercent), networkProcessor=(.+)><>(Value)
      name: kafka_network_$1_$2_$4
      labels:
        network_processor: $3
    - pattern : kafka.network<type=(RequestMetrics), name=(RequestsPerSec), request=(.+)><>(Count)
      name: kafka_network_$1_$2_$4
      labels:
        request: $3
    - pattern: kafka.server<type=(.+), name=(.+), topic=(.+)><>(Count|OneMinuteRate)
      name: kafka_server_$1_$2_$4
      labels:
        topic: $3
    - pattern: kafka.server<type=(DelayedOperationPurgatory), name=(.+), delayedOperation=(.+)><>(Value)
      name: kafka_server_$1_$2_$3_$4
    - pattern: kafka.server<type=(.+), name=(.+)><>(Count|Value|OneMinuteRate)
      name: kafka_server_$1_total_$2_$3
    - pattern: kafka.server<type=(.+)><>(queue-size)
      name: kafka_server_$1_$2
    - pattern: java.lang<type=(.+), name=(.+)><(.+)>(\w+)
      name: java_lang_$1_$4_$3_$2
    - pattern: java.lang<type=(.+), name=(.+)><>(\w+)
      name: java_lang_$1_$3_$2
    - pattern : java.lang<type=(.*)>
    - pattern: kafka.log<type=(.+), name=(.+), topic=(.+), partition=(.+)><>Value
      name: kafka_log_$1_$2
      labels:
        topic: $3
        partition: $4
{{- end }}
{{- end }}